简体   繁体   English

堆叠图-AmChart-Javascript

[英]Stacked Graph - AmChart - Javascript

i've created an AmChart wich is supposed to show stacked aeras. 我创建了一个AmChart,应该显示堆叠的aeras。 I don't know why, everything goes fine except the graphs aren't stacked... 我不知道为什么,除了没有堆叠图形,其他一切都很好...

Here's the code : 这是代码:

  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 ); 
 

do you have an idea why the "regular" value of the Stacktype propertie doesn't apply ? 您有一个主意,为什么Stacktype属性的“常规”值不适用?

Thanks 谢谢


i changed the spelling, here's the code now : 我更改了拼写,这是现在的代码:

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;

The final chart is still not stacked... I don't know why.. The legend is not working too thou.. 最终的图表仍然没有堆积起来。。。我不知道为什么。

Here's is the dataprovider table i'm using : 这是我正在使用的dataprovider表:

enter image description here 在此处输入图片说明

I really don't understand what's wrong im my JSON... Thanks for you help :) 我真的不明白我的JSON有什么问题...谢谢您的帮助:)

I think the problem is due the misspelled variable name: 我认为问题是由于变量名称拼写错误:

  • In your JSONChart object try to change the attribute name from "ValueAx i s" to "ValueAx e s" instead. 在您的JSONChart对象中,尝试将属性名称从“ ValueAx i s”更改为“ ValueAx e s”。

Ref: 参考:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM