You must be logged in to post your query.
Home › Forums › Chart Support › How to use fixed Y axis 0-100%
Tagged: Chart fixed Y Axis
Hi, I have data that can be only 0 to 100. I would like the Y axis to always show 0-100 regardless of highest data point. Is this possible?
Thanks, Bill
@wep,
You can specify the minimum and maximum permitted values by setting minimum and maximum property of axisY to 0 and 100 respectively.
If this is not what you are looking for can you please create a jsfiddle so that we can look into your code and help you out better. ___ Suyash Singh Team CanvasJS
i have data like:
dataPoints: [ { x: 10, y: 150 }, { x: 20, y: 400}, { x: 30, y: 500 }, { x: 40, y: 2000 }, { x: 50, y: 814 }, { x: 60, y: 68 }, { x: 70, y: 28 }, { x: 80, y: 34 }, { x: 90, y: 14} ]
I want to show axisY to 100%. is there any solution.
@saqib,
Can you kindly brief us more about your scenario and what is the reference value for 100% (100% of what value) so that we can understand your requirement better and help you out?
—- Manoj Mohan Team CanvasJS
I want to Y value to counted as 100%. Actually my Data looks like this:
dataPoints: [ { x: new Date(), y: 150 }, { x: new Date(), y: 400}, { x: new Date(), y: 500 }, { x: new Date(), y: 2000 }, ]
`axisY: { suffix: “%” // this should be calculated to 100% of Y values. },`
Please take a look at this JSFiddle.
Thanks. It Worked.
One more thing!! What if i have More then 1 Line. how can i calculate 100% for Multi data (multiple objects as dataPoints). in the blow data i have max point in 2 object and it can be in any object as it is multi line chart. how can i calculate in that scenario.
data
data: [ { // Change type to "doughnut", "line", "splineArea", etc. type: "spline", dataPoints: [ { x: 10, y: 150 }, { x: 20, y: 400 }, { x: 30, y: 500 }, { x: 40, y: 2000 }, { x: 50, y: 814 }, { x: 60, y: 68 }, { x: 70, y: 28 }, { x: 80, y: 34 }, { x: 90, y: 14 } ] }, { type: "spline", dataPoints: [ { x: 10, y: 150 }, { x: 20, y: 400 }, { x: 30, y: 800 }, { x: 40, y: 1500 }, { x: 50, y: 814 }, { x: 60, y: 68 }, { x: 70, y: 3000 }, { x: 80, y: 34 }, { x: 90, y: 14 } ] } ]
Got the solution with some changes in for Loop.
let a = []; chart.options.data.forEach((val, i)=>{ //alert(JSON.stringify(val), i); val.dataPoints.forEach((val2)=>{ a.push(val2.y) }) }) maxY = Math.max(...a); console.log(maxY, a)
You must be logged in to reply to this topic. Login/Register