0

I want to know how I can change the scale of y axis of the stackedAreaChart.

Imagine I have an array, I want to adjust the y axis to the max of the array and I want to draw all values in the new scale.

var odata = [10,40];

    nv.addGraph(function() {
      var chart = nv.models.stackedAreaChart();
                 .x(function(d) { return d[0] })
                 .y(function(d) { return d[1] })
                  .useInteractiveGuideline(true);

      chart.xAxis
          .showMaxMin(false)
          .tickFormat(function(d) { return d3.time.format('%x')(new Date(d)) });

      chart.yAxis
          .tickFormat(d3.format(',.2f'));

      d3.select('#chart svg')
        .datum(data)
          .transition().duration(500).call(chart);

      nv.utils.windowResize(chart.update);

      return chart;
    });
alifirat
  • 2,899
  • 1
  • 17
  • 33

1 Answers1

0

I found the solution and I post here :

var odata = [10,40];

    nv.addGraph(function() {
      var chart = nv.models.stackedAreaChart();
                 .x(function(d) { return d[0] })
                 .y(function(d) { return d[1] })
                 .yDomain([0, 
                    d3.max(odata,function (d) { return d; })])
                  .useInteractiveGuideline(true);

      chart.xAxis
          .showMaxMin(false)
          .tickFormat(function(d) { return d3.time.format('%x')(new Date(d)) });

      chart.yAxis
          .tickFormat(d3.format(',.2f'));

      d3.select('#chart svg')
        .datum(data)
          .transition().duration(500).call(chart);

      nv.utils.windowResize(chart.update);

      return chart;
    }); 
alifirat
  • 2,899
  • 1
  • 17
  • 33