堆积图 - AmChart - Javascript

时间:2018-05-03 09:08:34

标签: javascript json amcharts stacked areas

我创造了一个AmChart,它应该显示堆叠的aeras。 我不知道为什么,一切都很好,除了图表没有堆叠......

以下是代码:

 var JSONChart = {
        "type":"serial",
        "backgroundAlpha":1,
        "backgroundColor":"white",
        "autoMargin":true,"autoMarginOffset":30,
        "marginRight":50,
        "creditsPosition":"bottom-right",
        "titles":"TEST",
        "fontSize":15,
        "categoryAxis": {"parseDates":true,"minPeriod":"ss","axisAlpha":1,"gridAlpha":"white",},
        "chartScrollbar":{"enabled":true,"backgroundAlpha":1},
        "dataProvider":Tableau,
        "categoryField":"Date",
        "ValueAxis":[{"stackType":"regular","axisAlpha":0,"gridAlpha":0.1,"unit":"MWh","unitPosition":"left"}],
        "chartCursor":{"cursorColor":"red","valueLineBalloonEnabled":true,"valueLineEnabled":true,"valueZoomable":true},
        }

        var Graphiques =  [];
        for (var j=1;j<TableFinale[0].length;j++){
            var Param = {};
            Param.id = "g"+j.toString();
            Param.type = "line";
            Param.lineColor = "red";
            Param.valueField = j.toString();
            Param.fillAlphas = 0.3;
            Graphiques.push(Param);
        }
        JSONChart.graphs=Graphiques;

        customVisualzationObject = AmCharts.makeChart("chartdiv",JSONChart );
 

你知道为什么Stacktype属性的“常规”值不适用吗?

由于

我更改了拼写,现在是代码:

evar JSONChart = {
    "type":"serial",
    "ValueAxes": [{"stackType":"regular","axisAlpha":0,"gridAlpha":0.1,"unit":"MWh","unitPosition":"left"}],
    "backgroundAlpha":1,
    "backgroundColor":"white",
    "autoMargin":true,"autoMarginOffset":30,
    "marginRight":50,
    "creditsPosition":"bottom-right",
    "titles":"TEST",
    "fontSize":15,
    "categoryAxis": {"parseDates":true,"minPeriod":"mm","axisAlpha":1,"gridAlpha":"white"},
    "chartScrollbar":{"enabled":true,"backgroundAlpha":1},
    "dataProvider":Tableau,
    "categoryField":"Date",
    "chartCursor":{"cursorColor":"blue","valueLineBalloonEnabled":true,"valueLineEnabled":true,"valueZoomable":true},
    "Legend":{"position":"top","valueTextRegular":"bite","valueWidth":100},
    "export": {
    "enabled": true, "position":"bottom-right" }
    }

    var Graphiques =  [];
    for (var j=1;j<TableFinale[0].length;j++){
        var Param = {};
        Param.id = "g"+j.toString();
        Param.type = "line";
        Param.lineColor = getRandomColor();
        Param.valueField = j.toString();
        Param.fillAlphas = 0.3;
        Graphiques.push(Param);
    }
    JSONChart.graphs=Graphiques;

最终图表仍然没有堆叠......我不知道为什么...... 这个传说也不起作用..

这是我正在使用的数据提供者表:

enter image description here

我真的不明白我的JSON有什么问题... 谢谢你的帮助:)

1 个答案:

答案 0 :(得分:1)

我认为问题是错误的变量名称:

  • 在您的JSONChart对象中,尝试更改&#34; ValueAx i s&#34;的属性名称。到&#34; ValueAx e s&#34;代替。

参考: