Hi anyone know How get max yAxis value ?
I have line chart with 3 series and i want know max yAxis value that set it for calculate step and set end value yAxis…
Hi
Something like this:
function max_value(){
var arr = [];
q = barChart1.dataCount();
for(var i=1; i<q; i++){
arr.push(barChart1.get(barChart1.idByIndex(i)).sales);
}
alert(Math.max.apply( Math, arr ));
}
thx
You are welcome!
Darya, Hi again … maybe i am stupid, but i can’t use your code …
i try this in my code
yAxis:{
start:0,
step:100,
end: function(){
var test="1000";
return test;
}
}
but it’s not work …
Sorry, but my code and your code aren’t similar absolutely.
That do you want to achieve with your piece of code?
See attachment.
13.01.30.rar (378 KB)
Darya, i try your code too …
my code it’s only sample when i use function in end value, chart show not correctly …
yAxis:{
start:0,
step:100,
end: function(){
var test="1000";
return test;
}
}
i can’t get end value from simple function …
And can you tell me please, can i refresh chart without blink the screen ???
i try use chart.refresh() function from manual, but it’s not work, chart not refresh
when i use chart.clearAll();chart.load - chart refresh but with blink on page
it’s possible refresh the chart without blinking?
END value or MAX value?
I provided you how to get MAX value
i want get max value from yAxis data, and use it in the
yAxis:{
start:0,
step:100,
end: THIS IS MAX VALUE FROM LOADED DATA
}
maybe i can explain what i mean
i have 3 series on graph
yAxis changes from 0 to 1500 and step 100
when yAxis scales autocalculate , scales shows normally when max value less then 800 and scales = 0,100,200,300,400,500,600,700,800
but when max value more then 800, yAxis scales autocalculate set step=500 and scales = 0,500,1000
but i need fix step =100
and i want set start:0,step:100 but end value set as max y value from series
When you define youк chart such way:
i want get max value from yAxis data, and use it in the
yAxis:{
start:0,
step:100,
end: 'max'
}
you haven’t already this coordinate, because your chart is still not loaded.
Darya how i can save step 100 on yAxis if i don’t know how much will be max value ?
Well, like in a sample:
dhtmlx.com/docs/products/dht … _json.html
yAxis: {
start: 0,
end: 100
}
You can redraw the chart, when you get a value exceeding 100
Hm … i want step 100, not end 100 …
end value changes in time and in one refresh end value can be 800, but in another time in refresh end value can be 1400 …
Ok
Make the step 100.
What exactly issue have you now?
Hello,
you need to calculate the max value manually before chart is created. So, in the yAxis config you should pass calculated value.
Here is the example that is based on the sample from Chart package - dhtmlxChart/samples/06_bar_chart/06_series.html
- calculate the max value for all series:
var data = multiple_dataset;
var series = ["sales","sales2","sales2"];
var maxValue = -Infinity;
for(var i= 0; i < series.length;i++){
for(var j = 0; j < data.length; j++){
var value = parseFloat(data[j][series[i]]);
if(maxValue < value)
maxValue = value;
}
}
- set calculated maxValue in yAxis config (probably you will need to increase this value to adjust to the 100 step):
var barChart = new dhtmlXChart({
...
yAxis:{
start:0,
step:100,
end: maxValue
},
...
}
...
Alexandra var data = multiple_dataset; it’s massive of loaded data ??
i load values from json file, how i can put values from json file in the var data …
it’s massive of loaded data ??
Yes, it is.
i load values from json file, how i can put values from json file in the var data …
You can to load data using Ajax. For example the solution with dhtmlx.ajax():
dhtmlx.ajax(url, function(text){
var data = dhtmlx.DataDriver.json.toObject(text);
// your code with chart init
});
Alexandra how i can reloaded yAxis values without reloading all page ??? only reload graph div
sorry i already solve my problem.
i use chart.destructor() and create chart again