Farbschema: Dunkel
Sie befinden sich hier: start » en » Documentation » Microsoft Access development tools » WKL Forms Object Library » Data views » WklChart

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", wskBad in Form_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
+-----------------------------------------------------------------+
RegionMeaning
1Title
2A limit line from AddReference, in the color of its kind, with its caption
3The series as a line with markers; a missing value breaks the line
4The linear trend (ShowTrend), dashed, across the points it's based on
5The 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 LinkMasterFields and LinkChildFields; 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

MemberMeaning
RecordSourceTable, query or SQL statement.
XField, YFields, SeriesFieldThe X field; the Y fields separated by semicolons (one series each); or one Y field and a field whose values name the series.
XKindwcxNumber, wcxDate (default), wcxCategory.
ChartType, GroupingwctLine (default), wctPoint, wctColumn, wctBar; wcgGrouped (default), wcgStacked.
Aggregate, PeriodwcaNone (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.
MissingwcvGap (default), wcvConnect, wcvZero.
Title, YFormatTitle above the chart; .NET number format of the Y labels, for example 0.0.
ShowLegend, ShowTrend, ShowMarkersLegend with more than one series (default on); trend line per series; markers on lines up to 200 points (default on).
LinkMasterFields, LinkChildFieldsFields or controls of the form and the matching fields of the data, separated by semicolons.
RequeryReads 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.
ClearReferencesRemoves 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, LastErrorRead only.
ColorSchemeAs for the other components.
PrintStylewpsAutomatic (default): series, limits and bands also by pattern when printed or in print preview; wpsColor: color only; wpsPatterns: patterns also on the screen.
EventWhen
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

  • WklGauge: one value against its ranges, where a chart shows a series.
en/wiki/msaccess/comctl/data-views/chart/start.txt · Zuletzt geändert: von Wolfgang van der Stille