keen / keen-dataviz.js

Data Visualization Charting Library
MIT License
224 stars 48 forks source link

y axis cuts off some values in line chart #13

Closed joannecheng closed 8 years ago

joannecheng commented 8 years ago

From example page on http://keen.github.io/keen-dataviz.js/:

screen shot 2016-02-03 at 11 13 43 am

I think this is a c3 issue. We could solve this quickly by setting options.y.axis = { min: 0, padding: { bottom: 0 } } in the render method in default, but we'll lose some of the auto scaling that c3 does. Thoughts?

dustinlarimer commented 8 years ago

We can calculate the minimum w/ this (console demo):

var mins = [];
Keen.utils.each(chart.dataset.selectRow(0), function(col, i){
  if (i > 0) {
    mins.push(chart.dataset.minimum(chart.dataset.selectColumn(i)));
  }
});
console.log( chart.dataset.minimum(mins) );

(dataset.minimum() takes an array and returns the min value found)

dustinlarimer commented 8 years ago

This seems to be a known c3 issue, though it hasn't been addressed directly yet: https://github.com/masayuki0812/c3/issues/1523. This also appears to only occur in stacked line, spline, and step charts, which aren't exactly ideal types for representing a whole, as one would aim for by setting stacked = true. Perhaps we just wait on this awhile and see if it gets fixed upstream? What do you think @joannecheng?

dustinlarimer commented 8 years ago

Closing for now, as this should be fixed in a future update to c3.js.