ZingChart: Is there a way for the min Y-scale value to not include zero?
Adjust The minValue
At the very least, you must set the minValue
property on scaleY
.
scaleY: { minValue:20 ... }
Example: https://demos.zingchart.com/view/embed/0P1S746R
If you'd like to set the minimum value programmatically, you can the ZingChart API do some preprocessing and analysis before rendering the chart. Say we want to to set the chart 'minValue' to be 10 below the lowest value, we can do that dynamically with 'zingchart.bind(null,'dataparse',...)'
zingchart.bind(null, 'dataparse', function(e,oGraph) { var dynamicMinvalue = 0; // sanity checks so we don't throw console error with malformed graph JSON if (oGraph && oGraph.graphset && oGraph.graphset[0]) { if (oGraph.graphset[0].series && oGraph.graphset[0].series[0]) { dynamicMinvalue = oGraph.graphset[0].series[0].values.reduce(function(a,b) { return Math.min(a, b); }); oGraph.graphset[0].scaleY.minValue = (dynamicMinvalue - 10); } } return oGraph; });
Example: https://demos.zingchart.com/view/embed/0P1S746R
Hide The Value
Apart from changing the minimum value. You can hide the value. In ZingChart we call this the scale item.
scaleY: { item: { // hide y zero rules: [ { rule: '%i === 0', visible:false } ] } }, scaleX: { item: { // move x zero rules: [ { rule: '%i === 0', offsetX: -10 } ] } },
Example: https://demos.zingchart.com/view/embed/0P1S746R
Documentation
scales Tutorial
scale-x JSON Docs
scale-y JSON Docs
dataparse API Event