Posts

Showing posts with the label d3plus

Use data field in chart subtitle

Image
Clash Royale CLAN TAG #URR8PPP Use data field in chart subtitle I have charts with some data imported from a CSV. Among this data, there is a "year" field. For each chart to be displayed, I would like to have a subtitle which changes dynamically according to the year the chart is displaying. For instance, if I'm displaying data from 2017 ("year" field in my data object), I would like to have a title "Rain data" and a subtitle "Year 2017", and the same if I switch to every year in my data object. Roughly, it should be something like: .title({ value: "Distribució de la població per edat i sexe", sub: function(){ return "Year " + data.year; } }) I've tried to do something similar to what's done in the formatting function with the params and keys , but it just doesn't recognize the fields: .format({ "text": function(text, params) { if (text === "usd") { return "...