Line chart - drawing an average line between 2 points

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
world2160
Posts: 7
Joined: Mon Aug 07, 2006 1:03 pm

Line chart - drawing an average line between 2 points

Post by world2160 » Tue Aug 08, 2006 12:03 am

When I am drawing a Line Chart, and I have eg. years 1 to years 10 in the x-Axis. Now say I have years3 and years4 with null value. But I dont want to have an empty gap, I can draw an average line from year2 to year5. Right now, I can use some mathematics and calculate years3 and years4 but this one there will be points on the lineChart which may give people a false impression that years3 and years4 has some value but its just an average line between years2 and years5. How can I go about drawng an average line without having the points displayed?

SeanMcCrohan
Posts: 18
Joined: Thu May 11, 2006 11:22 pm

Post by SeanMcCrohan » Tue Aug 08, 2006 5:32 pm

If you supply NO data for those years, this will happen automatically.

That is to say: If you have a series that contains year 1, year 2, year 5, year 6 and year 7...those points will be connected in sequence, with the interval between 2 and 5 appropriately wide. Change the type of the chart to LINE_AND_SHAPES so that the actual datapoints are visible to the user, and they'll be able to see where the real data was.

If you add years 3 and 4 to the dataset as zeros or nulls, you probably won't get this result. So check you values as you're adding them to the series, and skip any that are invalid.

world2160
Posts: 7
Joined: Mon Aug 07, 2006 1:03 pm

Post by world2160 » Wed Aug 09, 2006 12:27 am

Thank you for your advice. However it does not seem so easy. The axis values are not simply 1,2,3,4..... They are more customized eg. one, two, three..... and I dont think JFreeChart will know the exact ordering of that. So if I didnt put a value for three, then the values on the axis will simply become one, two, four, five......

Locked