Scripts

Functions

The basic idea behind xmCHART is to make an extensive set of functions available to users with which the general appearance of a chart can be controlled in detail. Three functions are all you need to draw up a number of different charts: first the function OpenDrawing() defines the size of the chart, secondly the ChartData() function which contains all numerical values (or date/time values) used for representation and, thirdly, a function which determines the type of chart.

Example
EXAMPLE_01
1

OpenDrawing(250;​120)

2

ChartData(1 2 3 4 ;​ 9 8 7)

3

BarChart()

4

CloseDrawing()

EXAMPLE_01

Besides a comprehensive set of charting functions, xmCHART also offers numerous functions for creating geometric shapes or for adding texts, images, barcodes, etc.

Examples
EXAMPLE_02
1

OpenDrawing(200;​100)

2

AddRect(10;​10;​180;​80;​darkYellow;​solid;​8;​steelBlue;​shaded)

3

AddLine(25;​55;​175;​55;​0.25;​black)

4

AddText(30;​55;​"Abcd 和制汉字";​Arial;​21;​bold;​darkGray)

5

CloseDrawing()

EXAMPLE_02
EXAMPLE_03
1

OpenDrawing(110;​110;​print)

2

BarcodeQR(5;​5;​100;​100;​"https://www.xmchart.com")

3

CloseDrawing()

EXAMPLE_03

In fact, over 170 functions are available with which nearly all parts of the chart can be varied.

xmCHART’s built-in functions are not to be confused with the External Functions. xmCHART functions do not show up in FileMaker’s Specify Calculation dialog box as external functions.

If a chart is to be created, all function calls — arranged as a large string of text — are transferred to xmCHART by using the external function xmCH_DrawChart(). xmCHART then checks this text string for possible typing errors, missing brackets, invalid values, etc. In the event of an error, the process is aborted and an error message is sent to FileMaker Pro by xmCHART. To enable the user to quickly and easily correct this error, xmCHART sends a detailed error message, if possible, with the line number, the function name and argument index. If no errors are found, xmCHART begins to set up the chart and stores it in a FileMaker container field.

 

xmCHART function names and predefined constants are not case sensitive. If a function has several arguments, they are separated by semicolons (;). For example:

OPENDRAWING(800;​600;​PRINT)

OpenDrawing(800;​600;​screen)

Optional arguments can be skipped in a function call. The default values stored in xmCHART are used in this case. See Functions for these values. For example:

AddSymbol(100;​150;​bullet;​10;​;​steelBlue)

LegendBackground(white;​;​2;​;​;​3)

LegendBackground()

Literal text arguments such as label texts or filenames must be enclosed in quotation marks. For example:

LabelTexts(all;​"|f1|")

AddText(20;​30;​"Company Universal Exports")

SaveAsPNGFile("~/desktop/img_01.png")

