Hi,
Only the line style solid comes out OK when charting a large series, where successive points are just one or a few pixels apart. All other line styles also come out as solid. I suspect this is because TChart uses repetitively the LineTo function to draw the curve which starts each new LineTo segment the same way regardless what was drawn in previous segment. Is there some way around this so that a curve with lots of points comes out looking as say dash dot (or whatever the pen style is)?
Regards,
Michael
Problem charting large data sets with non-solid pen style
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Michael,
Yes, you are right. Below you’ll find the results of some research we did regarding similar issues.
Basic rules:
* TeeChart draws a line between 2 points and then starts again to draw a line between the next 2 points and so forth. Every time a point is met the line starts again as a new vector to the next point.
* The length of repetition of a pattern for a one pixel wide line is (We got this data by print-screening a Chart and using an image editor to count the pixels):
- dotted line: 4 pixels (obtained with line width 2)
- dashed line: 24 pixels
- dash dot: 24 pixels
That means that if your points are closer than 4 pixels (x-displaced) then a dotted line won't have the chance to repeat. In the case of a dotted line there are 3 pixels of white space (empty) between each dot and each dot is 1 pixels wide. Therefore so you could imagine reducing the minimum distance to 2 pixels between 2 points to obtain at least 1 pixel of empty space.
For a flat line Series such as the example, even if the Series were a Point Series with points of 1 pixel width (configurable via the Editor to
test) then the Series would still appear as a constant line as a typical screen is between 1024 and 1280 pixels wide so even if the Chart were the full width of the screen you could not fit more than (on a 1024 screen)
1024/2 = 512 points if you wish to have one pixel of empty space between points.
If the only requirement is to have a horizontal line then no problem, just mark a first and last point and plot it, or use the ColorLine Tool to plot the line. However if the line is irregular then more points need to be plotted and the minimum distance for a 1 pixel wide dotted line would be between 2 and 4 pixels depending on how regular you wish the line to appear. For a dashed line the distance is greater (curiously a width 2 line has a shorter repeat distance than a width 1 line). Repeat distances are easily calculable using an image editor and zooming in on the line.
Re 1. How many numbers of dots are needed to make them look like the dotted line and the dashdotdot line?
Example:
Test Chart is 573 pixels wide between left and right axes.
a) We set line width to 1 and style to dot. Repeat distance for plot is 6 pixels. Therefore max points = 573/6 = 95. (if the line is not flat could increase value). In the case of this example, the 3 points added on each cycle will appear on the same pixel and thus not affect the line.
b) We set line width to 3 and style to DashDot. Repeat distance for plot is 18 pixels. Therefore max points = 573/18 = 31. (if the line is not flat could increase value). In the case of this example, the 3 points added on each cycle will not appear on the same pixel and thus will affect the pattern repetition and make it appear constant. Thus we need to remove points or find a different way to add them.
Alternatively, reduce point rate further or pick a Line Style with higher repeat frequency.
Re.2. When the above number of dots is exceeded, he will try to plot the point. He is thinking of using the CalcXPosValue or CalcYPosValue of the Axis class. Are there any other way >to do so?
It's probably easier to calculate based on maximum points allowed (as in examples above). If the distance between points is not regular then choosing a non-regular style (such as dashdot above) adds further lmitations.
To summarise:
For Line Style to appear correctly point frequency must be low enough for point distance to be greater than Style pattern repetition distance.
Steema does not plan to make any changes to Line plot styles.
Yes, you are right. Below you’ll find the results of some research we did regarding similar issues.
Basic rules:
* TeeChart draws a line between 2 points and then starts again to draw a line between the next 2 points and so forth. Every time a point is met the line starts again as a new vector to the next point.
* The length of repetition of a pattern for a one pixel wide line is (We got this data by print-screening a Chart and using an image editor to count the pixels):
- dotted line: 4 pixels (obtained with line width 2)
- dashed line: 24 pixels
- dash dot: 24 pixels
That means that if your points are closer than 4 pixels (x-displaced) then a dotted line won't have the chance to repeat. In the case of a dotted line there are 3 pixels of white space (empty) between each dot and each dot is 1 pixels wide. Therefore so you could imagine reducing the minimum distance to 2 pixels between 2 points to obtain at least 1 pixel of empty space.
For a flat line Series such as the example, even if the Series were a Point Series with points of 1 pixel width (configurable via the Editor to
test) then the Series would still appear as a constant line as a typical screen is between 1024 and 1280 pixels wide so even if the Chart were the full width of the screen you could not fit more than (on a 1024 screen)
1024/2 = 512 points if you wish to have one pixel of empty space between points.
If the only requirement is to have a horizontal line then no problem, just mark a first and last point and plot it, or use the ColorLine Tool to plot the line. However if the line is irregular then more points need to be plotted and the minimum distance for a 1 pixel wide dotted line would be between 2 and 4 pixels depending on how regular you wish the line to appear. For a dashed line the distance is greater (curiously a width 2 line has a shorter repeat distance than a width 1 line). Repeat distances are easily calculable using an image editor and zooming in on the line.
Re 1. How many numbers of dots are needed to make them look like the dotted line and the dashdotdot line?
Example:
Test Chart is 573 pixels wide between left and right axes.
a) We set line width to 1 and style to dot. Repeat distance for plot is 6 pixels. Therefore max points = 573/6 = 95. (if the line is not flat could increase value). In the case of this example, the 3 points added on each cycle will appear on the same pixel and thus not affect the line.
Code: Select all
m_chart.Series(0).GetAsFastLine().GetLinePen().SetStyle(psDot);
m_chart.Series(0).GetAsFastLine().GetLinePen().SetWidth(1);
double XX;
for (XX = 0.0; XX < 9.5; XX += 0.1) {
m_chart.Series(0).AddXY(0.0 + XX, 1.0, (LPCTSTR)"", clTeeColor);
m_chart.Series(0).AddXY(0.033333 + XX, 1.0, (LPCTSTR)"", clTeeColor);
m_chart.Series(0).AddXY(0.066667 + XX, 1.0, (LPCTSTR)"", clTeeColor); }
Code: Select all
m_chart.Series(0).GetAsFastLine().GetLinePen().SetStyle(psDashDot);
m_chart.Series(0).GetAsFastLine().GetLinePen().SetWidth(3);
double XX;
for (XX = 0.0; XX < 3.1; XX += 0.1) {
m_chart.Series(0).AddXY(0.0 + XX, 1.0, (LPCTSTR)"", clTeeColor); }
Re.2. When the above number of dots is exceeded, he will try to plot the point. He is thinking of using the CalcXPosValue or CalcYPosValue of the Axis class. Are there any other way >to do so?
It's probably easier to calculate based on maximum points allowed (as in examples above). If the distance between points is not regular then choosing a non-regular style (such as dashdot above) adds further lmitations.
To summarise:
For Line Style to appear correctly point frequency must be low enough for point distance to be greater than Style pattern repetition distance.
Steema does not plan to make any changes to Line plot styles.
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |