amcharts.js - 如果值太不同,则使引导线可见

时间:2016-02-28 15:54:58

标签: javascript amcharts

我需要附图中的内容。 I need something like this请遵循此fiddle

正如您所看到的,我添加了两条引导线,但它们不可见,因为它的值大于图形值。有什么办法,我可以让它们可见吗?也许有一些方法可以缩小图表或其他东西..请参阅下面的代码或jsfiddle。 谢谢,

var chart = AmCharts.makeChart("chartdiv", {
    "type": "serial",
    "theme": "light",
    "dataDateFormat": "YYYY-MM-DD HH:NN",
    "dataProvider": [{
        "date": "2012-01-01",
        "value": 8
    }, {
        "date": "2012-01-02",
        "value": 10
    }, {
        "date": "2012-01-03",
        "value": 12
    }, {
        "date": "2012-01-04",
        "value": 14
    }, {
        "date": "2012-01-05",
        "value": 11
    }, {
        "date": "2012-01-06",
        "value": 6
    }, {
        "date": "2012-01-07",
        "value": 7
    }],
    "valueAxes": [{
        "axisAlpha": 0,
        "position": "left",
        "tickLength": 0
    }],
    "graphs": [{
        "bullet": "none",
        "valueField": "value"
    }],
    "categoryField": "date",
    "categoryAxis": {
        "parseDates": true,
        "axisAlpha": 0,
        "gridAlpha": 0.1,
    },
  "guides": [{
    "value": 25,
    "toValue": 25,
    "lineColor": "#CC0000",
    "fillAlpha": 1,
    "fillColor": "#CC0000",
    "label": "critical"
  }, {
    "value": 20,
    "toValue": 20,
    "lineColor": "#CCF000",
    "fillAlpha": 1,
    "fillColor": "#CCF000",
    "label": "normal"
  }]
});

1 个答案:

答案 0 :(得分:3)

答案是值轴设置includeGuidesInMinMax。只需将其设置为true,它将重新计算值轴刻度以包含所有当前指南:

"valueAxes": [{
  "axisAlpha": 0,
  "position": "left",
  "tickLength": 0,
  "includeGuidesInMinMax": true
}]

这是您更新的fiddle