How can i set max value to 1 and min value to 0 on y-axis for an AmChart?

4.4k views Asked by At
    var chart = AmCharts.makeChart("chartdiv", {
      "type": "serial",
      "dataProvider": chartData,
      "categoryField": "date",
      "categoryAxis": {
        "parseDates": false,
        "gridAlpha": 0.15,
        "minorGridEnabled": true,
        "axisColor": "#DADADA",
        "title": 'Timp'
      },
      "valueAxes": [{
        "axisAlpha": 0.2,
        "id": "v1",

      }],
      "graphs": [{
        "title": "Starea echipamentului",
        "id": "g1",
        "valueAxis": "v1",
        "valueField": "starea",
        "autoGridCount": true,
        "bullet": "round",
        "bulletBorderColor": "#FFFFFF",
        "bulletBorderAlpha": 1,
        "lineThickness": 2,
        "lineColor": "#b5030d",
        "negativeLineColor": "#0352b5",
        "balloonText": "[[category]]<br><b><span style='font-size:14px;'>value: [[value]]</span></b>",

      }],
       "titles": [
    {
      "size": 15,
      "text": window.location.href.split('?')[1].split('=')[1].replace('%20',' ')
    }
  ],

        "legend": {
    "useGraphSettings": true
  },

      "chartCursor": {
        "fullWidth": true,
        "cursorAlpha": 0.1
      },
      "chartScrollbar": {
        "scrollbarHeight": 40,
        "color": "#FFFFFF",
        "autoGridCount": true,
        "graph": "g1"
      },
      "mouseWheelZoomEnabled": true,
      "responsive": {
        "enabled": true
      },
      "export": {
          "enabled": true,
          "libs": {
            "path": "http://amcharts.com/lib/3/plugins/export/libs/"
          }
        }
    });

So my graph on y-axis, has only 0, 0.5 and 1 values. If i have part of the graph where i have 0.5 on y-axis it apeears values between 0.5 (0.4 min and 0.6 max). How ever i want my graph on y axis to display 0 and 1, not 1.2 . Any ideas?

1

There are 1 answers

0
martynasma On BEST ANSWER

Use minimum and maximum properties for the value axis:

 "valueAxes": [{
    "axisAlpha": 0.2,
    "id": "v1",
    "minimum": 0,
    "maximum": 1
 }],

That should do the trick.

In some rare cases, you might also want to set strictMinMax. But for this particular case, you're probably not going to need it.