You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/documentation/docs/controls/ChartControl.md
+43-1Lines changed: 43 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -205,7 +205,7 @@ For example:
205
205
## Implementation
206
206
207
207
### ChartControl Properties
208
-
The ChartControl can be configured with the following properties:
208
+
The ChartControl control can be configured with the following properties:
209
209
210
210
| Property | Type | Required | Description |
211
211
| ---- | ---- | ---- | ---- |
@@ -221,6 +221,21 @@ The ChartControl can be configured with the following properties:
221
221
| onHover | (chart: Chart, event: MouseEvent, activeElements: Array<{}>) => void | no | Optional callback method that get called when a user hovers the chart |
222
222
| onResize | (chart: Chart, newSize: ChartSize) => void | no | Optional callback method that get called when the window containing the ChartXontrol resizes |
223
223
224
+
You can call the following methods to interact with the chart after it has been initialized:
225
+
226
+
| Method | Type | Description |
227
+
| ---- | ---- | ---- |
228
+
| clear | void | Will clear the chart canvas. Used extensively internally between animation frames, but you might find it useful. |
229
+
| getCanvas | () => HTMLCanvasElement | Return the canvass element that contains the chart |
| getDatasetAtEvent | (e: MouseEvent) => Array<{}> | Looks for the element under the event point, then returns all elements from that dataset. This is used internally for 'dataset' mode highlighting |
232
+
| getElementAtEvent | (e: MouseEvent) => {} | Calling getElementAtEvent(event) passing an argument of an event will return the single element at the event position. For example, you can use with `onClick` event handlers. |
233
+
| getElementsAtEvent | (e: MouseEvent) => Array<{}> | Looks for the element under the event point, then returns all elements at the same data index. This is used internally for 'label' mode highlighting. Calling `getElementsAtEvent(event)` passing an argument of an event will return the point elements that are at that the same position of that event. |
234
+
| renderChart | (config: {}) => void | Triggers a redraw of all chart elements. Note, this does not update elements for new data. Use .update() in that case. |
235
+
| stop | void | Use this to stop any current animation loop. This will pause the chart during any current animation frame. |
236
+
| toBase64Image | () => string | Returns a base 64 encoded string of the chart in it's current state. |
237
+
| update | (config?: number \| boolean \| string) => void | Triggers an update of the chart. This can be safely called after updating the data object. This will update all scales, legends, and then re-render the chart. |
238
+
224
239
### IChartAccessibility
225
240
226
241
The `IChartAccessibility` interface implements the following properties:
@@ -271,7 +286,34 @@ Defines the type of chart that will be rendered. For more information what data
The easiest way to customize a chart is to use the plugin functionality provided by Chart.js. In order to use a plugin, simply pass an array of objects that implement the `IChartPlugin` interface to the `plugins` property of the ChartControl.
274
292
293
+
If a hook is listed as cancellable, you can return `false` to cancel the event.
294
+
295
+
| Property | Type | Required | Description |
296
+
| ---- | ---- | ---- | ---- |
297
+
| afterDatasetsDraw | (chartInstance: Chart, easing: string, options?: {}) => void | no | Called after the datasets are drawn but after scales are drawn. |
298
+
| afterDatasetUpdate | (chartInstance: Chart, options?: {}) => void | no | Called after a dataset was updated. |
299
+
| afterDraw | (chartInstance: Chart, easing: string, options?: {}) => void | no | Called after an animation frame was drawn. |
300
+
| afterEvent | (chartInstance: Chart, event: Event, options?: {}) => void | no | Called after an event occurs on the chart. |
301
+
| afterInit | (chartInstance: Chart, options?: {}) => void | no | Called after a chart initializes |
302
+
| afterLayout | (chartInstance: Chart, options?: {}) => void | no | Called after the chart layout was rendered. |
303
+
| afterRender | (chartInstance: Chart, options?: {}) => void | no | Called after a rander. |
304
+
| afterTooltipDraw | (chartInstance: Chart, tooltipData?: {}, options?: {}) => void | no | Called after drawing the `tooltip`. Note that this hook will not be called if the tooltip drawing has been previously cancelled. |
305
+
| afterUpdate | (chartInstance: Chart, options?: {}) => void | no | Called after a chart updates |
306
+
| beforeDatasetsDraw | (chartInstance: Chart, easing: string, options?: {}) => void | no | Called before the datasets are drawn but after scales are drawn. Cancellable. |
307
+
| beforeDatasetUpdate| (chartInstance: Chart, options?: {}) => void | no | Called before a dataset is updated. Cancellable. |
308
+
| beforeDraw | (chartInstance: Chart, easing: string, options?: {}) => void | no | Called before an animation frame is drawn. |
309
+
| beforeEvent | (chartInstance: Chart, event: Event, options?: {}) => void | no | Called when an event occurs on the chart. Cancellable. |
310
+
| beforeInit | (chartInstance: Chart, options?: {}) => void | no | Called before a chart initializes |
311
+
| beforeLayout | (chartInstance: Chart, options?: {}) => void | no | Called before rendering the chart's layout. Cancellable. |
312
+
| beforeRender | (chartInstance: Chart, options?: {}) => void | no | Called at the start of a render. It is only called once, even if the animation will run for a number of frames. Use beforeDraw or afterDraw to do something on each animation frame. Cancellable. |
313
+
| beforeTooltipDraw | (chartInstance: Chart, tooltipData?: {}, options?: {}) => void | no | Called before drawing the `tooltip`. Cancellable. If it returns `false`, tooltip drawing is cancelled until another `render` is triggered. |
314
+
| beforeUpdate | (chartInstance: Chart, options?: {}) => void | no | Called before updating the chart. Cancellable. |
315
+
| destroy | (chartInstance: Chart) => void | no | Called when a chart is destroyed. |
316
+
| resize | (chartInstance: Chart, newChartSize: Chart.ChartSize, options?: {}) => void | no | Called when a chart resizes. Cancellable. |
0 commit comments