BarChartOptions
Modified in version 5.0
BarChartOptions ( showConnectingLines ; referenceValue ; makeColorSplit ; optimizeLabelTextColor )
Argument | Type | Range | Default | Note |
---|---|---|---|---|
showConnectingLines | int | 0..1 | off | |
referenceValue | num | -inf..+inf | 0 | |
makeColorSplit | int | 0..1 | off | |
optimizeLabelTextColor | int | 0..1 | off | xmCHART 5.0.5 or higher required |
Examples
BarChartOptions(;;on)
Description
By activating the 1st argument showConnectingLines = on, the (in this case normally stacked) bars are connected by lines. The appearance of the lines can be controlled by the LineStyle() function. Please note that the BarChartOptions() function should be listed after the BarChart() function. This rule generally applies: chart options should always be listed after the actual chart function.
| BAR_CHART_OPTIONS_01 |
1 | OpenDrawing(250;150) |
2 | ChartData( 4 13 12 18 9 10; |
3 | 12 17 14 11 13 12; |
4 | 9 10 11 8 12 3) |
5 | |
6 | |
7 | /* Set up styles. */ |
8 | FillStyle(1;#005ca9) |
9 | FillStyle(2;#00afef) |
10 | FillStyle(3;#cbdb29) |
11 | |
12 | |
13 | /* Set up axes. */ |
14 | |
15 | |
16 | AxisMajorTicks(all;0) |
17 | /* Set up grid. */ |
18 | MajorGridLineWidths(y;x;0) |
19 | MajorGridLineWidths(x;y;0.25) |
20 |
The 2nd argument referenceValue makes it possible to define the base line of the bars. As the default, all bars start at zero, i.e. referenceValue = 0.
| BAR_CHART_OPTIONS_02 |
1 | OpenDrawing(250;150) |
2 | ChartData( 4 13 12 18 9 10; |
3 | 12 17 14 11 13 12; |
4 | 9 10 11 8 12 3) |
5 | |
6 | BarChartOptions(;10) /* Reference value = 10 */ |
7 | /* Set up styles. */ |
8 | FillStyle(1;#005ca9) |
9 | FillStyle(2;#00afef) |
10 | FillStyle(3;#cbdb29) |
11 | |
12 | ShadowStyle(all;2 2 3) |
13 | /* Set up axes. */ |
14 | |
15 | AxisMajorTicks(all;0) |
16 | /* Set up grid. */ |
17 | MajorGridLineWidths(y;x;0) |
18 | MajorGridLineWidths(x;y;0.25) |
19 |
By activating the 3rd argument makeColorSplit = on, the positive and negative values are represented by different colored bars. The appearance of the "positive bars", i.e. the chart values are greater than the reference value, can be controlled by using style functions with odd series indices; the appearance of "negative bars" by using style functions with even series indices. Please note that the color split for the legend is not supported.
| BAR_CHART_OPTIONS_03 |
1 | OpenDrawing(250;150) |
2 | ChartData(108 98 96 101 95 107 102 92) |
3 | BarChart() |
4 | BarChartOptions(;100;on) /* Reference value = 100 */ |
5 | /* Set up styles. */ |
6 | FillStyle(1;#4682b4) /* "Positive bars", odd series index. */ |
7 | |
8 | |
9 | /* Set up axes. */ |
10 | |
11 | AxisMajorTicks(all;0) |
12 | /* Set up grid. */ |
13 | MajorGridLineWidths(y;x;0) |
14 | MajorGridLineWidths(x;y;0.25) |
15 |
| BAR_CHART_OPTIONS_04 |
1 | OpenDrawing(250;150) |
2 | |
3 | ChartData(16.2 15.1 12.4 11.9 9.9 7.5 7.2 4.3 2.3 -1.3 -3.3 -4.5 -6.9) |
4 | |
5 | BarChartOptions(off;0;on) /* Reference value = 0*/ |
6 | /* Set up styles. */ |
7 | FillStyle(1;#4682b4) /* "Positive bars", odd series index. */ |
8 | FillStyle(2;#e80000) /* "Negative bars", even series index. */ |
9 | |
10 | LabelTexts(1;" |f1|") |
11 | LabelTexts(2;"(|!f1|) ") |
12 | LabelStyle(1;Arial;10;plain;#444;;-90) |
13 | LabelStyle(2;Arial;10;plain;#e80000;;-90) |
14 | |
15 | ShadowStyle(all;1 1 3) |
16 | /* Set up axes. */ |
17 | AxisOptions(all;none) /* Hide y-axis. */ |
18 | AxisMajorTicks(all;0) |
19 | GridLocation(all;none) /* Hide grid. */ |
20 | |
21 |
By activating the argument optimizeLabelTextColor = on the label text color is automatically adjusted to ensure good readability. Labels located outside of the bars are not affected by optimizeLabelTextColor.
| BAR_CHART_OPTIONS_05 |
1 | OpenDrawing(500;150) |
2 | |
3 | ChartData(11 13 7 19 6) |
4 | BarChart(label+horizontal;20) |
5 | BarChartOptions(;;;off) /* Don't optimize label text color. */ |
6 | /* Set up styles. */ |
7 | FillStyle(1;#4682b4) |
8 | |
9 | LabelStyle(all;Arial;11;plain;#333) |
10 | /* Set up axes. */ |
11 | ScalingOptions(y;on) /* y-scale top to bottom. */ |
12 | |
13 | AxisMajorTicks(all;0) |
14 | GridLocation(all;none) /* Hide grid. */ |
15 | |
16 | |
17 | ChartData(11 13 7 19 6) |
18 | BarChart(label+horizontal;20) |
19 | BarChartOptions(;;;on) /* Optimize label text color. */ |
20 | /* Set up styles. */ |
21 | FillStyle(1;#4682b4) |
22 | |
23 | LabelStyle(all;Arial;11;plain;#333) |
24 | /* Set up axes. */ |
25 | ScalingOptions(y;on) /* y-scale top to bottom. */ |
26 | |
27 | AxisMajorTicks(all;0) |
28 | GridLocation(all;none) /* Hide grid. */ |
29 | |
30 |
| BAR_CHART_OPTIONS_06 |
1 | OpenDrawing(500;150) |
2 | |
3 | ChartData(0 8 18 0 25 20 0; |
4 | 8 10 7 25 5 10 20) |
5 | |
6 | BarChartOptions(;;;off) /* Don't optimize label text color. */ |
7 | /* Set up styles. */ |
8 | |
9 | FillStyle(1;;transparent) |
10 | |
11 | LabelTexts(1;"") |
12 | LabelStyle(all;Arial;10;plain;#333) |
13 | LabelOptions(2;smartOut) |
14 | ShadowStyle(all;1 1 2;lightGray) |
15 | /* Set up axes. */ |
16 | |
17 | AxisMajorTicks(all;0) |
18 | /* Set up title. */ |
19 | TitleText("Waterfall Chart 1") |
20 | TitleStyle(Verdana;11;plain;#555) |
21 | /* Set up grid. */ |
22 | MajorGridLineWidths(x;y;0.25) |
23 | MajorGridLineWidths(y;x;0) |
24 | |
25 | |
26 | ChartData(0 8 18 0 25 20 0; |
27 | 8 10 7 25 5 10 20) |
28 | |
29 | BarChartOptions(;;;on) /* Optimize label text color. */ |
30 | /* Set up styles. */ |
31 | |
32 | FillStyle(1;;transparent) |
33 | |
34 | LabelTexts(1;"") |
35 | LabelStyle(all;Arial;10;plain;#333) |
36 | LabelOptions(2;smartOut) |
37 | ShadowStyle(all;1 1 2;lightGray) |
38 | /* Set up axes. */ |
39 | |
40 | AxisMajorTicks(all;0) |
41 | /* Set up title. */ |
42 | TitleText("Waterfall Chart 2") |
43 | TitleStyle(Verdana;11;plain;#555) |
44 | /* Set up grid. */ |
45 | MajorGridLineWidths(x;y;0.25) |
46 | MajorGridLineWidths(y;x;0) |
47 | |
48 |
See also functions GanttChartOptions() and PieChartLabelOptions() .