WklChart
WklChart draws a chart from a table, query, or SQL statement on an Access form: a series of
measurements over time with its lower and upper limits, monthly counts as columns, or values per
category as bars. Like a subform, it follows the form's current record through LinkMasterFields
and LinkChildFields. Because it uses its own renderer, the chart looks the same in Form view,
Design view, and Print Preview.
Since release 1.60.0; in reports and with PrintStyle since 1.62.0.
Get started
Common tasks
- Plot the wall thickness of the current measuring point over time:
RecordSource= the readings,XField= the date,YFields= the thickness,LinkMasterFields= the key on the form,LinkChildFields= the key in the readings. - Draw the minimum and maximum:
AddReference MinWall, , "Minimum", wskBadinForm_Current. - Find out when the minimum will be reached if the trend continues:
TrendReaches(0, MinWall). - Count inspections due per month:
ChartType = wctColumn,Aggregate = wcaCount,Period = wcyMonth. - Bands, one series per measuring point from long data, and reading the trend: How to: Show limits and a trend in a chart.
- One chart per report record, legible on a grayscale printout: How to: Print gauges and charts in a report.
Visual aid
+- WklChart ------------------------------------------------------+ | TML-1 Wall thickness | 1 | 11.0 | | | 10.5 |- - - - - - - - - - - - - - - - - - - - - - - - - Maximum| 2 | 10.0 | *-* | | 9.5 | *-*-* . | 3 | 9.0 | *-*-*-* . . | 4 | 8.5 |- - - - - - - - - - - - - - - - - - - - - - - - - Minimum| | +----------+----------+----------+----------+ | | 2026 2027 2028 2029 | 5 +-----------------------------------------------------------------+
| Region | Meaning |
|---|---|
| 1 | Title |
| 2 | A limit line from AddReference, in the color of its kind, with its caption |
| 3 | The series as a line with markers; a missing value breaks the line |
| 4 | The linear trend (ShowTrend), dashed, across the points it's based on |
| 5 | The time axis with calendar intervals (years, months, days) chosen to fit the width |
Key features
- Data binding to a table, query, or SQL statement, with one series per Y field (“wide” data) or one series per value of a series field (“long” data).
- Follows the form like a subform through
LinkMasterFieldsandLinkChildFields; when the master record changes, the chart reads its data again. - Four chart types: line, point, column, and bar; columns and bars can be clustered or stacked.
- Aggregation per X value or per day, week, month, quarter, or year: sum, average, count, minimum, and maximum.
- Limits and bands with captions, in the same status colors as the other components.
- Linear trend per series, with its slope and the date it reaches a limit.
- Long series are downsampled for display, and the chart says so; the trend and the axis still use every value.
- Readable for everyone: series colors that stay distinguishable for people with color vision deficiency and keep a 3:1 contrast ratio, a distinct marker shape per series, and the same color schemes as the other components.
Core concepts
The X values determine the axis. XKind = wcxDate gives a time axis with calendar intervals;
wcxNumber, a numeric axis with round steps (1, 2, 2.5, or 5 times a power of ten); and
wcxCategory, one position per distinct text, in the order the texts first appear.
Missing values aren't made up. With Missing = wcvGap (the default), a row without a Y value
breaks the line. wcvConnect skips the point, and wcvZero treats it as 0. A row without a
readable X value can't be placed; instead of failing the chart, it's counted in RowsWithoutX.
Errors are displayed, not raised. The chart reads its data on its own (when the form opens and
when the master record changes), outside any VBA call that could catch an error. A read error is
drawn in the chart, stored in LastError, and reported through DataLoaded.
The value axis includes the limits. The Y axis always spans every limit line and band, so a limit outside the measured range is never cut off. Columns and bars start at 0.
A downsampled chart says so. A line with more points than the chart can display (more than 2,000) is downsampled with the Largest-Triangle-Three-Buckets algorithm (Steinarsson, 2013), which keeps the first and last points and the peaks; the chart then shows “reduced for display” in its corner.
Contract
| Member | Meaning |
|---|---|
RecordSource | Table, query or SQL statement. |
XField, YFields, SeriesField | The X field; the Y fields separated by semicolons (one series each); or one Y field and a field whose values name the series. |
XKind | wcxNumber, wcxDate (default), wcxCategory. |
ChartType, Grouping | wctLine (default), wctPoint, wctColumn, wctBar; wcgGrouped (default), wcgStacked. |
Aggregate, Period | wcaNone (default), wcaSum, wcaAverage, wcaCount, wcaMin, wcaMax; wcyNone (default), wcyDay, wcyWeek (ISO, from Monday), wcyMonth, wcyQuarter, wcyYear. A group without any value is a gap, not 0; wcaCount needs no Y field. |
Missing | wcvGap (default), wcvConnect, wcvZero. |
Title, YFormat | Title above the chart; .NET number format of the Y labels, for example 0.0. |
ShowLegend, ShowTrend, ShowMarkers | Legend with more than one series (default on); trend line per series; markers on lines up to 200 points (default on). |
LinkMasterFields, LinkChildFields | Fields or controls of the form and the matching fields of the data, separated by semicolons. |
Requery | Reads the data again. |
AddReference(FromValue, [ToValue], [Caption], [Kind]) | Adds a limit line, or a band from FromValue to ToValue; Kind is a wsk* status kind. Returns its number. |
ClearReferences | Removes all limit lines and bands. |
SeriesCount, SeriesName(i), SeriesVisible(i) | The series from 0; a click on a legend entry toggles SeriesVisible. |
TrendSlope(i) | Change of Y per X unit (per day on a date axis); Null with fewer than two points. |
TrendReaches(i, Value) | The X (a date on a date axis) where the trend reaches Value; Null when it never does. |
RowsWithoutX, LastError | Read only. |
ColorScheme | As for the other components. |
PrintStyle | wpsAutomatic (default): series, limits and bands also by pattern when printed or in print preview; wpsColor: color only; wpsPatterns: patterns also on the screen. |
| Event | When |
|---|---|
PointClick(Series, X, Y) | A click on a point, column or bar; X as a date, category text or number. |
DataLoaded(Points) | The data were read; also after an error (see LastError). |
Administration
Troubleshooting
None yet.
For developers
Related topics
- WklGauge: one value against its ranges, where a chart shows a series.