Opened 12 years ago

Closed 11 years ago

#5228 closed defect (invalid)

Line chart is not working correctly as expected with data x,y(0,0)

Reported by: guest Owned by: Eugene Lazutkin
Priority: high Milestone: 1.1
Component: Charting Version: 1.0
Keywords: Chart2D Cc:
Blocked By: Blocking:

Description

I have noticed one small issue with charting. When I have tried creating 2d line chart with y value starting at 0, line was not drawn exactly starting at x,y(0,0) postion.

Here I have attached the code what I have tried to draw line chart. More details can be also found in forum discussion in DOJOx support under title"DOJO 1.0 Charting" created by dojo_user28.


<htm>
<head>

<script type="text/javascript" src="js/dojo-1.0.1rc4/dojo/dojo.js" djConfig="isDebug: true"></script>
<script type="text/javascript">
        dojo.require("dojox.charting.Chart2D");
        dojo.require("dojox.charting.themes.PlotKit.orange");

        var seriesA=[0,0,0,0,0,0,0,12,24,36,48,60,60,74,88,102,116,130,144,158,172,186,200,214,214,230,246,262,278,294,310,326,342,358,374,376,
                                588,608,628,648,668,688,708,728,748,768,788,808,808,827,846,865,884,903,922,941,960,979,998,1017,1036,1055,1074,1093,1126,
                                1340,1359,1378,1397,1416,1435,1454,1473,1492,1511,1530,1549,1568,1587,1606,1625,1644,1663,1682,1701,1701,1718,1735,1752];
        var labels=[{value: 0, text: "0"},
                    {value: 12, text: "1"},
          {value: 24, text: "2"},
                    {value: 36, text: "3"},
                {value: 48, text: "4"},
                {value: 60, text: "5"},
                {value: 72, text: "6"},
                {value: 84, text: "7"},
                {value: 96, text: "8"},
                {value: 108, text: "9"},
                {value: 120, text: "10"},
                {value: 132, text: "11"},
                {value: 144, text: "12"},
                {value: 156, text: "13"},
                {value: 168, text: "14"},
                {value: 180, text: "15"},
                {value: 192, text: "16"},
                {value: 204, text: "17"},
                {value: 216, text: "18"},
                {value: 228, text: "19"},
                {value: 240, text: "20"},
                {value: 252, text: "21"},
                {value: 264, text: "22"},
                {value: 276, text: "23"},
                {value: 288, text: "24"}
                ];

        var createChart = function(){
                      chart = new dojox.charting.Chart2D("test");
                      chart.setTheme(dojox.charting.themes.PlotKit.red);

                      chart.addAxis("x", {min:0,max:288,fixLower: "minor", fixUpper: "major",
                                          majorTickStep:12,
                                          minorTickStep:2,
                                          fontColor:"blue",
                                          labels: labels
                                    });

                    chart.addAxis("y", {vertical:"true",
                                        min: 0,
                                        max: 5000,
                                        majorTickStep: 1000,
                                        fontColor:"blue"});

                        chart.addPlot("default", {type: "Lines"});

                        chart.addSeries("Series A", seriesA,{stroke:{color: "red", width: 4}, fill: "lightpink"});
                        chart.render();
                        };

     dojo.addOnLoad(createChart);

 </script>
 </head>
 <body>

   <div id="test" style="width: 100%; height: 60%;"></div>

 </body>

</html>

Change History (4)

comment:1 Changed 12 years ago by Eugene Lazutkin

Component: DojoxCharting
Owner: changed from Tom Trenka to Eugene Lazutkin

comment:2 Changed 12 years ago by Eugene Lazutkin

Status: newassigned

comment:3 Changed 11 years ago by Eugene Lazutkin

I was able to reproduce it with your program. Thx.

comment:4 Changed 11 years ago by Eugene Lazutkin

Resolution: invalid
Status: assignedclosed

Actually implied x starts with 1, not 0. So the first point is actually x,y(1, 0) --- using your notation. That explains a horizontal shift in 1 unit. If you want, you can specify x directly like so:

var seriesA = [{x: 0, y: 0}, {x: 1, y: 0}, ... ];
Note: See TracTickets for help on using tickets.