|
Urgent--- Time stamp display problem in Multi line chart |
Posted by Vighneshwar on Mar-29-2010 14:43 |
|
Dear All,
I have a small problem, please provide me the code.
I have a two lines to display on same chart for a 2 days forecast.
First line : values for every 30 min. I took this in one array, it contains total 96 values for 2 days.
Second line : values for every 3 hours. I took in another array, it contains total 16 values for 2 days.
when iam displaying the both lines on same chart, time stamps in graph i took first line to display then second line is displaying the same within 6 hours (total 16 points displaying at 30 min distance only with same like first line).
I want to scatter the second line to entire graph, the points should be displayed when 3 hours came in the time stamp then only next point should display, my first line will be displayed 6 points in that 3 hours time stamp. But it's not happening like that.
Here iam providing the URL of my charts: www.incois.gov.in/Incois/charts/wrbimage.jsp
You can mail me the code to my mail id : vighneshwar@incois.gov.in
Please, give me reply ASAP, i need to solve this today it self (if any one have clear idea, provide me the phone number, i will call you).
Thanks & Regards,
Vighneshwar.
|
Re: Urgent--- Time stamp display problem in Multi line chart |
Posted by Peter Kwan on Mar-30-2010 00:10 |
|
Hi Vighenshwar,
Currently, your code do not specify the x-coordinates for the second series, so ChartDirector cannot know how to align the second series with the first series. To solve the problem, you just need to tell ChartDirector what are the x-coordinates for the second series to align with the first series.
In your code, your x-coordinate are not date/time, but are text strings. (Your timeStamps are declared as String[], and passed to ChartDirector using Axis.setLabels.) For text strings, the x-coordinates are assumed to be the index 0, 1, 2, 3, ..... of the text labels. In this case, the code you may use is:
LineLayer layer = c.addLineLayer2();
layer.addDataSet(value2, 0xff00ff,"Forecast Wave Height").setDataSymbol(Chart.CircleSymbol, 4, 0x6633ff);
layer = c.addLineLayer2();
layer.addDataSet(value, 0xff0000,"Real time Wave Height").setDataSymbol(Chart.CircleSymbol, 4, 0xffff00);
//spread the data to (value2.length - 1) / 6 * 6)
layer.setXData(0, (value2.length - 1) / 6 * 6);
Note that your data do not span 2 days. If you have 96 points for 30 minutes, it only spans 1 day 23 hours 30 minutes from the first point to the last point. Similarly, 16 data points 3 hours apart only span 1 day 21 hours. So your two data series do not terminiate at the same point. That's why the code above needs to use "(value2.length - 1) / 6 * 6" instead of simply "value2.length - 1".
Hope this can help.
Regards
Peter Kwan |
|