@redvars/peacock 3.15.0 → 3.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. package/dist/assets/styles.css +1 -1
  2. package/dist/assets/styles.css.map +1 -1
  3. package/dist/assets/theme.js +19 -19
  4. package/dist/assets/tokens.css +1 -1
  5. package/dist/assets/tokens.css.map +1 -1
  6. package/dist/card-content.js +8 -7
  7. package/dist/card-content.js.map +1 -1
  8. package/dist/card.js +142 -98
  9. package/dist/card.js.map +1 -1
  10. package/dist/{chart-bar-D5dGFJfK.js → cartesian-chart-DgE4USyC.js} +529 -312
  11. package/dist/cartesian-chart-DgE4USyC.js.map +1 -0
  12. package/dist/chart-area.js +78 -0
  13. package/dist/chart-area.js.map +1 -0
  14. package/dist/chart-bar.js +283 -213
  15. package/dist/chart-bar.js.map +1 -1
  16. package/dist/{transform-DSwFSqzD.js → chart-base-C2qRMF48.js} +771 -102
  17. package/dist/chart-base-C2qRMF48.js.map +1 -0
  18. package/dist/chart-doughnut.js +55 -287
  19. package/dist/chart-doughnut.js.map +1 -1
  20. package/dist/chart-line.js +626 -0
  21. package/dist/chart-line.js.map +1 -0
  22. package/dist/chart-pie.js +637 -195
  23. package/dist/chart-pie.js.map +1 -1
  24. package/dist/code-editor.js +704 -131
  25. package/dist/code-editor.js.map +1 -1
  26. package/dist/code-group.js +188 -0
  27. package/dist/code-group.js.map +1 -0
  28. package/dist/code-highlighter.js +895 -257
  29. package/dist/code-highlighter.js.map +1 -1
  30. package/dist/custom-elements-jsdocs.json +2278 -677
  31. package/dist/custom-elements.json +13962 -3690
  32. package/dist/image.js +5 -1
  33. package/dist/image.js.map +1 -1
  34. package/dist/index.js +8 -7
  35. package/dist/index.js.map +1 -1
  36. package/dist/loader-full.js +1 -1
  37. package/dist/loader.js +9 -3
  38. package/dist/loader.js.map +1 -1
  39. package/dist/{is-dark-mode-DOcaw4Yq.js → observe-theme-change-DCifz1uv.js} +2 -6
  40. package/dist/observe-theme-change-DCifz1uv.js.map +1 -0
  41. package/dist/pagination.js +408 -110
  42. package/dist/pagination.js.map +1 -1
  43. package/dist/path-CJ0Arqcy.js +166 -0
  44. package/dist/path-CJ0Arqcy.js.map +1 -0
  45. package/dist/snackbar.js +89 -34
  46. package/dist/snackbar.js.map +1 -1
  47. package/dist/src/__internal/chart/cartesian-chart.d.ts +80 -0
  48. package/dist/src/__internal/chart/chart-base.d.ts +113 -0
  49. package/dist/src/__internal/chart/paths.d.ts +5 -0
  50. package/dist/src/__internal/chart/types.d.ts +42 -0
  51. package/dist/src/card/card-content.d.ts +2 -3
  52. package/dist/src/card/card.d.ts +31 -17
  53. package/dist/src/chart-area/chart-area.d.ts +54 -0
  54. package/dist/src/chart-area/index.d.ts +1 -0
  55. package/dist/src/chart-bar/chart-bar.d.ts +44 -33
  56. package/dist/src/chart-bar/index.d.ts +0 -1
  57. package/dist/src/chart-doughnut/chart-doughnut.d.ts +33 -39
  58. package/dist/src/chart-line/chart-line.d.ts +69 -0
  59. package/dist/src/chart-line/index.d.ts +1 -0
  60. package/dist/src/chart-pie/chart-pie.d.ts +63 -28
  61. package/dist/src/code-editor/code-editor.d.ts +52 -13
  62. package/dist/src/code-editor/editor-theme.d.ts +60 -0
  63. package/dist/src/code-highlighter/code-group.d.ts +52 -0
  64. package/dist/src/code-highlighter/code-highlighter.d.ts +122 -15
  65. package/dist/src/code-highlighter/index.d.ts +1 -0
  66. package/dist/src/code-highlighter/line-ranges.d.ts +24 -0
  67. package/dist/src/code-highlighter/local.d.ts +4 -1
  68. package/dist/src/code-highlighter/token-colors.d.ts +8 -0
  69. package/dist/src/index.d.ts +4 -2
  70. package/dist/src/pagination/page-items.d.ts +14 -0
  71. package/dist/src/pagination/pagination.d.ts +46 -7
  72. package/dist/src/snackbar/snackbar.d.ts +13 -1
  73. package/dist/src/table/table.d.ts +125 -27
  74. package/dist/src/toolbar/toolbar.d.ts +56 -51
  75. package/dist/table.js +1007 -338
  76. package/dist/table.js.map +1 -1
  77. package/dist/test/chart.test.d.ts +1 -0
  78. package/dist/test/code-highlighter.test.d.ts +1 -0
  79. package/dist/test/pagination.test.d.ts +1 -0
  80. package/dist/test/table.test.d.ts +1 -0
  81. package/dist/token-colors-0TFHWbcq.js +81 -0
  82. package/dist/token-colors-0TFHWbcq.js.map +1 -0
  83. package/dist/toolbar.js +195 -184
  84. package/dist/toolbar.js.map +1 -1
  85. package/dist/tsconfig.tsbuildinfo +1 -1
  86. package/package.json +1 -2
  87. package/readme.md +7 -6
  88. package/scss/_code-block.scss +139 -0
  89. package/scss/tokens.css +24 -0
  90. package/src/__internal/chart/cartesian-chart.ts +404 -0
  91. package/src/__internal/chart/chart-base.scss +252 -0
  92. package/src/__internal/chart/chart-base.ts +474 -0
  93. package/src/__internal/chart/paths.ts +28 -0
  94. package/src/__internal/chart/types.ts +49 -0
  95. package/src/card/card-content.ts +12 -9
  96. package/src/card/card.scss +66 -54
  97. package/src/card/card.ts +109 -73
  98. package/src/chart-area/chart-area.ts +82 -0
  99. package/src/chart-area/index.ts +1 -0
  100. package/src/chart-bar/chart-bar.ts +336 -250
  101. package/src/chart-bar/index.ts +0 -1
  102. package/src/chart-doughnut/chart-doughnut.ts +62 -262
  103. package/src/chart-doughnut/demo/index.html +14 -22
  104. package/src/chart-line/chart-line.scss +25 -0
  105. package/src/chart-line/chart-line.ts +346 -0
  106. package/src/chart-line/index.ts +1 -0
  107. package/src/chart-pie/chart-pie.scss +35 -16
  108. package/src/chart-pie/chart-pie.ts +282 -188
  109. package/src/chart-pie/demo/index.html +13 -21
  110. package/src/code-editor/code-editor.scss +132 -36
  111. package/src/code-editor/code-editor.ts +308 -88
  112. package/src/code-editor/demo/index.html +39 -12
  113. package/src/code-editor/editor-theme.ts +213 -0
  114. package/src/code-highlighter/code-group.scss +34 -0
  115. package/src/code-highlighter/code-group.ts +173 -0
  116. package/src/code-highlighter/code-highlighter.scss +226 -111
  117. package/src/code-highlighter/code-highlighter.ts +554 -199
  118. package/src/code-highlighter/demo/index.html +68 -4
  119. package/src/code-highlighter/index.ts +1 -0
  120. package/src/code-highlighter/line-ranges.ts +81 -0
  121. package/src/code-highlighter/local.ts +9 -3
  122. package/src/code-highlighter/token-colors.ts +42 -0
  123. package/src/index.ts +4 -2
  124. package/src/loader.ts +8 -2
  125. package/src/pagination/page-items.ts +50 -0
  126. package/src/pagination/pagination.scss +159 -44
  127. package/src/pagination/pagination.ts +275 -74
  128. package/src/snackbar/demo/index.html +39 -4
  129. package/src/snackbar/snackbar.scss +27 -10
  130. package/src/snackbar/snackbar.ts +80 -37
  131. package/src/table/table.scss +337 -109
  132. package/src/table/table.ts +812 -272
  133. package/src/toolbar/toolbar-colors.scss +6 -7
  134. package/src/toolbar/toolbar.scss +35 -106
  135. package/src/toolbar/toolbar.ts +180 -80
  136. package/dist/array-D5vjT2Xm.js +0 -14
  137. package/dist/array-D5vjT2Xm.js.map +0 -1
  138. package/dist/chart-bar-D5dGFJfK.js.map +0 -1
  139. package/dist/chart-stacked-bar.js +0 -403
  140. package/dist/chart-stacked-bar.js.map +0 -1
  141. package/dist/copy-to-clipboard-upGx-Ueo.js +0 -39
  142. package/dist/copy-to-clipboard-upGx-Ueo.js.map +0 -1
  143. package/dist/is-dark-mode-DOcaw4Yq.js.map +0 -1
  144. package/dist/pie-Dz0IDiPt.js +0 -537
  145. package/dist/pie-Dz0IDiPt.js.map +0 -1
  146. package/dist/pierre-dark-DFWl0m-C.js +0 -4
  147. package/dist/pierre-dark-DFWl0m-C.js.map +0 -1
  148. package/dist/pierre-light-BEkAPImt.js +0 -4
  149. package/dist/pierre-light-BEkAPImt.js.map +0 -1
  150. package/dist/src/chart-bar/chart-stacked-bar.d.ts +0 -78
  151. package/dist/src/code-highlighter/constants.d.ts +0 -1
  152. package/dist/transform-DSwFSqzD.js.map +0 -1
  153. package/src/chart-bar/chart-bar.scss +0 -58
  154. package/src/chart-bar/chart-stacked-bar.ts +0 -398
  155. package/src/chart-doughnut/chart-donut.scss +0 -37
  156. package/src/code-highlighter/constants.ts +0 -117
  157. /package/dist/test/{chart-bar.test.d.ts → card.test.d.ts} +0 -0
