Using xmCHART
Table of Contents:
- Introduction
- Chart Structure
- Chart Data
- Data Order
- Chart Types
- AreaChart, AreaChart2D
- BarChart, BarChart2D
- BoxPlot
- BubbleChart, BubbleChart2D
- CandlestickChart, CandlestickChart2D
- CircularBarChart
- ContourMap
- DensityPlot
- GanttChart
- HeatMap
- HighLowChart, HighLowChart2D
- Histogram
- LinearGauge
- LineChart, LineChart2D
- PieChart
- PolarChart, RadarChart
- RadialGauge
- ScatterChart, ScatterChart2D
- TreeMap
- VectorPlot, VectorPlot2D
- VennDiagram
- ViolinPlot
- Chart Appearance
- Colors and Patterns
- Filled Areas
- Lines
- Symbols
- Shadows
- Axes
- Grid
- Background
- Title
- Legend
- Value Labels
- Pie Charts
- Additional Lines
- Formatting Numbers, Dates, Times, and Text
- Other Graphical Objects
- Output
Introduction
xmCHART is a FileMaker plug-in that uses input text (containing data and options you specify) to generate an output graphic, most commonly a chart. Usually this is done with the Draw Chart[] script step, which works like Set Field (set a field equal to some result — in this case, set a container field equal to the graphic produced when xmCHART processes your input text).
xmCHART also comes with the function xmCH_DrawChart for generating graphics through the calculation engine (such as in a calculated container field).
Chart Structure
The input text you pass to xmCHART uses functions (not to be confused with FileMaker functions) which describe the graphic you're asking for. A typical chart has the following structure:
- OpenDrawing() (to specify the image size)
- ChartData (to populate the chart)
- a function for a particular chart type
- assorted appearance functions
- CloseDrawing() (optional)
For more complex drawings, use OpenChart() to position a chart precisely within the drawing, or to place multiple charts in the same drawing (including overlaying charts over each other), see examples here. Use OpenView() or OpenGroup() to establish drawing groups if desired, see examples here.
xmCHART supports single-line //
and multi-line /* */
comments.
Chart Data
- A chart requires data, usually consisting of multiple values, often arranged in multiple series/sections.
- Use ChartData() to include data in your xmCHART code (use whitespace such as spaces or returns to separate values, and semicolons to separate series/sections), or use ChartDataRead() to read data directly from a text file (use tabs and returns, or specify custom separators).
- Don't use commas as thousands separators in input numbers.
- Dates can be read as M/D/Y, D/M/Y, or Y/M/D depending on DateTimeOptions(). Dashes or slashes may be used in dates. Timestamps must use
&
to join dates and times. - Use
NULL
to indicate a missing value (beware the potential for FileMaker's List() function to condense gaps). - A null value can be forced if data falls outside an expected range using ChartDataLowerLimits() and/or ChartDataUpperLimits().
- Use a legend to assign names to data series.
Data Order
Use ChartDataOptions() to change how data is read (see examples below). XXYY is default.
If you have a single 1-dimensional series with one data point (such as a radial gauge):
- Use XXYY, XYXY, or XYXY2 if your data looks like:
value
If you have a single 1-dimensional series with multiple data points (such as a single-color bar chart):
- Use XXYY or XYXY2 if your data looks like:
value value /* Values space-separated. */
- Use XYXY if your data looks like:
value ; value /* Values semicolon-separated. */
If you have a single 2-dimensional series with one data point (such as a single-point 2D scatter chart):
- Use XXYY or XYXY2 if your data looks like:
x ; y /* Values semicolon-separated. */
- Use XYXY if your data looks like:
x y /* Values space-separated. */
If you have a single 2-dimensional series with multiple data points (such as a single-color 2D line chart):
- Use XXYY or XYXY2 if your data looks like:
x x ; /* All X values. */
y y ; /* All Y values. */ - Use XYXY if your data looks like:
x y ; /* First data point. */
x y ; /* Second data point. */
If you have multiple 1-dimensional series with one data point each (such as a pie chart):
- Use XXYY or XYXY2 if your data looks like:
value ; value /* Series semicolon-separated. */
- Use XYXY if your data looks like:
value value /* Series space-separated. */
If you have multiple 1-dimensional series with multiple data points each (such as a multi-colored bar chart with multiple categories):
- Use XXYY or XYXY2 if your data looks like:
value value ; /* All values for series 1. */
value value ; /* All values for series 2. */ - Use XYXY if your data looks like:
value value ; /* First values for all series. */
value value ; /* Second values for all series. */
If you have multiple 2-dimensional series with one data point each (such as a 2D scatter chart with assorted point colors):
- Use XXYY if your data looks like:
x ; y ; /* Coordinates for series 1 (semicolon-separated). */
x ; y ; /* Coordinates for series 2 (semicolon-separated). */ - Use XYXY if your data looks like:
x y x y /* Coordinates for all series (space-separated). */
- Use XYXY2 if your data looks like:
x y ; /* Coordinates for series 1 (space-separated). */
x y ; /* Coordinates for series 2 (space-separated). */
If you have multiple 2-dimensional series with multiple data points each (such as a 2D line chart with multiple lines):
- Use XXYY if your data looks like:
x x ; /* All X values for series 1. */
y y ; /* All Y values for series 1. */
x x ; /* All X values for series 2. */
y y ; /* All Y values for series 2. */ - Use XYXY if your data looks like:
x y x y ; /* First data point for all series. */
x y x y ; /* Second data point for all series. */ - Use XYXY2 if your data looks like:
x y x y ; /* All data points for series 1. */
x y x y ; /* All data points for series 2. */
Chart Types
Several chart options vary by chart type. Notably, chart types may differ in the number of values used to describe a single data point, the number of data points allowed in a series, and the total number of series allowed (see below).
Chart type | Values per data point | Points per series |
Max series |
Appearance constants |
Other options |
---|---|---|---|---|---|
AreaChart()
(like a 1D line chart but drawn with a filled area) |
|
∞ | 10000 | shadow, label, symbol, horizontal, stacked, proportional | AreaChartOptions(), filled areas |
AreaChart2D()
(like a 2D line chart but drawn with a filled area) |
|
∞ | 10000 | shadow, label, symbol | AreaChartOptions(), filled areas |
BarChart()
(standard bar chart) |
|
∞ | 10000 | shadow, label, symbol, horizontal, stacked, proportional | BarChartOptions(), BarStyle(), filled areas |
BarChart2D()
(each bar has an X coordinate) |
|
∞ | 10000 | shadow, label, symbol, horizontal, stacked, proportional | BarChartOptions(), BarStyle(), filled areas |
BoxPlot()
(box with some dots inside and some outside) |
|
∞ | 10000 | shadow, symbol, horizontal | BoxPlotOptions(), filled areas |
BubbleChart()
(like a 1D scatter chart, but with varying point sizes) |
|
∞ | 10000 | shadow, label, symbol, horizontal | BubbleChartOptions(), filled areas |
BubbleChart2D()
(like a 2D scatter chart, but with varying point sizes) |
|
∞ | 10000 | shadow, label, symbol | BubbleChartOptions(), filled areas |
CandlestickChart()
(stock prices as boxes with high/low lines) |
|
∞ | 10000 | shadow, horizontal | CandlestickChartOptions(), filled areas |
CandlestickChart2D()
(stock prices, but each box has an X coordinate) |
|
∞ | 10000 | shadow | CandlestickChartOptions(), filled areas |
CircularBarChart()
(circular progress bars) |
|
1 | 10000 | shadow, label | BarStyle(), filled areas |
ContourPlot()
(topographic map) |
|
∞ | 1 | shadow, label, symbol | ContourPlotOptions(), lines, filled areas (border only) |
DensityPlot()
(grid of colored blobs) |
|
∞ | 1 | shadow, label, symbol | DensityPlotOptions(), FillColorScale() |
GanttChart()
(range-based timeline) |
|
∞ | 10000 | shadow, label, symbol, horizontal | BarStyle(), filled areas |
HeatMap()
(grid of colored tiles) |
|
∞ | 1 | shadow, label | HeatMapOptions(), FillColorScale(), filled areas (usually border only) |
HighLowChart()
(like a candlestick chart without the boxes) |
|
∞ | 10000 | shadow, label, symbol, horizontal | HighLowChartOptions(), lines |
HighLowChart2D()
(like a 2D candlestick chart without the boxes) |
|
∞ | 10000 | shadow, label, symbol, horizontal | HighLowChartOptions(), lines |
Histogram()
(a bar chart that groups values into several buckets) |
|
∞ | 10000 | shadow, label, symbol, horizontal, stacked | HistogramOptions(), HistogramRange(), filled areas |
LinearGauge()
(points on a number line) |
|
1 | 10000 | shadow, label, horizontal | symbols |
LinearMeter()
(progress bar) |
|
1 | 10000 | shadow, symbol, horizontal | filled areas |
LineChart()
(like a 1D scatter chart with connecting lines) |
|
∞ | 10000 | shadow, label, symbol, horizontal | lines |
LineChart2D()
(like a 2D scatter chart with connecting lines) |
|
∞ | 10000 | shadow, label, symbol | lines |
PieChart()
(basic pie chart) |
|
∞ | 1 | shadow, label, oval | pie charts, filled areas |
PolarChart()
(like a 2D area chart displayed with a polar grid) |
|
∞ | 10000 | shadow, label, symbol, oval | PolarChartOptions(), filled areas, ArrowStyle() |
RadarChart()
(like a 1D area chart but on a polar grid) |
|
∞ | 10000 | shadow, label, symbol, oval | RadarChartOptions(), filled areas, ArrowStyle() |
RadialGauge()
(like a speedometer) |
|
1 | 10000 | shadow | filled areas |
ScatterChart()
(like a bar chart, but with points instead of bars) |
|
∞ | 10000 | shadow, label, horizontal | symbols |
ScatterChart2D()
(points drawn at X/Y coordinates) |
|
∞ | 10000 | shadow, label | symbols |
TreeMap()
(various numbers sorted into rectangles of descending size) |
|
∞ | 10000 | shadow, label | TreeMapOptions(), FillColorScale(), filled areas (usually border only) |
VectorPlot()
(like a 1D scatter chart, but with arrows of some length and direction) |
|
∞ | 10000 | shadow, label, symbol, horizontal | VectorPlotOptions(), lines |
VectorPlot2D()
(like a 2D scatter chart, but with arrows of some length and direction) |
|
∞ | 10000 | shadow, label, symbol | VectorPlotOptions(), lines |
VennDiagram()
(2 or 3 intersecting circles with counts by category) |
|
∞ | 3 | label, horizontal | filled areas |
ViolinPlot()
(used to represent statistical distributions) |
|
∞ | 10000 | shadow, horizontal | ViolinPlotOptions(), filled areas |
Chart Appearance
Colors and Patterns
- Colors can be specified by color name, RGB/RGBA integers, or long or short hex codes; read more here. Gradients and predefined patterns are also available.
- BorderColorScheme(), FillColorScheme(), LineColorScheme(), and SymbolColorScheme() can specify a color scheme to avoid having to specify individual colors for every series.
- Density plots, heat maps, and tree maps use color scales rather than fill colors.
- Read here about the shaded option offered by some functions.
Filled Areas
- Series drawn as filled areas can be styled with FillStyle() or PictureStyle(). A fill color scheme can be defined using FillColorScheme().
- A filled area's border can be styled with BorderStyle(). A border color scheme can be defined using BorderColorScheme().
- If a series is drawn as an unfilled line, its line is instead styled with LineStyle().
Lines
- Series drawn as lines can be styled with LineStyle(). A line color scheme can be defined using LineColorScheme().
- If a series is drawn as a filled area, its line is instead styled with BorderStyle().
Symbols
- Series in charts with the symbol option enabled (or which are inherently symbol-based) can have their points styled with SymbolStyle(). A symbol color scheme can be defined using SymbolColorScheme().
- See a list of symbol types here.
Shadows
- Series in charts with the shadow option enabled can have their shadows configured with ShadowStyle().
- Read here about shadow options which can be defined in ShadowStyle and other functions which include a shadowEffect parameter.
Axes
- Move or hide an axis using AxisOptions().
- Use Scaling() and ScalingOptions() to change axis scaling (including min/max values, as well as the number of major/minor tick intervals).
- Change the appearance of the axis line using AxisLine().
- Label an axis using AxisLabelText(), and set the label's position with AxisLabelOptions(). Style the label's text with AxisLabelStyle(), and adjust the label's background with AxisLabelBackground() and AxisLabelBackgroundOptions().
- Change the appearance of tick marks using AxisMajorTicks() and AxisMinorTicks().
- Set tick marks' labels using AxisMajorTickLabelTexts() and AxisMinorTickLabelTexts() (see pipe notation for numbers and dates/times).
- Adjust tick labels' location with AxisMajorTickLabelOptions() and AxisMinorTickLabelOptions(). Style the labels' text with AxisMajorTickLabelStyle() and AxisMinorTickLabelStyle(). Adjust their background with AxisMajorTickLabelBackground(), AxisMajorTickLabelBackgroundOptions(), AxisMinorTickLabelBackground(), and AxisMinorTickLabelBackgroundOptions().
Grid
- Hide the grid lines (or move them to the foreground) with GridLocation().
- The grid's major and minor intervals are set with Scaling().
- Style major grid lines using MajorGridLineWidths(), MajorGridLineColors(), and MajorGridLinePatterns(). Style minor grid lines using MinorGridLineWidths(), MinorGridLineColors(), and MinorGridLinePatterns().
- Color the regions between major grid lines using MajorGridStripeColors() and MajorGridStripePatterns(). Color the regions between minor grid lines using MinorGridStripeColors() and MinorGridStripePatterns().
- Style the border around the grid using GridFrame(). Change the grid's background using ChartBackground() or ChartBackgroundPict(). A few chart types also support ChartBackgroundOptions() for rounded corners and padding.
Background
- Use Background() or BackgroundPict() to define a background for a view, group, or for the entire drawing.
- Use ChartBackground() or ChartBackgroundPict() to define a background for a chart grid.
Title
- Add a chart title (and optional subtitle) with TitleText(). Position the title with TitleOptions().
- Style the title's text with TitleStyle(), and the subtitle's text with TitleSubStyle().
- Adjust the title's background with TitleBackground() and TitleBackgroundOptions().
Legend
- Enable a chart legend with LegendOptions().
- Add a title to the legend with LegendTitle().
- Adjust the legend's background with LegendBackground() and LegendBackgroundOptions().
- Customize the legend's series labels with LegendTexts(). Style their text with LegendStyle().
- Use LegendColorTones() or LegendColorScale() to add a color legend to a DensityPlot, HeatMap, or TreeMap.
Value Labels
- If a chart has the label option enabled, value labels can be configured using LabelTexts() (see pipe notation for numbers and dates/times).
- Adjust value labels' location (and lower/upper limits) with LabelOptions(). Style the labels' text with LabelStyle(). Adjust their background with LabelBackground() and LabelBackgroundOptions().
- For inner labels used with PieChart, see pie charts.
Pie Charts
- In the context of PieChart, the label option refers to value labels normally placed outside the pie slices. A second set of labels, normally placed inside the pie slices, are available via PieChartInnerLabelTexts() (see pipe notation for numbers). The placement of outer and inner labels can be adjusted with PieChartLabelOptions().
- Style outer labels' text with LabelStyle(), and inner labels' text with PieChartInnerLabelStyle(). Adjust outer labels' background with LabelBackground() and LabelBackgroundOptions(), and inner labels' background with PieChartInnerLabelBackground() and PieChartInnerLabelBackgroundOptions().
- Outer labels can be drawn with a connecting line using PieChartAuxLines().
- An additional label at the center of the pie can be specified with PieChartCenterLabelText() (see pipe notation for numbers). Style the label's text with PieChartCenterLabelStyle(), and adjust its background with PieChartCenterLabelBackground() and PieChartCenterLabelBackgroundOptions().
- One or more pie slices may be offset from the center of the pie using PieChartExplodes(). When a pie chart uses the pieDepth parameter for a 3D effect, PieChartExplodeDepths() can be used to raise one or more pie slices along the z-axis.
Additional Lines
- Add a curve-fitting line with CurveFitting() and CurveFittingOptions(). Change its line style with CurveFittingLineStyle().
- Adding a moving-average line with MovingAverage() and MovingAverageOptions(). Change its line style with MovingAverageLineStyle().
- If you draw a reference point DropLineReferencePoint() or reference line DropLineReferenceLine(), points on the chart will be given a connector line to that point/line. Alternately, one series can be connected to another references series with DropLineReferenceSeries(). Modify the resulting connector lines with DropLineStyle().
- Draw error bars with ErrorBars(). Change the error bars' appearance with ErrorBarStyle(), or switch to 2D error regions with ErrorBarStyle2D(). Enter customized error bar data with ErrorBarData().
Formatting Numbers, Dates, Times, and Text
- Use SetThousandsSep() to globally add a comma as a thousands separator (this only affects output, not input). SetDecimalPoint() globally changes the decimal point character. HypenationOptions() globally changes hyphenation rules.
- Numbers, dates, and times in major/minor tick labels and value labels can be formatted using pipe notation (see help for formatting numbers and dates/times).
Other Graphical Objects
xmCHART drawings may also incorporate barcodes, vector objects, text tags, and data tables.
Output
The drawing can be exported as an image file using various save functions (or using FileMaker's Export Field Contents command, if the drawing has been inserted into a container field).