4

In my code below, the data is updated but the chart is not redrawn in the same position. What is the problem in my code?

(more information in firebug if you want - json is updated when the las dropdown is changed - only the category designer have data)

 <script type="text/javascript">
    dojo.query(".estatistica").onchange(function() {
        dojo.xhrPost({
            url: "drop2.php",
            handleAs: "json",
            postData: "data=" + $(this).val(),
            preventCache: true,
            load: function(json) {
                $msgs = [];

                for (var i = 1; i < 10; i++) {
                    $msgs.push(parseFloat(json[i]["valor" + i]));
                }
                var chart1 = new dojox.charting.Chart2D('chart1');
                chart1.addPlot("default", {
                    type: "StackedAreas",
                    markers: true,
                    tension: "S",
                    lines: true,
                    areas: true,
                    labelOffset: 0,

                });
                chart1.addAxis('x');
                chart1.addAxis('y', {
                    vertical: true,
                    max: 80000
                });

                chart1.addSeries('January Visits', $msgs, {
                    stroke: 'red',
                    fill: 'pink'
                });


                chart1.updateSeries("January Visits", $msgs);
                chart1.render();


            var stackedAreaLegend = new dojox.charting.widget.SelectableLegend({
                chart: chart1
            }, "legend1");

            stackedAreaLegend.refresh();

            }
        });
    });
</script>

thanks

Trott
  • 66,479
  • 23
  • 173
  • 212
anvd
  • 3,997
  • 19
  • 65
  • 126

1 Answers1

0

First, render your chart, then do any updates. Just switch these two lines, as shown:

            chart1.render();
            chart1.updateSeries("January Visits", $msgs);
Lance Roberts
  • 22,383
  • 32
  • 112
  • 130