在amchart上的蜡烛图画线

时间:2017-08-16 10:41:25

标签: javascript amcharts

我正在使用amchart stock chart

function createStockChart() {
    var chart = new AmCharts.AmStockChart();
    var dataSet = new AmCharts.DataSet();

    // make candlechart

    dataSet.fieldMappings = [{
        fromField: "open",
        toField: "open"
    }, {
        fromField: "close",
        toField: "close"
    }, {
        fromField: "high",
        toField: "high"
    }, {
        fromField: "low",
        toField: "low"
    }, {
        fromField: "volume",
        toField: "volume"
    }, {
        fromField: "testValue",
        toField: "testValue"
    }];
    dataSet.dataProvider = chartData;
    dataSet.categoryField = "date";


// make line to be drawn on the candle stock

    var dataSet2 = new AmCharts.DataSet();
    dataSet2.fieldMappings = [{
        fromField: "close",
        toField: "value"
    }];
    dataSet2.color = "#33888a";
    dataSet2.dataProvider = chartData;
    dataSet2.compared = false; // if I made here true, the line appears but it will be shown as percentage!!.
    dataSet2.title = "Open";
    dataSet2.categoryField = "date";

我想在蜡烛图上划一条线。

如果我将true用于compared字段,则该线条会显示在蜡烛部分上,但Y轴会变为百分比。

这是正确的,因为它是用于比较功能。

但是我想将图表附加起来不是为了比较。

如何在蜡烛图上简单画一条线???

1 个答案:

答案 0 :(得分:1)

您可以在面板对象中将recalculateToPercents设置为"never",以防止图表使用百分比,只需添加该行。这在the knowledge base

中有更详细的解释

这里是fiddle that illustrates this。它使用JSON设置,但基于对象的设置类似。