@@ -1,283 +1,83 @@
1
- import { html, LitElement, PropertyValues } from 'lit';
2
- import { property, query } from 'lit/decorators.js';
3
- import { select, arc, pie, scaleOrdinal, easeCubicInOut, interpolateNumber, PieArcDatum, BaseType } from 'd3';
1
+ import { html } from 'lit';
2
+ import { property } from 'lit/decorators.js';
3
+ import { styleMap } from 'lit/directives/style-map.js';
4
4
  import IndividualComponent from '@/IndividualComponent.js';
5
- import styles from './chart-donut.scss';
5
+ import { ChartPie } from '../chart-pie/chart-pie.js';
6
6
 
7
- export type ChartDoughnutColor = {
8
- color: string;
9
- };
10
-
11
- export type ChartDoughnutItem = {
12
- name: string;
13
- value: number;
14
- label?: string;
15
- color?: string;
16
- };
17
-
18
- const chartColors: ChartDoughnutColor[] = [];
19
- ['purple', 'blue', 'red', 'green', 'yellow', 'orange'].forEach(colorName => {
20
- chartColors.push({
21
- color: `var(--color-${colorName})`,
22
- });
23
- });
24
-
25
- /** SVGPathElement augmented with the last rendered arc datum for smooth tween interpolation. */
26
- interface ArcPathElement extends SVGPathElement {
27
- _prevDatum?: PieArcDatum<ChartDoughnutItem>;
28
- }
29
-
30
- function debounce<T extends (...args: any[]) => void>(fn: T, wait: number): T {
31
- let timer: ReturnType<typeof setTimeout>;
32
- return ((...args: any[]) => {
33
- clearTimeout(timer);
34
- timer = setTimeout(() => fn(...args), wait);
35
- }) as T;
36
- }
7
+ export type {
8
+ ChartPieItem,
9
+ ChartSelectDetail,
10
+ ChartValueFormatter,
11
+ } from '../chart-pie/chart-pie.js';
37
12
 
