0
votes

i've created an AmChart wich is supposed to show stacked 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 ?

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 :

enter image description here

I really don't understand what's wrong im my JSON... Thanks for you help :)

1

1 Answers

1
votes

I think the problem is due the misspelled variable name:

  • In your JSONChart object try to change the attribute name from "ValueAxis" to "ValueAxes" instead.

Ref: