Steps to reproduce:
Expected results: the popup contains 32.600
Actual results: the popup contains 32,600
chart_layout
margin. I can return the current values but can‘t work out the syntax for setting a new value. To console the values I just console.log(chart_layout.margins())
But how do I set the top margin to say to 20. I’ve tried variations on the following but can’t get any to work chart_layout.margins({top:20})
but can’t seem to get it correct
Hi @bobhaslett. Unlike most of the methods, the margins
property is read-only. The values returned when you call chart_layout.margins()
are calculated based on the other settings (e.g. the size and orientation of tick marks, presence or absence of axis titles, specified height and width etc etc).
You can actually tell the chart_layout
instance not to calculate one or more of these properties when you call update
by passing an object with a margins property e.g. chart_layout.update({margins: {top: 20}})
. (You'll have to do this every time you call update
if you want it to persist.) This may or may not be useful, depending on what it is you're actually trying to do. It doesn't clip the chart to those margins and it doesn't affect the size of content contained in the margins. It just tells the instance not to calculate the given margin and just to use the value it's been given. It effectively changes the bounding box the instance thinks it takes up. This can be useful if you are trying to place multiple instances side by side with shared margins.
Hi Flourish team. Could tell me how to programmatically set an x date axis to a specific custom set of ticks. I have a function that calculates the ticks I want and returns them in an array, this, xAxisTicks
0: Mon Mar 26 2012 00:00:00 GMT+0100 (British Summer Time) {}
1: Tue Jan 01 2013 00:00:00 GMT+0000 (Greenwich Mean Time) {}
2: Wed Jan 01 2014 00:00:00 GMT+0000 (Greenwich Mean Time) {}
3: Thu Jan 01 2015 00:00:00 GMT+0000 (Greenwich Mean Time) {}
4: Fri Jan 01 2016 00:00:00 GMT+0000 (Greenwich Mean Time) {}
5: Sun Jan 01 2017 00:00:00 GMT+0000 (Greenwich Mean Time) {}
6: Mon Jan 01 2018 00:00:00 GMT+0000 (Greenwich Mean Time) {}
7: Tue Jan 01 2019 00:00:00 GMT+0000 (Greenwich Mean Time) {}
8: Wed Jan 01 2020 00:00:00 GMT+0000 (Greenwich Mean Time) {}
9: Fri Jan 01 2021 00:00:00 GMT+0000 (Greenwich Mean Time) {}
10: Mon Apr 26 2021 00:00:00 GMT+0100
Normally I would pass this to the .ticks() axis function in d3. But I can’t work out how to do this using the chart_layout()
I’ve tried using chart_layout.xData(xAxisTicks) whci almost works but the beginning and end ticks are removed. When I console out console.log(chart_layout.xTicks())which give me these:
0: {index: 0, value: Tue Jan 01 2013 00:00:00 GMT+0000 (Greenwich Mean Time), lines: Array(1), significant_digits: NaN, exponent: 12, …}
1: {index: 1, value: Wed Jan 01 2014 00:00:00 GMT+0000 (Greenwich Mean Time), lines: Array(1), significant_digits: NaN, exponent: 12, …}
2: {index: 2, value: Thu Jan 01 2015 00:00:00 GMT+0000 (Greenwich Mean Time), lines: Array(1), significant_digits: NaN, exponent: 12, …}
3: {index: 3, value: Fri Jan 01 2016 00:00:00 GMT+0000 (Greenwich Mean Time), lines: Array(1), significant_digits: NaN, exponent: 12, …}
4: {index: 4, value: Sun Jan 01 2017 00:00:00 GMT+0000 (Greenwich Mean Time), lines: Array(1), significant_digits: NaN, exponent: 12, …}
5: {index: 5, value: Mon Jan 01 2018 00:00:00 GMT+0000 (Greenwich Mean Time), lines: Array(1), significant_digits: NaN, exponent: 12, …}
6: {index: 6, value: Tue Jan 01 2019 00:00:00 GMT+0000 (Greenwich Mean Time), lines: Array(1), significant_digits: NaN, exponent: 12, …}
7: {index: 7, value: Wed Jan 01 2020 00:00:00 GMT+0000 (Greenwich Mean Time), lines: Array(1), significant_digits: NaN, exponent: 12, …}
8: {index: 8, value: Fri Jan 01 2021 00:00:00 GMT+0000 (Greenwich Mean Time), lines: Array(1), significant_digits: NaN, exponent: 12, …}
nice()
extents, whether to extend to include zero (e.g. for bar charts in a template that also supports non-zero axes), and whether to show a specific selection of ticks.
chart_layout.xData(dateExtent)
where dateExtent
is an array containing two date objects (start date and end date). I’ve tried to pass in my bound data chart_layout.xData(data.data)
but all this does is generate a linear axis based on the values in the data. I’ve also tried chart_layout.xData([data.data,['date']])
which returns a axis with a series of tick all labelled '1970' Given the following data what would you pass to create a date axis