@@ -26,89 +26,67 @@ import { ChartMixin } from './vaadin-chart-mixin.js';
2626 * There are two ways of configuring your `<vaadin-chart>` element: **HTML API**, **JS API** and **JSON API**.
2727 * Note that you can make use of all APIs in your element.
2828 *
29- * #### Configuring your chart using HTML API
29+ * #### Using HTML API
3030 *
3131 * `vaadin-chart` has a set of attributes to make it easier for you to customize your chart.
3232 *
3333 * ```html
34- * <vaadin-chart title="The chart title" subtitle="The chart subtitle">
35- * <vaadin-chart-series
36- * type="column"
37- * title="The series title"
38- * values="[10,20,30]">
39- * </vaadin-chart-series>
40- * </vaadin-chart>
34+ * <vaadin-chart title="The chart title" subtitle="The chart subtitle">
35+ * <vaadin-chart-series
36+ * type="column"
37+ * title="The series title"
38+ * values="[10, 20, 30]"
39+ * > </vaadin-chart-series>
40+ * </vaadin-chart>
4141 * ```
4242 *
4343 * > Note that while you can set type for each series individually, for some types, such as `'bar'`, `'gauge'` and `'solidgauge'`, you
4444 * > have to set it as the default series type on `<vaadin-chart>` in order to work properly.
4545 *
46- * #### Configuring your chart using JS API
46+ * #### Using JS API
47+ *
48+ * Use [`configuration`](#/elements/vaadin-chart#property-configuration) property to set chart title, categories and data:
4749 *
48- * 1. Set an id for the `<vaadin-chart>` in the template
49- * ```html
50- * <vaadin-chart id="mychart"></vaadin-chart>
51- * ```
52- * 1. Add a function that uses `configuration` property (JS Api) to set chart title, categories and data
53- * ```js
54- * initChartWithJSApi() {
55- * requestAnimationFrame(() => {
56- * const configuration = this.$.mychart.configuration;
57- * configuration.setTitle({ text: 'The chart title' });
58- * // By default there is one X axis, it is referenced by configuration.xAxis[0].
59- * configuration.xAxis[0].setCategories(['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']);
60- * configuration.addSeries({
61- * type: 'column',
62- * data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
63- * });
64- * });
65- * }
66- * ```
67- * 1. Call that function from connectedCallback (when the element is added to a document)
6850 * ```js
69- * connectedCallback() {
70- * super.connectedCallback();
71- * this.initChartWithJSApi();
72- * }
51+ * const chart = document.querySelector('vaadin-chart');
52+ *
53+ * // Wait for default configuration to be ready
54+ * requestAnimationFrame(() => {
55+ * const configuration = chart.configuration;
56+ * configuration.setTitle({ text: 'The chart title' });
57+ * // By default there is one X axis, it is referenced by configuration.xAxis[0].
58+ * configuration.xAxis[0].setCategories(['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']);
59+ * configuration.addSeries({
60+ * type: 'column',
61+ * data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
62+ * });
63+ * });
7364 * ```
7465 *
75- * #### Configuring your chart using JS JSON API
66+ * #### Using JS JSON API
7667 *
77- * JS JSON API is a simple alternative to the JS API.
68+ * Use [`updateConfiguration`](#/elements/vaadin-chart#method-updateConfiguration) method to set chart title, categories and data:
7869 *
79- * 1. Set an id for the `<vaadin-chart>` in the template
80- * ```html
81- * <vaadin-chart id="mychart"></vaadin-chart>
82- * ```
83- * 1. Add a function that uses `updateConfiguration` method (JS JSON Api) to set chart title, categories and data
84- * ```js
85- * initChartWithJSJSONApi() {
86- * this.$.mychart.updateConfiguration({
87- * title: {
88- * text: 'The chart title'
89- * },
90- * subtitle: {
91- * text: 'Subtitle'
92- * },
93- * xAxis: {
94- * categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
95- * },
96- * series: [{
97- * type: 'column',
98- * data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
99- * }]
100- * });
101- * }
102- * ```
103- * 1. Call that function from connectedCallback (when the element is added to a document)
10470 * ```js
105- * connectedCallback() {
106- * super.connectedCallback();
107- * this.initChartWithJSJSONApi();
108- * }
71+ * const chart = document.querySelector('vaadin-chart');
72+ * chart.updateConfiguration({
73+ * title: {
74+ * text: 'The chart title'
75+ * },
76+ * subtitle: {
77+ * text: 'Subtitle'
78+ * },
79+ * xAxis: {
80+ * categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
81+ * },
82+ * series: [{
83+ * type: 'column',
84+ * data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
85+ * }]
86+ * });
10987 * ```
11088 *
111- * It should be noted that chart style customization cannot be done via the JS or JSON API.
89+ * **Note:** chart style customization cannot be done via the JS or JSON API.
11290 * Styling properties in the JSON configuration will be ignored. The following section discusses chart styling.
11391 *
11492 * ### CSS Styling
0 commit comments