Quotation marks entered inside FileMaker’s Specify Calculation dialog box should be prefixed with a backslash (\"). For more details, please see Texts.

Enclosing font names in quotation marks is optional and can be omitted. For example:

AxisMajorTickLabelStyle(y;​"Verdana";​10;​bold;​darkBlue)

AxisMajorTickLabelStyle(y;​Verdana;​10;​bold;​darkBlue)

If a function is called several times, the last one will be used; all previous ones will be ignored.

Exception: The functions PieChartExplodes(),PieChartExplodeDepths() and graphics primitive functions, e.g. AddText(),AddSymbol(),AddPicture() etc. — they can be called multiple times. For example:

 

OpenDrawing(800;​600)

ChartData(12 45 23 -10 34) /* Is ignored. */

ChartData(78 -23 56 22 11)

PieChart(shadow+label) /* Is ignored. */

BarChart(label)

FillStyle(1;​red) /* Is ignored. */

FillStyle(1;​blue)

FillStyle(2;​yellow)

AddText(20;​20;​"Diagram 1")

AddText(20;​35;​"(Variant A)")

AddText(200;​280;​"Copyright")

CloseDrawing()

Recommended Order of Function Calls

 

OpenDrawing()

 

"Global" functions, e.g. SetDecimalPoint(), SetThousandsSep()

 

DateTimeOptions() /* Before ChartData() */

ChartDataOptions() /* Before ChartData() */

ChartData()

 

Chart function, e.g. BarChart() /* After ChartaData() */

Chart function options, e.g. BarChartOptions() /* After chart function. */

 

Color scheme functions, e.g. FillColorScheme() /* After chart function(s). */

Style functions, e.g. FillStyle() /* After color scheme functions. */

 

Axis and scaling functions.

Grid, title, legend functions.

 

CloseDrawing()

Structure

Basic Structure: OpenDrawing() . . . CloseDrawing()

 

OpenDrawing(width;height[;resolution])

...

sequence of xmCHART functions

...

CloseDrawing()

Example
EXAMPLE_04
1

OpenDrawing(200;​100)

2

ChartData(2 9 12 6 3)

3

LineChart(;​on)

4

LineStyle(all;​smooth;​1.5;​steelBlue)

5

Scaling(y;​linear;​0;​15;​3)

6

AxisOptions(x;​none) /* Hide x-axis. */

7

AxisLine(y;​0) /* Hide y-axis lines. */

8

AxisMajorTicks(y;​0) /* Hide y-axis tick marks. */

9

MajorGridLineWidths(y;​x;​0) /* Hide vertical grid lines. */

10

MajorGridLineWidths(x;​y;​0.25)

11

CloseDrawing()

EXAMPLE_04

OpenChart() . . . CloseChart() Structure

 

OpenDrawing(width;height[;resolution])

...

OpenChart(left;top;width;height[;isPlotArea])

...

sequence of xmCHART functions

...

CloseChart()

...

CloseDrawing()

 

OpenChart() . . . CloseChart() can be used to precisely place one or more charts on the drawing.

Examples
EXAMPLE_05
1

OpenDrawing(200;​100)

2

OpenChart(10;​10;​80;​80;​on)

3

ChartData(10 5 4 3 1)

4

PieChart()

5

PieChartExplodes(10;​max) /* After PieChart() function. */

6

FillColorScheme(beige;​shaded)

7

BorderStyle(all;​none)

8

CloseChart()

9

Background(none;​;​0.25;​gray)

10

CloseDrawing()

EXAMPLE_05
EXAMPLE_06
1

OpenDrawing(400;​100)

2

OpenChart(10;​10;​180;​80)

3

ChartData(2 9 12 6 3)

4

BarChart()

5

FillStyle(1;​orange;​shaded)

6

BorderStyle(1;​none)

7

Scaling(y;​linear;​0;​15;​3)

8

AxisLine(all;​0) /* Hide axis lines. */

9

AxisMajorTicks(all;​0) /* Hide tick marks. */

10

MajorGridLineWidths(y;​x;​0) /* Hide vertical grid lines. */

11

MajorGridLineWidths(x;​y;​0.25)

12

CloseChart()

13

OpenChart(210;​10;​180;​80)

14

ChartData(2 9 12 6 3)

15

LineChart(;​on)

16

LineStyle(all;​smooth;​1.5;​steelBlue)

17

Scaling(y;​linear;​0;​15;​3)

18

AxisOptions(x;​none) /* Hide x-axis. */

19

AxisLine(y;​0) /* Hide y-axis lines. */

20

AxisMajorTicks(y;​0) /* Hide y-axis tick marks. */

21

MajorGridLineWidths(y;​x;​0) /* Hide vertical grid lines. */

22

MajorGridLineWidths(x;​y;​0.25)

23

CloseChart()

24

Background(none;​;​0.25;​gray)

25

CloseDrawing()

EXAMPLE_06

The argument isPlotArea = on can be used to precisely align or overlay two or more charts.

Examples
EXAMPLE_07
1

OpenDrawing(400;​100)

2

OpenChart(30;​25;​150;​50;​on)

3

ChartData(2 9 12 6 3)

4

BarChart()

5

FillStyle(1;​orange;​shaded)

6

BorderStyle(1;​none)

7

Scaling(y;​linear;​0;​15;​3)

8

AxisLine(all;​0) /* Hide axis lines. */

9

AxisMajorTicks(all;​0) /* Hide tick marks. */

10

MajorGridLineWidths(y;​x;​0) /* Hide vertical grid lines. */

11

MajorGridLineWidths(x;​y;​0.25)

12

CloseChart()

13

OpenChart(230;​25;​150;​50;​on)

14

ChartData(2 9 12 6 3)

15

LineChart(;​on)

16

LineStyle(all;​smooth;​1.5;​steelBlue)

17

Scaling(y;​linear;​0;​15;​3)

18

AxisOptions(x;​none) /* Hide x-axis. */

19

AxisLine(y;​0) /* Hide y-axis lines. */

20

AxisMajorTicks(y;​0) /* Hide y-axis tick marks. */

21

MajorGridLineWidths(y;​x;​0) /* Hide vertical grid lines. */

22

MajorGridLineWidths(x;​y;​0.25)

23

CloseChart()

24

Background(none;​;​0.25;​gray)

25

CloseDrawing()

EXAMPLE_07
EXAMPLE_08
1

OpenDrawing(220;​120)

2

OpenChart(25;​20;​180;​80;​on)

3

ChartData(2 9 12 6 3)

4

BarChart()

5

FillStyle(1;​orange;​shaded)

6

BorderStyle(1;​none)

7

Scaling(y;​linear;​0;​15;​3)

8

AxisLine(all;​0) /* Hide axis lines. */

9

AxisMajorTicks(all;​0) /* Hide tick marks. */

10

MajorGridLineWidths(y;​x;​0) /* Hide vertical grid lines. */

11

MajorGridLineWidths(x;​y;​0.25)

12

CloseChart()

13

OpenChart(25;​20;​180;​80;​on)

14

ChartData(2 9 12 6 3)

15

LineChart(;​on)

16

LineStyle(all;​smooth;​1.5;​steelBlue)

17

Scaling(y;​linear;​0;​15;​3)

18

AxisOptions(all;​none) /* Hide axes. */

19

GridLocation(all;​none) /* Hide grid. */

20

CloseChart()

21

CloseDrawing()

EXAMPLE_08

OpenView() . . . CloseView() Structure

 

OpenDrawing(width;height[;resolution])

...

OpenView(left;top;width;height)

...

sequence of xmCHART functions

...

CloseView()

...

CloseDrawing()

 

Views make it possible to divide a drawing into rectangular regions. For example, a series of graphics primitives, such as lines, areas or texts, can be combined within a view; by simply changing the position of the view all graphic components within a view are automatically moved with it. Otherwise the coordinates of each single graphics primitive would have to changed. That means all coordinates within a view always refer to the upper left-hand corner of the view. Charts and graphics primitives, which are located partially or completely outside of a view, are clipped.

Example
EXAMPLE_09
1

OpenDrawing(200;​120)

2

OpenView(70;​40;​120;​70)

3

ChartData(4 3 4 5 3)

4

AreaChart()

5

AreaChartOptions(on) /* After AreaChart() function. */

6

FillStyle(1;​#ffa50022)

7

BorderStyle(1;​smooth;​0)

8

LineStyle(1;​smooth;​1.5;​orange)

9

Scaling(y;​linear;​0;​6;​3)

10

AxisOptions(x;​none) /* Hide x-axis. */

11

AxisLine(y;​0) /* Hide y-axis lines. */

12

AxisMajorTicks(y;​0) /* Hide y-axis tick marks. */

13

MajorGridLineWidths(y;​x;​0) /* Hide vertical grid lines. */

14

MajorGridLineWidths(x;​y;​0.25)

15

Background(none;​;​0.25;​gray)

16

CloseView()

17

Background(none;​;​0.25;​gray)

18

CloseDrawing()

EXAMPLE_09

Nested views, i.e. views within a view, are also possible.

Example
EXAMPLE_10
1

OpenDrawing(200;​120)

2

OpenView(20;​20;​160;​80)

3

AddText(3;​10;​"View 1";​Verdana;​9)

4

OpenView(20;​20;​50;​40)

5

AddText(3;​10;​"View 1.1";​Verdana;​9)

6

Background(#be330022;​solid;​1;​#be3300)

7

CloseView()

8

OpenView(90;​20;​50;​40)

9

AddText(3;​10;​"View 1.2";​Verdana;​9)

10

Background(#4682b422;​solid;​1;​#4682b4)

11

CloseView()

12

Background(#ffcc0022;​solid;​1;​#ffcc00)

13

CloseView()

14

Background(none;​;​0.25;​gray)

15

CloseDrawing()

EXAMPLE_10

Comments

xmCHART supports two comment styles: single-line and multi-line.

A double slash (//) anywhere on a line (except within a string) turns the rest of the line into a comment. Multi-line comments begin with a slash-asterisk (/*) and end with an asterisk-slash (*/), and can span multiple lines. For example, obsolete or unfinished pieces of code can be disabled by turning them into comments. Or while testing or debugging a script, multi-line comment delimiters can be used to comment-out whole sections of code. Single-line comments inside multi-line comments are also permitted. Nested multi-line comments are supported starting with xmCHART 4.

Example
 

// -----------------------------------------------

// Area chart 2D

// -----------------------------------------------

OpenDrawing(600;​400)

OpenChart(100;​50;​400;​300;​on) /* Plot area. */

ChartData(1 2 3 4 5;​ // x-values of series 1

9 5 8 8 4;​ // y-values of series 1

1 2 3 4 5 6;​ // x-values of series 2

15 9 7 0 0 1) // y-values of series 2

AreaChart2D()

//FillColorScheme(11)

BorderStyle(all;​none) /* Hide borders. */

LabelStyle(all;​;​9;​plain;​60 60 60)

/* Disabled code lines:

LabelOptions(all;​out)

Scaling(x;​linear;​0;​7;​7)

AxisOptions(all;​none) /* Hide axes. */

MajorGridLineWidths(all;​all;​0) // Hide grid lines.

*/

CloseChart()

CloseDrawing()

 
In FileMaker’s Specify Calculation dialog box "//" comments are not automatically limited by the end of the line, making the single-line comments extend to the end of the script! Instead, use multi-line comments /* ... */ or add a paragraph sign "¶" at the end of "//" comments. Example:
Wrong Comment Syntax Correct Comment Syntax
Scroll to Top
Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×