38
13
  /**
39
- * @label Chart Doughnut
14
+ * @label Doughnut Chart
40
15
  * @tag wc-chart-doughnut
41
16
  * @rawTag chart-doughnut
42
- * @summary A doughnut chart is a circular chart with a blank center. The area in the center can be used to display information.
17
+ * @summary A pie chart with a hole that shows the total, or the hovered slice, in its centre.
43
18
  * @tags charts
44
19
  *
45
20
  * @example
46
21
  * ```html
47
- * <wc-chart-doughnut width="400" label="Total"></wc-chart-doughnut>
22
+ * <wc-chart-doughnut label="Visitors by browser" center-label="Visitors"></wc-chart-doughnut>
48
23
  * <script>
49
24
  * document.querySelector('wc-chart-doughnut').data = [
50
- * { name: 'A', value: 30, label: 'Category A' },
51
- * { name: 'B', value: 50, label: 'Category B' },
52
- * { name: 'C', value: 20, label: 'Category C' },
25
+ * { name: 'chrome', label: 'Chrome', value: 275 },
26
+ * { name: 'safari', label: 'Safari', value: 200 },
27
+ * { name: 'firefox', label: 'Firefox', value: 187 },
53
28
  * ];
54
29
  * </script>
55
30
  * ```
31
+ *
32
+ * @slot center - Replaces the total and caption in the centre.
33
+ * @slot empty - Shown when there is no data. Defaults to "No data".
34
+ *
35
+ * @fires chart-select - A slice was clicked or chosen with Enter. `detail` holds `index`, `series` (the slice name) and `datum`.
36
+ *
37
+ * @csspart container - The outer wrapper.
38
+ * @csspart plot - The focusable plot area holding the SVG.
39
+ * @csspart center - The centre content.
40
+ * @csspart tooltip - The tooltip.
41
+ * @csspart legend - The legend.
42
+ *
43
+ * @cssprop --color-chart-1 - Color of the first slice; slices cycle through `--color-chart-1` to `--color-chart-8`.
44
+ * @cssprop --chart-dim-opacity - Opacity of slices that are not hovered. Defaults to `0.4`.
56
45
  */
