BarChart

BarChart ( appearanceConst ;​ categoryGap ;​ seriesGap ;​ barDepth ;​ barShape )

Argument Type Range Default Note
appearanceConst int 0..127 default
categoryGap num 0..10000 100 In % of bar width
seriesGap num -200..10000 (see desc.) In % of bar width
barDepth num 0..1000 0 In % of bar width
barShape int 1..2 1
Examples
Description

The BarChart() function serves to draw bar charts.

BAR_CHART_01
1

OpenDrawing(250;​150)

2

ChartData( 4 13 9 18 9 8;​ /* Blue series. */

3

12 17 14 11 3 12) /* Green series. */

4

BarChart()

5

/* Set up styles. */

6

FillStyle(1;​#4682b4)

7

FillStyle(2;​#cbdb29)

8

BorderStyle(all;​none)

9

/* Set up axes. */

10

AxisLine(all;​0)

11

AxisMajorTicks(all;​0)

12

/* Set up grid. */

13

MajorGridLineWidths(x;​y;​0.25)

14

MajorGridLineWidths(y;​x;​0)

15

CloseDrawing()

BAR_CHART_01

The 1st argument appearanceConstants makes it possible to rotate the chart 90 degrees (appearanceConstants = horizontal) and to add symbols (appearanceConstants = symbol), shadow (appearanceConstants = shadow) and labels (appearanceConstants = label) to the bars. All options can be combined by using a plus sign "+".

BAR_CHART_02
1

OpenDrawing(250;​150)

2

ChartData(11 13 7 17 6)

3

BarChart(label+shadow+horizontal)

4

/* Set up styles. */

5

FillStyle(1;​#4682b4)

6

BorderStyle(all;​none)

7

ShadowStyle(all;​2 2 5)

8

/* Set up axes. */

9

ScalingOptions(y;​on) /* y-scale top to bottom. */

10

AxisLine(all;​0)

11

AxisMajorTicks(all;​0)

12

/* Set up grid. */

13

MajorGridLineWidths(y;​x;​0.25)

14

MajorGridLineWidths(x;​y;​0)

15

CloseDrawing()

BAR_CHART_02

The fills, borders, symbols and shadows can be varied by using the style functions FillColorScheme() , FillStyle() , PictureStyle() , BorderColorScheme() , BorderStyle() , SymbolColorScheme() , SymbolStyle() and ShadowStyle() and the labels by using the five style functions LabelTexts() , LabelStyle() , LabelBackground() , LabelBackgroundOptions() and LabelOptions() .

BAR_CHART_03
1

OpenDrawing(250;​150)

2

ChartData( 4 13 9 18 9;​

3

12 17 14 11 3 12)

4

BarChart(shadow)

5

/* Set up styles. */

6

FillColorScheme(blue)

7

BorderStyle(all;​none)

8

ShadowStyle(all;​2 2 5)

9

/* Set up axes. */

10

AxisLine(all;​0)

11

AxisMajorTicks(all;​0)

12

/* Set up grid. */

13

MajorGridLineWidths(x;​y;​0.25)

14

MajorGridLineWidths(y;​x;​0)

15

CloseDrawing()

BAR_CHART_03
BAR_CHART_04
1

OpenDrawing(250;​150)

2

ChartData(4;​ 12;​ 19;​ 14;​ 6)

3

BarChart(shadow+label)

4

/* Set up styles. */

5

FillStyle(1;​#005ca9;​shaded)

6

FillStyle(2;​#a2e4f9;​shaded)

7

FillStyle(3;​#cbdb29;​shaded)

8

FillStyle(4;​#00afef;​shaded)

9

FillStyle(5;​#9cccf0;​shaded)

10

BorderStyle(all;​none)

11

ShadowStyle(all;​2 2 5)

12

/* Set up axes. */

13

AxisLine(all;​0)

14

AxisMajorTicks(all;​0)

15

/* Set up grid. */

16

MajorGridLineWidths(x;​y;​0.25)

17

MajorGridLineWidths(y;​x;​0)

18

CloseDrawing()

BAR_CHART_04

Furthermore, bar charts can be stacked (appearanceConstants = stacked) and drawn proportionally (appearanceConstants = proportional). Proportional charts are automatically stacked.

BAR_CHART_05
1

OpenDrawing(250;​150)

2

ChartData(4 13 9 13 9;​ /* 1st series. */

3

7 10 10 14 4 13) /* 2nd series. */

4

BarChart(shadow+stacked+label)

5

/* Set up styles. */

6

FillStyle(1;​#00afef)

7

FillStyle(2;​#cbdb29)

8

BorderStyle(all;​none)

9

ShadowStyle(all;​2 2 3)

10

/* Set up axes. */

11

AxisLine(all;​0)

12

AxisMajorTicks(all;​0)

13

/* Set up grid. */

14

MajorGridLineWidths(x;​y;​0.25)

15

MajorGridLineWidths(y;​x;​0)

16

CloseDrawing()

BAR_CHART_05
BAR_CHART_06
1

OpenDrawing(250;​150)

2

ChartData(34 0 0 0 0;​

3

0 3 0 0 0;​

4

0 10 0 0 0;​

5

0 15 0 0 0;​

6

0 0 24 0 0;​

7

0 0 0 5 0;​

8

0 0 0 0 2;​

9

0 0 0 0 4)

10

BarChart(stacked;​50)

11

/* Set up styles. */

12

FillStyle(1;​#5e9ed4)

13

FillStyle(2;​#fdc12d)

14

FillStyle(3;​#ec7f3e)

15

FillStyle(4;​#a5a5a5)

16

FillStyle(5;​#4676c3)

17

FillStyle(6;​#72ab4d)

18

FillStyle(7;​#9d4718)

19

FillStyle(8;​#e7401f)

20

BorderStyle(all;​none)

21

/* Set up axes. */

22

AxisLine(all;​0)

23

AxisMajorTicks(all;​0)

24

AxisMajorTickLabelTexts(x;​"A";​"B";​"C";​"D";​"E")

25

/* Set up grid. */

26

MajorGridLineWidths(x;​y;​0.25)

27

MajorGridLineWidths(y;​x;​0)

28

CloseDrawing()

BAR_CHART_06
BAR_CHART_07
1

OpenDrawing(250;​150)

2

ChartData(4 13 9 13 9;​ /* 1st series. */

3

7 10 10 11 3;​ /* 2nd series. */

4

2 9 12 5 4) /* 3rd series. */

5

BarChart(horizontal+proportional)

6

/* Set up styles. */

7

FillStyle(1;​#005ca9)

8

FillStyle(2;​#00afef)

9

FillStyle(3;​#cbdb29)

10

BorderStyle(all;​none)

11

/* Set up axes. */

12

Scaling(x;​percent)

13

ScalingOptions(y;​on) /* y-scale top to bottom. */

14

AxisLine(all;​0)

15

AxisMajorTicks(all;​0)

16

/* Set up grid. */

17

MajorGridLineWidths(y;​x;​0.25)

18

MajorGridLineWidths(x;​y;​0)

19

CloseDrawing()

BAR_CHART_07

In addition, it is also possible to create floating bar charts by making the first data series invisible.

BAR_CHART_08
1

OpenDrawing(250;​150)

2

ChartData( 4 13 9 18 9 10;​

3

12 17 14 11 6 12;​

4

9 10 11 8 12 4)

5

BarChart(stacked)

6

/* Set up styles. */

7

FillStyle(1;​none)

8

FillStyle(2;​#005ca9)

9

FillStyle(3;​#cbdb29)

10

BorderStyle(all;​none)

11

BarStyle(2;​1 50)

12

BarStyle(3;​0;​1 50)

13

/* Set up axes. */

14

AxisLine(all;​0)

15

AxisMajorTicks(all;​0)

16

/* Set up grid. */

17

MajorGridLineWidths(x;​y;​0.25)

18

MajorGridLineWidths(y;​x;​0)

19

CloseDrawing()

BAR_CHART_08
BAR_CHART_09
1

OpenDrawing(250;​150)

2

ChartData(0 8 18 0 25 20 0;​

3

8 10 7 25 5 10 20)

4

BarChart(stacked+label+shadow;​30)

5

/* Set up styles. */

6

BorderStyle(all;​none)

7

FillStyle(1;​;​transparent)

8

FillStyle(2;​lightBlue)

9

LabelTexts(1;​"")

10

LabelOptions(2;​smartOut)

11

ShadowStyle(all;​1 1 2;​lightGray)

12

/* Set up axes. */

13

AxisLine(all;​0)

14

AxisMajorTicks(all;​0)

15

/* Set up title. */

16

TitleText("Waterfall Chart")

17

TitleStyle(Verdana;​11;​plain;​#555)

18

/* Set up grid. */

19

MajorGridLineWidths(x;​y;​0.25)

20

MajorGridLineWidths(y;​x;​0)

21

CloseDrawing()

BAR_CHART_09

By using both arguments categoryGap and seriesGap, the space between the bars can be controlled. Both arguments are to be entered in percent of the bar width. As the default, the space between two bar categories is exactly one bar width, i.e. categoryGap =​ 100.

BAR_CHART_10
1

OpenDrawing(250;​150)

2

ChartData( 4 13 9 18 9;​

3

12 17 14 11 3 12;​

4

9 10 11 8 12 3)

5

BarChart(;​100) /* Default category gap. */

6

/* Set up styles. */

7

FillStyle(1;​#005ca9)

8

FillStyle(2;​#00afef)

9

FillStyle(3;​#cbdb29)

10

BorderStyle(all;​none)

11

/* Set up axes. */

12

AxisLine(all;​0)

13

AxisMajorTicks(all;​0)

14

/* Set up grid. */

15

MajorGridLineWidths(x;​y;​0.25)

16

MajorGridLineWidths(y;​x;​0)

17

CloseDrawing()

BAR_CHART_10

The space between the categories is, for example, halved by using categoryGap =​ 50, or completely suppressed by using categoryGap =​ 0.

BAR_CHART_11
1

OpenDrawing(250;​150)

2

ChartData( 4 13 9 18 9;​

3

12 17 14 11 3 12;​

4

9 10 11 8 12 3)

5

BarChart(;​50)

6

/* Set up styles. */

7

FillStyle(1;​#005ca9)

8

FillStyle(2;​#00afef)

9

FillStyle(3;​#cbdb29)

10

BorderStyle(all;​none)

11

/* Set up axes. */

12

AxisLine(all;​0)

13

AxisMajorTicks(all;​0)

14

/* Set up grid. */

15

MajorGridLineWidths(x;​y;​0.25)

16

MajorGridLineWidths(y;​x;​0)

17

CloseDrawing()

BAR_CHART_11
BAR_CHART_12
1

OpenDrawing(250;​150)

2

ChartData( 4 13 9 18 9;​

3

12 17 14 11 3 12;​

4

9 10 11 8 12 3)

5

BarChart(;​0)

6

/* Set up styles. */

7

FillStyle(1;​#005ca9)

8

FillStyle(2;​#00afef)

9

FillStyle(3;​#cbdb29)

10

BorderStyle(all;​none)

11

/* Set up axes. */

12

AxisLine(all;​0)

13

AxisMajorTicks(all;​0)

14

/* Set up grid. */

15

MajorGridLineWidths(x;​y;​0.25)

16

MajorGridLineWidths(y;​x;​0)

17

CloseDrawing()

BAR_CHART_12

For example, by using categoryGap =​ 400, the space between two groups of bars is enlarged by four times the bar width.

BAR_CHART_13
1

OpenDrawing(250;​150)

2

ChartData( 4 13 9 18 9;​

3

12 17 14 11 3 12;​

4

9 10 11 8 12 3)

5

BarChart(;​400)

6

/* Set up styles. */

7

FillStyle(1;​#005ca9)

8

FillStyle(2;​#00afef)

9

FillStyle(3;​#cbdb29)

10

BorderStyle(all;​none)

11

/* Set up axes. */

12

AxisLine(all;​0)

13

AxisMajorTicks(all;​0)

14

/* Set up grid. */

15

MajorGridLineWidths(x;​y;​0.25)

16

MajorGridLineWidths(y;​x;​0)

17

CloseDrawing()

BAR_CHART_13

For non-stacked bars there are no spaces between the series as the default (seriesGap =​ 0). For example, when seriesGap =​ 100 a space is inserted between the individual series. The size of the space corresponds to the bar width when seriesGap =​ 100.

BAR_CHART_14
1

OpenDrawing(250;​150)

2

ChartData( 4 13 9 18 9;​

3

12 17 14 11 3 12;​

4

9 10 11 8 12 3)

5

BarChart(;​;​100)

6

/* Set up styles. */

7

FillStyle(1;​#005ca9)

8

FillStyle(2;​#00afef)

9

FillStyle(3;​#cbdb29)

10

BorderStyle(all;​none)

11

/* Set up axes. */

12

AxisLine(all;​0)

13

AxisMajorTicks(all;​0)

14

/* Set up grid. */

15

MajorGridLineWidths(x;​y;​0.25)

16

MajorGridLineWidths(y;​x;​0)

17

CloseDrawing()

BAR_CHART_14

For non-stacked bars a negative seriesGap produces partial or complete overlapping of bars.

BAR_CHART_15
1

OpenDrawing(250;​150)

2

ChartData( 4 13 9 18 9;​

3

12 17 14 11 3 12;​

4

9 10 11 8 12 3)

5

BarChart(;​;​-50)

6

/* Set up styles. */

7

FillStyle(1;​#005ca9a0)

8

FillStyle(2;​#00afefa0)

9

FillStyle(3;​#cbdb29)

10

BorderStyle(all;​none)

11

/* Set up axes. */

12

AxisLine(all;​0)

13

AxisMajorTicks(all;​0)

14

/* Set up grid. */

15

MajorGridLineWidths(x;​y;​0.25)

16

MajorGridLineWidths(y;​x;​0)

17

CloseDrawing()

BAR_CHART_15

Since stacked bars are not arranged next to each other but rather on top of each other, the default seriesGap is -100. When the seriesGap is not equal to -100, for example, when seriesGap =​ 0, the stacked bars are offset.

BAR_CHART_16
1

OpenDrawing(250;​150)

2

ChartData( 4 13 9 18 9;​

3

12 17 14 11 3 12;​

4

9 10 11 8 12 3)

5

BarChart(stacked;​;​0)

6

/* Set up styles. */

7

FillStyle(1;​#005ca9)

8

FillStyle(2;​#00afef)

9

FillStyle(3;​#cbdb29)

10

BorderStyle(all;​none)

11

/* Set up axes. */

12

AxisLine(all;​0)

13

AxisMajorTicks(all;​0)

14

/* Set up grid. */

15

MajorGridLineWidths(x;​y;​0.25)

16

MajorGridLineWidths(y;​x;​0)

17

CloseDrawing()

BAR_CHART_16

The 4th argument barDepth can be used to control the three-dimensional drawing of bars. The bar depth is to be entered in percentage of the bar width.

BAR_CHART_17
1

OpenDrawing(250;​150)

2

ChartData( 4 13 9 18 9;​

3

12 17 14 11 3 12)

4

BarChart(shadow;​;​;​40)

5

/* Set up styles. */

6

FillStyle(1;​#005ca9)

7

FillStyle(2;​#00afef)

8

BorderStyle(all;​none)

9

ShadowStyle(all;​2 2 3)

10

/* Set up axes. */

11

AxisLine(all;​0)

12

AxisMajorTicks(all;​0)

13

/* Set up grid. */

14

MajorGridLineWidths(all;​all;​0)

15

MajorGridLineWidths(x;​y;​0.25)

16

MajorGridLineWidths(x;​z;​0.25)

17

CloseDrawing()

BAR_CHART_17
BAR_CHART_18
1

OpenDrawing(250;​150)

2

ChartData( 4 13 9 18 9 10;​

3

12 17 14 11 3 12;​

4

9 10 11 8 12 3)

5

BarChart(stacked+shadow;​;​;​30)

6

/* Set up styles. */

7

FillStyle(1;​none)

8

FillStyle(2;​#005ca9)

9

FillStyle(3;​#cbdb29)

10

BorderStyle(all;​none)

11

ShadowStyle(all;​2 2 3)

12

/* Set up axes. */

13

AxisLine(all;​0)

14

AxisMajorTicks(all;​0)

15

/* Set up grid. */

16

MajorGridLineWidths(all;​all;​0)

17

MajorGridLineWidths(x;​y;​0.25)

18

CloseDrawing()

BAR_CHART_18
BAR_CHART_19
1

OpenDrawing(250;​150)

2

ChartData( 4 13 9 18 9;​

3

12 17 14 11 3 12;​

4

9 10 11 8 12 3)

5

BarChart(shadow;​0;​;​30)

6

/* Set up styles. */

7

FillStyle(1;​#005ca9)

8

FillStyle(2;​#00afef)

9

FillStyle(3;​#cbdb29)

10

BorderStyle(all;​none)

11

ShadowStyle(all;​2 2 3)

12

/* Set up axes. */

13

AxisLine(all;​0)

14

AxisMajorTicks(all;​0)

15

/* Set up grid. */

16

MajorGridLineWidths(all;​all;​0)

17

MajorGridLineWidths(x;​y;​0.25)

18

MajorGridLineWidths(x;​z;​0.25)

19

CloseDrawing()

BAR_CHART_19

By using the 5th argument barShape, it is possible to choose between the default bar shape (barShape =​ 1) and a cylindrical bar shape (barShape =​ 2).

BAR_CHART_20
1

OpenDrawing(250;​150)

2

ChartData(28 20 12 7 3)

3

BarChart(;​;​;​50;​2)

4

/* Set up styles. */

5

FillStyle(1;​1 0 1 0.0 49 56 12 255 0.35 176 198 52 255 1.0 49 56 12 255)

6

BorderStyle(all;​none)

7

/* Set up axes. */

8

AxisLine(all;​0)

9

AxisMajorTicks(all;​0)

10

/* Set up grid. */

11

MajorGridLineWidths(all;​all;​0)

12

MajorGridLineWidths(x;​y;​0.25)

13

MajorGridLineWidths(x;​z;​0.25)

14

CloseDrawing()

BAR_CHART_20
Scroll to Top