Strokes
Line and border strokes are defined in xmCHART by a list of numbers. The first value defines the stroke width, followed by an optional dash pattern. A dash pattern is defined by a sequence of successive on (dash) and off (gap) segments of variable lengths.
strokeWidth dashLength1 gapLength1 dashLength2 gapLength2 ...
Stroke Width
The stroke width can be controlled by the first element of the argument stroke. The argument stroke is part of numerous xmCHART functions. For example:
AddLine(10;10;100;100;1) /* 1px wide black line (default). */
AddLine(10;10;100;100) /* Same as line above. */
LineStyle(all;;2.5;red) /* 2.5px wide red lines. */
BorderStyle(all;;0.5) /* 0.5px wide black borders. */
MajorGridLineWidths(x;y;0.25) /* 0.25px wide horizontal grid lines. */
MajorGridLineWidths(y;x;0) /* Hide vertical grid lines. */
Example
| EXAMPLE_01 |
1 | OpenDrawing(220;180) |
2 | AddLine(10; 10;210; 10;0) /* Invisible */ |
3 | AddLine(10; 30;210; 30;0.25) |
4 | AddLine(10; 50;210; 50;0.5) |
5 | AddLine(10; 70;210; 70;1) /* Default width. */ |
6 | AddLine(10; 90;210; 90;1.5) |
7 | AddLine(10;110;210;110;3) |
8 | AddLine(10;131;210;131;6) |
9 | AddLine(10;155;210;155;12) |
10 |
Dash Patterns
As an option, a dash pattern can be assigned to a stroke by adding a list of dash lengths and gaps. These elements are separated by any whitespace characters, including space, tab, and new line. For example:
AddLine(10;10;100;100;1 5 5) /* 1px wide dashed black line. */
LineStyle(all;;1 9 4 2 4) /* 1px wide dot-dashed lines. */
LineStyle(1;poly;0.5 6 2;red) /* 0.5px wide dashed red polygonal curve. */
BorderStyle(all;;2.5 9 4 2 4) /* 2.5px wide dot-dashed borders. */
MajorGridLineWidths(x;y;0.25 2 2) /* 0.25px wide dotted horizontal grid lines. */
Dotted Lines:
To create a dotted line with perfect round dots the line thickness and the dash and gap lengths must be identical. For example:
Example
| EXAMPLE_02 |
1 | OpenDrawing(220;190) |
2 | AddLine(10; 10;210; 10;0.25 2 2) /* strokeWidth:0.25px dashLength:2px gapLength:2px */ |
3 | AddLine(10; 30;210; 30;0.5 15 8) /* strokeWidth:0.5px dashLength:15px gapLength:8px */ |
4 | AddLine(10; 50;210; 50;1 12 3 1 3) |
5 | AddLine(10; 70;210; 70;1 12 3 1 3 1 3) |
6 | AddLine(10; 90;210; 90;1 42 7 1 7 7 7 1 7) |
7 | AddLine(10;110;210;110;2 20 6) |
8 | AddLine(10;131;210;131;8 0.5 5) /* strokeWidth:8px dashLength:0.5px gapLength:5px */ |
9 | AddLine(10;155;210;155;12 12.1 12.1) /* Square dotted — dash and gap lengths are slightly different from stroke width. */ |
10 | AddLine(16;178;204;178;12 12 12) /* Round dotted. */ |
11 |
Line Shapes
A series of points can be connected in different ways, for example, by a polygonal line or a smooth curve. xmCHART supports the following line shapes:
Line Segments
By using constant jump (or value 1) a "line" is represented by a series of disconnected horizontal or vertical line segments. Line shape constant jump is only supported in combination with line charts and can be activated by the function LineStyle(). Optionally, since xmCHART 5.0.4, a so-called shift factor can be added to the jump constant number. The factor in the interval (0,1) shifts the line horizontally (or vertically). The default shift factor is 0.5.
Examples
| EXAMPLE_03 |
1 | OpenDrawing(240;120) |
2 | ChartData(2 6 8 5 3) |
3 | |
4 | SymbolStyle(1;circle;5;2;#fafbfe;solid;steelBlue) |
5 | |
6 | |
7 | AxisMajorTicks(all;8;;;;out) |
8 | GridLocation(all;0) /* Hide grid. */ |
9 |
| EXAMPLE_04 |
1 | OpenDrawing(240;120) |
2 | ChartData(2 6 8 5 3) |
3 | |
4 | SymbolStyle(1;circle;5;2;#fafbfe;solid;steelBlue) |
5 | |
6 | |
7 | AxisMajorTicks(all;8;;;;out) |
8 | GridLocation(all;0) /* Hide grid. */ |
9 |
| EXAMPLE_05 |
1 | OpenDrawing(240;120) |
2 | ChartData(2 6 8 5 3) |
3 | |
4 | SymbolStyle(1;circle;5;2;#fafbfe;solid;steelBlue) |
5 | |
6 | |
7 | AxisMajorTicks(all;8;;;;out) |
8 | GridLocation(all;0) /* Hide grid. */ |
9 |
Stair-step Lines
By using line shape constant step (or value 2) stair-step lines and borders are drawn. Stair-step lines are available for the following functions:
Optionally, since xmCHART 5.0.4, a so-called shift factor can be added to the step constant number. The factor in the interval (0,1) shifts the stepped line horizontally (or vertically). The default shift factor is 0.5.
Examples
| EXAMPLE_06 |
1 | OpenDrawing(240;120) |
2 | ChartData(2 6 8 5 3) |
3 | |
4 | SymbolStyle(1;circle;5;2;#fafbfe;solid;steelBlue) |
5 | |
6 | |
7 | AxisMajorTicks(all;8;;;;out) |
8 | GridLocation(all;0) /* Hide grid. */ |
9 |
| EXAMPLE_07 |
1 | OpenDrawing(240;120) |
2 | ChartData(2 6 8 5 3) |
3 | |
4 | SymbolStyle(1;circle;5;2;#fafbfe;solid;steelBlue) |
5 | |
6 | |
7 | AxisMajorTicks(all;8;;;;out) |
8 | GridLocation(all;0) /* Hide grid. */ |
9 |
| EXAMPLE_08 |
1 | OpenDrawing(240;120) |
2 | ChartData(2 6 8 5 3) |
3 | |
4 | SymbolStyle(1;circle;5;2;#fafbfe;solid;steelBlue) |
5 | |
6 | |
7 | AxisMajorTicks(all;8;;;;out) |
8 | GridLocation(all;0) /* Hide grid. */ |
9 |
Polygonal Lines
The default line shape constant poly (or value 3) is available for the following functions:
Example
| EXAMPLE_09 |
1 | OpenDrawing(240;120) |
2 | ChartData(2 6 8 5 3) |
3 | |
4 | SymbolStyle(1;circle;5;2;#fafbfe;solid;steelBlue) |
5 | |
6 | |
7 | AxisMajorTicks(all;8;;;;out) |
8 | GridLocation(all;0) /* Hide grid. */ |
9 |
Smooth Lines
xmCHART comes with two different line smoothing methods. The smoothing algorithm used for line shape constant smooth (or value 4) produces a more accurate result if the data consists of values of a smooth function. On the other hand, the algorithm used for line shape constant pchip (or value 5) has no overshoots and less oscillation if the data are not smooth ( pchip stands for "Piecewise Cubic Hermite Interpolating Polynomial" ). In math terminology, smooth returns a spline with curvature continuity, i.e. continuous derivatives of first and second order, pchip has tangent continuity, i.e. only the first-order derivative is continuous.
Optionally, a so-called tension factor can be added to the smooth and pchip constant number. The tension factor in the interval (0,2) can be interpreted as the "length" of the tangent. The default tension is 1, a tension of 0 yields to a polygonal shape. For example:
LineStyle(1;4 1) /* Same as LineStyle(1;smooth) */
LineStyle(1;4 0) /* Same as LineStyle(1;poly) */
LineStyle(1;4 0.8)
LineStyle(1;5 1) /* Same as LineStyle(1;pchip) */
LineStyle(1;5 0) /* Same as LineStyle(1;poly) */
LineStyle(1;5 1.2)
The line shape constants smooth and pchip are available for the following functions:
BorderStyle() /* For area charts, polar and radar charts. */
LineStyle() /* For line charts. */
Examples
| EXAMPLE_10 |
1 | OpenDrawing(480;120) |
2 | /* Left graph. */ |
3 | |
4 | ChartData(2 6 8 5 3) |
5 | |
6 | SymbolStyle(1;circle;5;2;#fafbfe;solid;steelBlue) |
7 | |
8 | |
9 | AxisMajorTicks(all;8;;;;out) |
10 | GridLocation(all;0) /* Hide grid. */ |
11 | AddText(130;52.5;"smooth";Verdana;10;plain;steelblue;center;center) |
12 | |
13 | /* Right graph. */ |
14 | |
15 | ChartData(2 6 8 5 3) |
16 | |
17 | SymbolStyle(1;circle;5;2;#fafbfe;solid;steelBlue) |
18 | |
19 | |
20 | AxisMajorTicks(all;8;;;;out) |
21 | GridLocation(all;0) /* Hide grid. */ |
22 | AddText(370;52.5;"pchip";Verdana;10;plain;steelblue;center;center) |
23 | |
24 |
| EXAMPLE_11 |
1 | OpenDrawing(450;210) |
2 | /* Left graph. */ |
3 | OpenView(10;5;210;200) |
4 | |
5 | ChartData(0.0 0.25 0.75 1.0 ; 1.0 1.0 2.0 2.0 ; |
6 | 0.0 0.25 0.75 1.0 ; 1.0 1.0 2.0 2.0 ) |
7 | |
8 | ShadowStyle(1;1 1 1) |
9 | ShadowStyle(2;0) |
10 | LineStyle(1;5 1.5;0.5;magenta) /* pchip (5) with tension factor 1.5 */ |
11 | |
12 | SymbolStyle(1;circle;4;1.4;#fafbfe;solid;magenta) |
13 | SymbolStyle(2;none) |
14 | |
15 | |
16 | |
17 | AxisMajorTicks(all;0) /* Hide tick marks. */ |
18 | AxisMajorTickLabelTexts(x;"|u|") |
19 | AxisMajorTickLabelOptions(x;out;0;3) |
20 | AxisMajorTickLabelOptions(y;out;-3;0) |
21 | MajorGridLineWidths(all;all;0.25) |
22 | LegendTexts("pchip";"smooth") |
23 | LegendStyle(Verdana;10) |
24 | LegendBackground(255 255 255 200;;0) |
25 | LegendOptions(bottomRight;on;0;4) |
26 | |
27 | |
28 | /* Right graph. */ |
29 | OpenView(230;5;210;200) |
30 | |
31 | ChartData( 1.2 2 5.6 4.6 3 2.8 0.6 ; |
32 | 1.2 2 5.6 4.6 3 2.8 0.6 ) |
33 | |
34 | ShadowStyle(1;1 1 1) |
35 | ShadowStyle(2;0) |
36 | |
37 | |
38 | SymbolStyle(1;circle;4;1.4;#fafbfe;solid;magenta) |
39 | SymbolStyle(2;none) |
40 | |
41 | |
42 | AxisMajorTicks(all;0) /* Hide tick marks. */ |
43 | AxisMajorTickLabelOptions(x;out;0;3) |
44 | AxisMajorTickLabelOptions(y;out;-3;0) |
45 | MajorGridLineWidths(all;all;0.25) |
46 | LegendTexts("pchip";"smooth") |
47 | LegendStyle(Verdana;10) |
48 | LegendBackground(255 255 255 200;;0) |
49 | LegendOptions(bottomCenter;on;0;4) |
50 | |
51 | |
52 |