Addepar / ember-charts

https://opensource.addepar.com/ember-charts/
Other
784 stars 131 forks source link

Setting default max and min for Y Axis #204

Closed klubiniecki closed 5 years ago

klubiniecki commented 7 years ago

Hi,

Is there any way to set the maximum and minimum value for Y Axis? By default it changes depending on the data.

Thanks, K

alvinvogelzang commented 7 years ago

@Klubiniecki yes that's possible by customizing the component. To do this for the yDomain for example I do this by adding custom properties called fixedMaxOfYSeries and fixedMinOfYSeries;

This is the part I've written in the yDomain CP:

    let maxOfSeries;
    let fixedMaxOfYSeries = this.get('fixedMaxOfYSeries');

    if (fixedMaxOfYSeries) {
      maxOfSeries = fixedMaxOfYSeries
    } else {
      maxOfSeries = d3.max(lineData, function(d) {
        return d3.max(d.values, function(dd) {
          return dd.value;
        });
      });
    }

    let minOfSeries;
    let fixedMinOfYSeries = this.get('fixedMinOfYSeries');

    if (fixedMinOfYSeries) {
      minOfSeries = fixedMinOfYSeries
    } else {
      minOfSeries = d3.min(lineData, function(d) {
        return d3.min(d.values, function(dd) {
          return dd.value;
        });
      });
    }