amcharts3
amcharts3 copied to clipboard
Line graph offset from category axis
Hi.
Maybe someone know how to offset graph from category axis?
When value = 0, line is invincible.
O maybe there is a way to offset value axis or something like that...
Hi there,
Have you tried setting a minimum
on your valueAxis? (You might need to enforce this setting by adding strictMinMax: true
.
"valueAxes": [{
"minimum": -0.1,
"strictMinMax": true
}]
Hope this helps!
Docs: https://docs.amcharts.com/3/javascriptcharts/ValueAxis#minimum https://docs.amcharts.com/3/javascriptcharts/ValueAxis#strictMinMax
Hi,
Thanks for suggestion I haven't tried it yet, but I will. But what if I don't know max and min values (another case)? Eg. I can have 100k amount of data. Is there any way to set offset from bottom (value axis, graph)?
That would require some extra logic. There are no settings that would do what you described, but you can set the minimum (or maximum) dynamically, based on your data, inside addInitHandler
. This method is used before the chart is initialized.
Here is an example for a simple column chart:
AmCharts.addInitHandler(function(chart) {
// find data minimum & maximum:
var min = chart.dataProvider[0].value;
var max = chart.dataProvider[0].value;
for (var i in chart.dataProvider) {
if (chart.dataProvider[i].value > max) {
max = chart.dataProvider[i].value;
}
if(chart.dataProvider[i].value < min){
min = chart.dataProvider[i].value;
}
}
min -= 10; // subtract an arbitrary offset
// set axes max based on value above:
chart.valueAxes[0].minimum = min;
// chart.valueAxes[0].maximum = max;
chart.valueAxes[0].strictMinMax = true;
});
Yes, looks like I have to add min/max logic to my pivot. Thanks :)