57
46
  @IndividualComponent
58
- export class ChartDoughnut extends LitElement {
59
- static styles = [styles];
60
-
61
- @query('svg')
62
- private svgElement?: SVGElement;
63
-
64
- /** Width (and height) of the chart in pixels. */
65
- @property({ type: Number, reflect: true }) width: number = 0;
66
-
67
- /** Margin around the chart. */
68
- @property({ type: Number, reflect: true }) margin: number = 10;
69
-
70
- /** Whether to show labels outside the chart. */
71
- @property({ type: Boolean, reflect: true, attribute: 'show-labels' })
72
- showLabels: boolean = true;
73
-
74
- /** Chart data array. Each item should have name, value, and optional label and color. */
75
- @property({ type: Array }) data: ChartDoughnutItem[] = [];
76
-
77
- /** Label displayed in the center of the doughnut. */
78
- @property({ type: String }) label?: string;
79
-
80
- private _initialized = false;
81
-
82
- private _debouncedRenderChart = debounce(() => {
83
- this._renderChart(true);
84
- }, 300);
85
-
86
- firstUpdated() {
87
- this._renderChart(false);
88
- }
89
-
90
- updated(changedProperties: PropertyValues) {
91
- if (!this._initialized) {
92
- this._initialized = true;
93
- return;
94
- }
95
- const watchedProps = ['width', 'margin', 'showLabels', 'data'];
96
- const hasChanged = watchedProps.some(prop => changedProperties.has(prop));
97
- if (hasChanged) {
98
- this._debouncedRenderChart();
99
- }
100
- }
101
-
102
- private _getRadius(): number {
103
- return this.width / 2 - this.margin - 100;
104
- }
105
-
106
- private _getTotal(): number {
107
- return this.data.reduce((total, d) => total + d.value, 0);
108
- }
109
-
110
- private _getPieData() {
111
- const pieGenerator = pie<ChartDoughnutItem>()
112
- .sort(null)
113
- .value(d => d.value);
114
- return pieGenerator(this.data);
115
- }
116
-
117
- private _getColorScale() {
118
- return scaleOrdinal<string, ChartDoughnutColor>()
119
- .domain(this.data.map(d => d.name))
120
- .range(chartColors);
121
- }
122
-
123
- private _renderChart(animate: boolean) {
124
- if (!this.svgElement) return;
125
-
126
- const DURATION = 500;
127
- const radius = this._getRadius();
128
- const pieData = this._getPieData();
129
- const colorScale = this._getColorScale();
130
- const total = this._getTotal();
131
-
132
- const svg = select(this.svgElement);
133
-
134
- const doughnutArc = arc<PieArcDatum<ChartDoughnutItem>>()
135
- .innerRadius(radius * 0.72)
136
- .outerRadius(radius);
137
-
138
- const labelsArc = arc<PieArcDatum<ChartDoughnutItem>>()
139
- .innerRadius(radius + 10)
140
- .outerRadius(radius + 10);
141
-
142
- // Update SVG dimensions and center transform
143
- svg.attr('width', this.width).attr('height', this.width);
144
- svg
145
- .select('.chart-container')
146
- .attr('transform', `translate(${this.width / 2},${this.width / 2})`);
147
-
148
- // Arc paths — keyed by name so D3 matches elements across updates
149
- const $paths = svg
150
- .select('.arc-container')
151
- .selectAll<SVGPathElement, PieArcDatum<ChartDoughnutItem>>('.arc')
152
- .data(pieData, d => d.data.name)
153
- .join('path')
154
- .attr('class', 'arc')
155
- .style('fill', d => d.data.color || colorScale(d.data.name).color);
156
-
157
- if (animate) {
158
- $paths
159
- .transition()
160
- .duration(DURATION)
161
- .ease(easeCubicInOut)
162
- .attrTween('d', function (this: SVGPathElement, d) {
163
- const self = this as ArcPathElement;
164
- // Interpolate from the last rendered angles to the new ones.
165
- // New (entering) arcs start collapsed at their startAngle.
166
- const prev: { startAngle: number; endAngle: number } =
167
- self._prevDatum ?? {
168
- startAngle: d.startAngle,
169
- endAngle: d.startAngle,
170
- };
171
- self._prevDatum = d;
172
- const iStart = interpolateNumber(prev.startAngle, d.startAngle);
173
- const iEnd = interpolateNumber(prev.endAngle, d.endAngle);
174
- return (t: number) =>
175
- doughnutArc({ ...d, startAngle: iStart(t), endAngle: iEnd(t) }) ??
176
- '';
177
- });
178
- } else {
179
- // Initial render: draw immediately and seed previous-datum for later tweens
180
- $paths
181
- .each(function (this: SVGPathElement, d) {
182
- (this as ArcPathElement)._prevDatum = d;
183
- })
184
- .attr('d', d => doughnutArc(d) ?? '');
185
- }
186
-
187
- // Animate the central total counter
188
- const $title = svg.select('.title');
189
- if (animate) {
190
- $title
191
- .transition()
192
- .duration(DURATION)
193
- .ease(easeCubicInOut)
194
- .tween('text', function (this: BaseType) {
195
- const sel = select(this as SVGTextElement);
196
- const start = parseFloat(sel.text()) || 0;
197
- const interp = interpolateNumber(start, total);
198
- return function (t: number) {
199
- sel.text(Math.round(interp(t)));
200
- };
201
- });
202
- } else {
203
- $title.text(total);
204
- }
205
-
206
- // Label polylines and text
207
- const $chartContainer = svg.select('.chart-container');
208
-
209
- if (this.showLabels) {
210
- const pointsFn = (d: PieArcDatum<ChartDoughnutItem>) => {
211
- const posA = doughnutArc.centroid(d);
212
- const posB = labelsArc.centroid(d);
213
- const posC = posB.slice() as [number, number];
214
- const midAngle = d.startAngle + (d.endAngle - d.startAngle) / 2;
215
- posC[0] = radius * (midAngle < Math.PI ? 1 : -1);
216
- return [posA, posB, posC].map(p => p.join(',')).join(' ');
217
- };
218
-
219
- const transformFn = (d: PieArcDatum<ChartDoughnutItem>) => {
220
- const pos = labelsArc.centroid(d);
221
- const midAngle = d.startAngle + (d.endAngle - d.startAngle) / 2;
222
- pos[0] = radius * (midAngle < Math.PI ? 1 : -1);
223
- return `translate(${pos})`;
224
- };
225
-
226
- const anchorFn = (d: PieArcDatum<ChartDoughnutItem>) => {
227
- const midAngle = d.startAngle + (d.endAngle - d.startAngle) / 2;
228
- return midAngle < Math.PI ? 'start' : 'end';
229
- };
230
-
231
- const $polylines = $chartContainer
232
- .selectAll<SVGPolylineElement, PieArcDatum<ChartDoughnutItem>>(
233
- '.item-polyline',
234
- )
235
- .data(pieData, d => d.data.name)
236
- .join('polyline')
237
- .attr('class', 'item-polyline');
238
-
239
- const $labels = $chartContainer
240
- .selectAll<SVGTextElement, PieArcDatum<ChartDoughnutItem>>('.item-label')
241
- .data(pieData, d => d.data.name)
242
- .join('text')
243
- .attr('class', 'item-label')
244
- .text(d => d.data.label ?? '');
245
-
246
- if (animate) {
247
- $polylines
248
- .transition()
249
- .duration(DURATION)
250
- .ease(easeCubicInOut)
251
- .attr('points', pointsFn);
252
- $labels
253
- .transition()
254
- .duration(DURATION)
255
- .ease(easeCubicInOut)
256
- .attr('transform', transformFn)
257
- .style('text-anchor', anchorFn);
258
- } else {
259
- $polylines.attr('points', pointsFn);
260
- $labels.attr('transform', transformFn).style('text-anchor', anchorFn);
261
- }
262
- } else {
263
- $chartContainer.selectAll('.item-polyline').remove();
264
- $chartContainer.selectAll('.item-label').remove();
265
- }
47
+ export class ChartDoughnut extends ChartPie {
48
+ // ── Properties
49
+
50
+ /** Size of the hole as a fraction of the radius. */
51
+ @property({ type: Number, attribute: 'inner-radius' }) innerRadius: number =
52
+ 0.62;
53
+
54
+ /** Caption under the total in the centre. */
55
+ @property({ type: String, attribute: 'center-label' }) centerLabel: string =
56
+ 'Total';
57
+
58
+ // ── Render helpers
59
+
60
+ protected renderOverlay() {
61
+ const active =
62
+ this.activeIndex >= 0 ? this.data[this.activeIndex] : undefined;
63
+ const value = active ? active.value : this.visibleTotal();
64
+ const caption = active ? (active.label ?? active.name) : this.centerLabel;
65
+ const hole = Math.max(this.radius * this.innerRadius * 2 - 16, 0);
66
+ return html`<div
67
+ class="center"
68
+ part="center"
69
+ style=${styleMap({ '--_center-width': `${hole}px` })}
70
+ >
71
+ <slot name="center">
72
+ <span class="center-value">${this.formatValue(value)}</span>
73
+ <span class="center-label">${caption}</span>
74
+ </slot>
75
+ </div>`;
266
76
  }
77
+ }
267
78
 
268
- render() {
269
- return html`
270
- <div class="chart">
271
- <svg>
272
- <g class="chart-container">
273
- <g class="arc-container"></g>
274
- <text class="title" text-anchor="middle"></text>
275
- <text class="label" text-anchor="middle" y="16">
276
- ${this.label}
277
- </text>
278
- </g>
279
- </svg>
280
- </div>
281
- `;
79
+ declare global {
80
+ interface HTMLElementTagNameMap {
81
+ 'wc-chart-doughnut': ChartDoughnut;
282
82
  }
283
83
  }
@@ -4,47 +4,39 @@
4
4
  <meta charset='utf-8'>
5
5
  <meta name='viewport' content='width=device-width, initial-scale=1.0, viewport-fit=cover' />
6
6
  <link rel='stylesheet' href='/dist/assets/styles.css' />
7
- <link href="https://fonts.googleapis.com/css2?family=Noto+Sans+Mono:wght@100..900&family=Noto+Sans:ital,wght@0,100..900;1,100..900&display=swap" rel="stylesheet">
8
-
9
7
  <style>
10
8
  body {
11
- background: #fafafa;
9
+ background: var(--color-surface);
10
+ max-width: 480px;
11
+ margin: 2rem auto;
12
12
  }
13
13
  </style>
14
14
  </head>
15
15
  <body>
16
16
 
17
- <wc-button id="randomize">Randomize</wc-button>
18
- <br />
17
+ <wc-button id='randomize'>Randomize</wc-button>
19
18
 
20
- <wc-chart-doughnut width="400" margin="20"></wc-chart-doughnut>
19
+ <wc-chart-doughnut label='Visitors by browser' center-label='Visitors'></wc-chart-doughnut>
21
20
 
22
21
  <script>
23
22
  const chart = document.querySelector('wc-chart-doughnut');
24
- chart.label = "Browsers";
25
23
  chart.data = [
26
- { label: 'Firefox', value: 10, color: '--color-red', hoverColor: '--color-red-40' },
27
- { label: 'Chrome', value: 20, color: '--color-green', hoverColor: '--color-green-50' },
28
- { label: 'Microsoft Edge', value: 30 },
29
- { label: 'Internet Explorer', value: 40 },
30
- { label: 'MC Browser', value: 50 },
24
+ { name: 'chrome', label: 'Chrome', value: 275 },
25
+ { name: 'safari', label: 'Safari', value: 200 },
26
+ { name: 'firefox', label: 'Firefox', value: 187 },
27
+ { name: 'edge', label: 'Edge', value: 173 },
28
+ { name: 'other', label: 'Other', value: 90 },
31
29
  ];
32
30
 
33
- function randomNumber(min, max) {
34
- return parseInt(Math.random() * (max - min) + min);
35
- }
36
-
37
- let count = 1;
38
31
  document.querySelector('#randomize').addEventListener('click', () => {
39
- chart.data = chart.data.map(d => ({ ...d, value: parseInt(Math.random() * 100) }));
40
- chart.width = randomNumber(400, 600);
32
+ chart.data = chart.data.map(d => ({ ...d, value: Math.round(Math.random() * 300) + 20 }));
41
33
  });
42
34
  </script>
43
35
 
44
-
45
36
  <script type='module'>
46
- import { Button, ChartDonut } from '/dist/index.js';
47
- window.customElements.define('wc-chart-doughnut', ChartDonut);
37
+ import { Button } from '/dist/button.js';
38
+ import { ChartDoughnut } from '/dist/chart-doughnut.js';
39
+ window.customElements.define('wc-chart-doughnut', ChartDoughnut);
48
40
  window.customElements.define('wc-button', Button);
49
41
  </script>
50
42
  </body>
@@ -0,0 +1,25 @@
1
+ :host {
2
+ --_chart-line-width: var(--chart-line-width, 2px);
3
+ }
4
+
5
+ .line {
6
+ fill: none;
7
+ stroke-width: var(--_chart-line-width);
8
+ stroke-linecap: round;
9
+ stroke-linejoin: round;
10
+ }
11
+
12
+ .stop-start {
13
+ stop-opacity: 0.4;
14
+ }
15
+
16
+ .stop-end {
17
+ stop-opacity: 0.02;
18
+ }
19
+
20
+ .dot,
21
+ .active-dot {
22
+ stroke: var(--color-surface);
23
+ stroke-width: 2px;
24
+ pointer-events: none;
25
+ }