如何为AmChart将y值设置为1并将最小值设置为0?

时间:2015-06-15 21:09:18

标签: amcharts

    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/"
          }
        }
    });

所以我在y轴上的图表只有0,0.5和1的值。如果我有一部分图表,我在y轴上有0.5,它的值介于0.5(0.4分钟和0.6最大值)之间。我怎么想让y轴上的图形显示0和1,而不是1.2。有什么想法吗?

1 个答案:

答案 0 :(得分:3)

对值轴使用minimummaximum属性:

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

这应该可以解决问题。

在极少数情况下,您可能还想设置strictMinMax。但对于这种特殊情况,你可能不会需要它。