@xplortech/apollo-data 0.0.4 → 0.0.6

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 (88) hide show
  1. package/README.md +15 -91
  2. package/dist/apollo-data/apollo-data.esm.js +1 -1
  3. package/dist/apollo-data/p-25841a73.entry.js +1 -0
  4. package/dist/apollo-data/p-2nuV5Vny.js +1 -0
  5. package/dist/apollo-data/p-839050b7.entry.js +1 -0
  6. package/dist/apollo-data/p-C2k3WBpi.js +11 -0
  7. package/dist/apollo-data/p-D64asVrg.js +2 -0
  8. package/dist/apollo-data/p-e2c3a317.entry.js +1 -0
  9. package/dist/cjs/apollo-data-bar-chart.cjs.entry.js +315 -0
  10. package/dist/{esm/apollo-data-bar-chart_2.entry.js → cjs/apollo-data-base-COGMOEqL.js} +9 -724
  11. package/dist/cjs/apollo-data-donut-chart.cjs.entry.js +408 -0
  12. package/dist/cjs/apollo-data-heat-map_4.cjs.entry.js +883 -0
  13. package/dist/cjs/apollo-data.cjs.js +3 -3
  14. package/dist/cjs/constants-B3weDEpc.js +5 -0
  15. package/dist/cjs/{index-Cl7HgRm0.js → index-Bd5risOy.js} +116 -63
  16. package/dist/cjs/loader.cjs.js +2 -2
  17. package/dist/collection/apollo-data-base.js +4 -8
  18. package/dist/collection/collection-manifest.json +7 -2
  19. package/dist/collection/components/apollo-data-bar/apollo-data-bar.js +8 -7
  20. package/dist/collection/components/apollo-data-bar/apollo-data-bar.stories.js +122 -0
  21. package/dist/collection/components/apollo-data-donut/apollo-data-donut.js +1 -1
  22. package/dist/collection/components/apollo-data-donut/apollo-data-donut.stories.js +132 -0
  23. package/dist/collection/components/apollo-data-heat-map/apollo-data-heat-map.js +208 -0
  24. package/dist/collection/components/apollo-data-heat-map/apollo-data-heat-map.stories.js +137 -0
  25. package/dist/collection/components/apollo-data-line/apollo-data-line.js +348 -0
  26. package/dist/collection/components/apollo-data-line/apollo-data-line.stories.js +122 -0
  27. package/dist/collection/components/apollo-data-scatter/apollo-data-scatter.js +329 -0
  28. package/dist/collection/components/apollo-data-scatter/apollo-data-scatter.stories.js +147 -0
  29. package/dist/collection/components/apollo-data-world-map/apollo-data-world-map.js +294 -0
  30. package/dist/collection/components/apollo-data-world-map/apollo-data-world-map.stories.js +126 -0
  31. package/dist/collection/examples/apollo-data-heat-map.examples.js +131 -0
  32. package/dist/collection/examples/apollo-data-line.examples.js +91 -0
  33. package/dist/collection/examples/apollo-data-scatter.examples.js +94 -0
  34. package/dist/collection/examples/apollo-data-world-map.examples.js +45 -0
  35. package/dist/collection/examples/index.js +3 -0
  36. package/dist/collection/utils/code-generator.js +1 -1
  37. package/dist/components/apollo-data-bar-chart.js +1 -1
  38. package/dist/components/apollo-data-donut-chart.js +1 -1
  39. package/dist/components/apollo-data-heat-map.d.ts +11 -0
  40. package/dist/components/apollo-data-heat-map.js +1 -0
  41. package/dist/components/apollo-data-line-chart.d.ts +11 -0
  42. package/dist/components/apollo-data-line-chart.js +1 -0
  43. package/dist/components/apollo-data-scatter-chart.d.ts +11 -0
  44. package/dist/components/apollo-data-scatter-chart.js +1 -0
  45. package/dist/components/apollo-data-world-map-chart.d.ts +11 -0
  46. package/dist/components/apollo-data-world-map-chart.js +1 -0
  47. package/dist/components/index.js +1 -1
  48. package/dist/components/p-2nuV5Vny.js +1 -0
  49. package/dist/components/p-CfbMSXKd.js +11 -0
  50. package/dist/components/p-gcjU8DVr.js +1 -0
  51. package/dist/esm/apollo-data-bar-chart.entry.js +313 -0
  52. package/dist/{cjs/apollo-data-bar-chart_2.cjs.entry.js → esm/apollo-data-base-C2k3WBpi.js} +8 -728
  53. package/dist/esm/apollo-data-donut-chart.entry.js +406 -0
  54. package/dist/esm/apollo-data-heat-map_4.entry.js +878 -0
  55. package/dist/esm/apollo-data.js +4 -4
  56. package/dist/esm/constants-2nuV5Vny.js +3 -0
  57. package/dist/esm/{index-Bb2nY-Tf.js → index-D64asVrg.js} +116 -63
  58. package/dist/esm/loader.js +3 -3
  59. package/dist/types/apollo-data-base.d.ts +2 -2
  60. package/dist/types/components/apollo-data-bar/apollo-data-bar.stories.d.ts +5 -0
  61. package/dist/types/components/apollo-data-donut/apollo-data-donut.stories.d.ts +5 -0
  62. package/dist/types/components/apollo-data-heat-map/apollo-data-heat-map.d.ts +140 -0
  63. package/dist/types/components/apollo-data-heat-map/apollo-data-heat-map.stories.d.ts +5 -0
  64. package/dist/types/components/apollo-data-line/apollo-data-line.d.ts +244 -0
  65. package/dist/types/components/apollo-data-line/apollo-data-line.stories.d.ts +5 -0
  66. package/dist/types/components/apollo-data-scatter/apollo-data-scatter.d.ts +327 -0
  67. package/dist/types/components/apollo-data-scatter/apollo-data-scatter.stories.d.ts +5 -0
  68. package/dist/types/components/apollo-data-world-map/apollo-data-world-map.d.ts +281 -0
  69. package/dist/types/components/apollo-data-world-map/apollo-data-world-map.stories.d.ts +5 -0
  70. package/dist/types/components.d.ts +210 -4
  71. package/dist/types/examples/apollo-data-heat-map.examples.d.ts +11 -0
  72. package/dist/types/examples/apollo-data-line.examples.d.ts +12 -0
  73. package/dist/types/examples/apollo-data-scatter.examples.d.ts +11 -0
  74. package/dist/types/examples/apollo-data-world-map.examples.d.ts +11 -0
  75. package/dist/types/examples/index.d.ts +3 -0
  76. package/dist/types/stencil-public-runtime.d.ts +23 -2
  77. package/dist/types/utils/code-generator.d.ts +1 -3
  78. package/package.json +8 -8
  79. package/src/examples/apollo-data-bar.examples.ts +157 -157
  80. package/src/examples/apollo-data-heat-map.examples.ts +147 -0
  81. package/src/examples/apollo-data-line.examples.ts +103 -0
  82. package/src/examples/apollo-data-scatter.examples.ts +109 -0
  83. package/src/examples/apollo-data-world-map.examples.ts +57 -0
  84. package/src/examples/index.ts +4 -1
  85. package/dist/apollo-data/p-Bb2nY-Tf.js +0 -2
  86. package/dist/apollo-data/p-e6584598.entry.js +0 -11
  87. package/dist/components/p-7XF5Cax8.js +0 -11
  88. package/dist/components/p-Dws5s-Xe.js +0 -1
@@ -0,0 +1,122 @@
1
+ import { html } from "lit-html";
2
+ import { lineExamples } from "../../examples/apollo-data-line.examples";
3
+ import { generateReactCode, generateVueCode, generateWebComponentCode, generateInstallationDocs } from "../../utils/code-generator";
4
+ function getCodeForFramework(props, framework) {
5
+ switch (framework) {
6
+ case 'vue':
7
+ return generateVueCode('apollo-data-line-chart', props);
8
+ case 'webcomponent':
9
+ return generateWebComponentCode('apollo-data-line-chart', props);
10
+ case 'react':
11
+ default:
12
+ return generateReactCode('apollo-data-line-chart', props);
13
+ }
14
+ }
15
+ const meta = {
16
+ title: 'Apollo Data/Line Chart',
17
+ tags: ['autodocs'],
18
+ argTypes: {
19
+ adData: {
20
+ control: 'object',
21
+ description: 'Array of data items. Each item has category, xValue, yValue, and optional xLabel/yLabel. When labels are omitted, numeric values are shown on axes and tooltip.',
22
+ table: {
23
+ type: {
24
+ summary: 'LineDataItem[]',
25
+ detail: 'interface LineDataItem {\n category: string;\n xValue: number;\n yValue: number;\n xLabel?: string;\n yLabel?: string;\n}',
26
+ },
27
+ defaultValue: { summary: '[]' },
28
+ },
29
+ },
30
+ adSpec: {
31
+ control: 'object',
32
+ description: 'Specification object for customizing the chart appearance.',
33
+ table: {
34
+ type: {
35
+ summary: 'LineSpec',
36
+ detail: 'interface LineSpec {\n colorSet?: string[];\n tooltipPrefix?: string;\n currencySymbol?: string;\n yAxisTitle?: string;\n xAxisTitle?: string;\n pointStyle?: LinePointStyle;\n lineStyle?: LineLineStyle;\n}',
37
+ },
38
+ defaultValue: { summary: '{}' },
39
+ },
40
+ },
41
+ },
42
+ decorators: [
43
+ (story, context) => {
44
+ const framework = context.globals?.framework || 'react';
45
+ setTimeout(() => {
46
+ const doc = globalThis.document;
47
+ if (doc) {
48
+ const installSections = {
49
+ react: doc.querySelector('.install-react'),
50
+ vue: doc.querySelector('.install-vue'),
51
+ webcomponent: doc.querySelector('.install-webcomponent'),
52
+ };
53
+ Object.values(installSections).forEach((section) => {
54
+ if (section)
55
+ section.setAttribute('style', 'display: none;');
56
+ });
57
+ const selectedSection = installSections[framework];
58
+ if (selectedSection)
59
+ selectedSection.setAttribute('style', 'display: block;');
60
+ }
61
+ }, 0);
62
+ return story();
63
+ },
64
+ ],
65
+ parameters: {
66
+ docs: {
67
+ description: {
68
+ component: `${generateInstallationDocs('react', 'apollo-data-line-chart')}
69
+
70
+ ${generateInstallationDocs('vue', 'apollo-data-line-chart')}
71
+
72
+ ${generateInstallationDocs('webcomponent', 'apollo-data-line-chart')}
73
+
74
+ ---
75
+
76
+ ## Description
77
+
78
+ A multi-series line chart component built with Vega. Each data item has \`category\` (one line per category), \`xValue\` and \`yValue\` (numeric axes), and optional \`xLabel\`/\`yLabel\` for display; when labels are omitted, numeric values are shown. Use \`adSpec.xAxisTitle\`, \`adSpec.yAxisTitle\`, \`adSpec.pointStyle\`, and \`adSpec.lineStyle\` (\`'solid' | 'dashed' | 'dotted'\`) to customize the chart. The example uses the monthly sales by product preset from \`lineExamples\`.
79
+
80
+ **Tip:** Use the Framework selector in the toolbar to switch between React, Vue, and Web Component installation and code examples.`,
81
+ },
82
+ },
83
+ viewMode: 'story',
84
+ },
85
+ };
86
+ export default meta;
87
+ const chartWrapper = (args) => html `
88
+ <div style="width: 800px; height: 400px;">
89
+ <apollo-data-line-chart .adData=${args.adData} .adSpec=${args.adSpec}></apollo-data-line-chart>
90
+ </div>
91
+ `;
92
+ export const MonthlySalesByProduct = {
93
+ args: {
94
+ adData: lineExamples[1].props.adData,
95
+ adSpec: lineExamples[1].props.adSpec ?? {},
96
+ },
97
+ render: args => chartWrapper(args),
98
+ parameters: {
99
+ codeGenerator: (args, framework) => getCodeForFramework({ adData: args.adData ?? lineExamples[1].props.adData, adSpec: args.adSpec ?? lineExamples[1].props.adSpec ?? {} }, framework),
100
+ docs: {
101
+ description: { story: lineExamples[1].description },
102
+ source: {
103
+ language: 'tsx',
104
+ type: 'dynamic',
105
+ transform: (_code, storyContext) => {
106
+ try {
107
+ const framework = storyContext?.globals?.framework || 'react';
108
+ const props = {
109
+ adData: storyContext?.args?.adData ?? lineExamples[1].props.adData,
110
+ adSpec: storyContext?.args?.adSpec ?? lineExamples[1].props.adSpec ?? {},
111
+ };
112
+ return getCodeForFramework(props, framework);
113
+ }
114
+ catch (error) {
115
+ console.error('Error in transform function:', error);
116
+ return `<apollo-data-line-chart />`;
117
+ }
118
+ },
119
+ },
120
+ },
121
+ },
122
+ };
@@ -0,0 +1,329 @@
1
+ import { h, Host } from "@stencil/core";
2
+ import { ApolloBase } from "../../apollo-data-base";
3
+ export class ApolloDataScatterChart extends ApolloBase {
4
+ constructor() {
5
+ super();
6
+ }
7
+ el = null;
8
+ /**
9
+ * Represents a single data point in the scatter chart.
10
+ * @property {string} category - Category or group name associated with the data point.
11
+ * This can be used for legend grouping or category-based styling.
12
+ * @property {number} xValue - Numeric value plotted along the X-axis.
13
+ * @property {number} yValue - Numeric value plotted along the Y-axis.
14
+ * @property {PointStyle} [pointStyle] - Optional style override for this specific data point.
15
+ * If provided, it takes precedence over default or category-level styles.
16
+ */
17
+ adData = [];
18
+ /**
19
+ * Optional specification object for customizing the scatter chart configuration.
20
+ * @property {string} [yAxisTitle] - Label displayed for the Y-axis.
21
+ * @property {string} [xAxisTitle] - Label displayed for the X-axis.
22
+ * @property {PointStyle} [defaultPointStyle] - Default styling applied to all scatter points (e.g., size, color, shape, opacity).
23
+ * @property {PointStyle} [pointStyle] - Global point style override applied to all data points.
24
+ * @property {{ [categoryName: string]: PointStyle }} [categoryPointStyleMap] -
25
+ * A mapping object that allows custom point styles per category name.
26
+ * Each key represents a category, and its value defines the corresponding PointStyle.
27
+ * @property {'auto' | 'none'} [tooltip] - Controls tooltip behavior.
28
+ * 'auto' enables default tooltip rendering, while 'none' disables tooltips.
29
+ */
30
+ adSpec = {};
31
+ async componentDidRender() {
32
+ await this.renderChart();
33
+ }
34
+ DEFAULT_POINT_STYLE = {
35
+ shape: 'circle',
36
+ opacity: 1,
37
+ color: 'blue',
38
+ size: 1,
39
+ };
40
+ // @ts-ignore
41
+ async getViewData(data, spec) {
42
+ const dataItemsToUse = data.map(dataItem => {
43
+ const pointStylesToUse = {};
44
+ Object.keys(this.DEFAULT_POINT_STYLE).forEach(key => {
45
+ const value = dataItem.pointStyle?.[key] ??
46
+ dataItem?.[key] ??
47
+ spec.categoryPointStyleMap?.[dataItem.category]?.[key] ??
48
+ spec.defaultPointStyle?.[key] ??
49
+ this.DEFAULT_POINT_STYLE[key];
50
+ pointStylesToUse[key] = value;
51
+ });
52
+ return {
53
+ category: dataItem.category,
54
+ xValue: dataItem.xValue,
55
+ yValue: dataItem.yValue,
56
+ color: pointStylesToUse.color,
57
+ shape: pointStylesToUse.shape,
58
+ opacity: pointStylesToUse.opacity,
59
+ };
60
+ });
61
+ const tooltipField = spec?.tooltip === 'auto' ? 'category' : 'none';
62
+ return {
63
+ $schema: 'https://vega.github.io/schema/vega/v6.json',
64
+ description: 'A scatter plot with null values visualized along the axes.',
65
+ width: 450,
66
+ height: 450,
67
+ padding: 5,
68
+ autosize: { type: 'fit', resize: true },
69
+ signals: [
70
+ { name: 'nullSize', value: 8 },
71
+ { name: 'nullGap', update: 'nullSize + 10' },
72
+ ],
73
+ data: [
74
+ {
75
+ name: 'source',
76
+ values: dataItemsToUse,
77
+ },
78
+ {
79
+ name: 'valid',
80
+ source: 'source',
81
+ transform: [
82
+ {
83
+ type: 'filter',
84
+ expr: 'datum.xValue != null && datum.yValue != null',
85
+ },
86
+ ],
87
+ },
88
+ {
89
+ name: 'nullXY',
90
+ source: 'source',
91
+ transform: [
92
+ {
93
+ type: 'filter',
94
+ expr: 'datum.xValue == null && datum.yValue == null',
95
+ },
96
+ { type: 'aggregate' },
97
+ ],
98
+ },
99
+ {
100
+ name: 'nullY',
101
+ source: 'source',
102
+ transform: [
103
+ {
104
+ type: 'filter',
105
+ expr: 'datum.xValue != null && datum.yValue == null',
106
+ },
107
+ ],
108
+ },
109
+ {
110
+ name: 'nullX',
111
+ source: 'source',
112
+ transform: [
113
+ {
114
+ type: 'filter',
115
+ expr: 'datum.xValue == null && datum.yValue != null',
116
+ },
117
+ ],
118
+ },
119
+ ],
120
+ scales: [
121
+ {
122
+ name: 'xscale',
123
+ type: 'linear',
124
+ range: [{ signal: 'nullGap' }, { signal: 'width' }],
125
+ nice: true,
126
+ domain: { data: 'valid', field: 'xValue' },
127
+ },
128
+ {
129
+ name: 'yscale',
130
+ type: 'linear',
131
+ range: [{ signal: 'height - nullGap' }, 0],
132
+ nice: true,
133
+ domain: { data: 'valid', field: 'yValue' },
134
+ },
135
+ ],
136
+ axes: [
137
+ {
138
+ orient: 'bottom',
139
+ scale: 'xscale',
140
+ offset: 5,
141
+ format: 's',
142
+ title: spec?.xAxisTitle || 'X Value',
143
+ },
144
+ {
145
+ orient: 'left',
146
+ scale: 'yscale',
147
+ offset: 5,
148
+ format: 's',
149
+ title: spec?.yAxisTitle || 'Y Value',
150
+ },
151
+ ],
152
+ marks: [
153
+ {
154
+ type: 'symbol',
155
+ from: { data: 'valid' },
156
+ encode: {
157
+ enter: {
158
+ size: { value: 50 },
159
+ tooltip: { field: tooltipField },
160
+ },
161
+ update: {
162
+ x: { scale: 'xscale', field: 'xValue' },
163
+ y: { scale: 'yscale', field: 'yValue' },
164
+ fill: { field: 'color' },
165
+ fillOpacity: { field: 'opacity' },
166
+ shape: { field: 'shape' },
167
+ zindex: { value: 0 },
168
+ },
169
+ hover: {
170
+ fill: { value: 'firebrick' },
171
+ fillOpacity: { value: 1 },
172
+ zindex: { value: 1 },
173
+ },
174
+ },
175
+ },
176
+ {
177
+ type: 'symbol',
178
+ from: { data: 'nullY' },
179
+ encode: {
180
+ enter: {
181
+ size: { value: 50 },
182
+ tooltip: { field: tooltipField },
183
+ },
184
+ update: {
185
+ x: { scale: 'xscale', field: 'xValue' },
186
+ y: { signal: 'height - nullSize/2' },
187
+ fill: { value: '#aaa' },
188
+ fillOpacity: { value: 0.2 },
189
+ },
190
+ hover: {
191
+ fill: { value: 'firebrick' },
192
+ fillOpacity: { value: 1 },
193
+ },
194
+ },
195
+ },
196
+ {
197
+ type: 'symbol',
198
+ from: { data: 'nullX' },
199
+ encode: {
200
+ enter: {
201
+ size: { value: 50 },
202
+ tooltip: { field: 'name' },
203
+ },
204
+ update: {
205
+ x: { signal: 'nullSize/2' },
206
+ y: { scale: 'yscale', field: 'yValue' },
207
+ fill: { value: '#aaa' },
208
+ fillOpacity: { value: 0.2 },
209
+ zindex: { value: 0 },
210
+ },
211
+ hover: {
212
+ fill: { value: 'firebrick' },
213
+ fillOpacity: { value: 1 },
214
+ zindex: { value: 1 },
215
+ },
216
+ },
217
+ },
218
+ {
219
+ type: 'text',
220
+ interactive: false,
221
+ from: { data: 'nullXY' },
222
+ encode: {
223
+ update: {
224
+ x: { signal: 'nullSize', offset: -4 },
225
+ y: { signal: 'height', offset: 13 },
226
+ text: { signal: "datum.count + ' null'" },
227
+ align: { value: 'right' },
228
+ baseline: { value: 'top' },
229
+ fill: { value: '#999' },
230
+ fontSize: { value: 9 },
231
+ },
232
+ },
233
+ },
234
+ ],
235
+ };
236
+ }
237
+ render() {
238
+ return (h(Host, { key: 'f6c1e8d9e9a6ba41dbbf8c2c5737895b96b0915d' }, h("div", { key: '2aeba82bc31c5995a3d5b532c339f5b45ae850f7', id: "container", style: { width: '100%', height: '100%' } })));
239
+ }
240
+ static get is() { return "apollo-data-scatter-chart"; }
241
+ static get encapsulation() { return "shadow"; }
242
+ static get properties() {
243
+ return {
244
+ "adData": {
245
+ "type": "string",
246
+ "mutable": false,
247
+ "complexType": {
248
+ "original": "string | ScatterDataItem[]",
249
+ "resolved": "ScatterDataItem[] | string",
250
+ "references": {
251
+ "ScatterDataItem": {
252
+ "location": "local",
253
+ "path": "/home/runner/work/apollo/apollo/packages/apollo-data/src/components/apollo-data-scatter/apollo-data-scatter.tsx",
254
+ "id": "src/components/apollo-data-scatter/apollo-data-scatter.tsx::ScatterDataItem"
255
+ }
256
+ }
257
+ },
258
+ "required": false,
259
+ "optional": false,
260
+ "docs": {
261
+ "tags": [{
262
+ "name": "property",
263
+ "text": "{string} category - Category or group name associated with the data point.\nThis can be used for legend grouping or category-based styling."
264
+ }, {
265
+ "name": "property",
266
+ "text": "{number} xValue - Numeric value plotted along the X-axis."
267
+ }, {
268
+ "name": "property",
269
+ "text": "{number} yValue - Numeric value plotted along the Y-axis."
270
+ }, {
271
+ "name": "property",
272
+ "text": "{PointStyle} [pointStyle] - Optional style override for this specific data point.\nIf provided, it takes precedence over default or category-level styles."
273
+ }],
274
+ "text": "Represents a single data point in the scatter chart."
275
+ },
276
+ "getter": false,
277
+ "setter": false,
278
+ "reflect": false,
279
+ "attribute": "ad-data",
280
+ "defaultValue": "[]"
281
+ },
282
+ "adSpec": {
283
+ "type": "string",
284
+ "mutable": false,
285
+ "complexType": {
286
+ "original": "string | ScatterSpec",
287
+ "resolved": "ScatterSpec | string",
288
+ "references": {
289
+ "ScatterSpec": {
290
+ "location": "local",
291
+ "path": "/home/runner/work/apollo/apollo/packages/apollo-data/src/components/apollo-data-scatter/apollo-data-scatter.tsx",
292
+ "id": "src/components/apollo-data-scatter/apollo-data-scatter.tsx::ScatterSpec"
293
+ }
294
+ }
295
+ },
296
+ "required": false,
297
+ "optional": false,
298
+ "docs": {
299
+ "tags": [{
300
+ "name": "property",
301
+ "text": "{string} [yAxisTitle] - Label displayed for the Y-axis."
302
+ }, {
303
+ "name": "property",
304
+ "text": "{string} [xAxisTitle] - Label displayed for the X-axis."
305
+ }, {
306
+ "name": "property",
307
+ "text": "{PointStyle} [defaultPointStyle] - Default styling applied to all scatter points (e.g., size, color, shape, opacity)."
308
+ }, {
309
+ "name": "property",
310
+ "text": "{PointStyle} [pointStyle] - Global point style override applied to all data points."
311
+ }, {
312
+ "name": "property",
313
+ "text": "{{ [categoryName: string]: PointStyle }} [categoryPointStyleMap] -\nA mapping object that allows custom point styles per category name.\nEach key represents a category, and its value defines the corresponding PointStyle."
314
+ }, {
315
+ "name": "property",
316
+ "text": "{'auto' | 'none'} [tooltip] - Controls tooltip behavior.\n'auto' enables default tooltip rendering, while 'none' disables tooltips."
317
+ }],
318
+ "text": "Optional specification object for customizing the scatter chart configuration."
319
+ },
320
+ "getter": false,
321
+ "setter": false,
322
+ "reflect": false,
323
+ "attribute": "ad-spec",
324
+ "defaultValue": "{}"
325
+ }
326
+ };
327
+ }
328
+ static get elementRef() { return "el"; }
329
+ }
@@ -0,0 +1,147 @@
1
+ import { html } from "lit-html";
2
+ import { generateReactCode, generateVueCode, generateWebComponentCode, generateInstallationDocs } from "../../utils/code-generator";
3
+ import { scatterExamples } from "../../examples/apollo-data-scatter.examples";
4
+ // Helper function to generate code based on framework
5
+ function getCodeForFramework(props, framework) {
6
+ switch (framework) {
7
+ case 'vue':
8
+ return generateVueCode('apollo-data-scatter-chart', props);
9
+ case 'webcomponent':
10
+ return generateWebComponentCode('apollo-data-scatter-chart', props);
11
+ case 'react':
12
+ default:
13
+ return generateReactCode('apollo-data-scatter-chart', props);
14
+ }
15
+ }
16
+ const metaDetail = `interface ScatterDataItem {
17
+ category: string;
18
+ xValue: number;
19
+ yValue: number;
20
+ pointStyle?: PointStyle;
21
+ }`;
22
+ const meta = {
23
+ title: 'Apollo Data/Scatter Chart',
24
+ tags: ['autodocs'],
25
+ argTypes: {
26
+ adData: {
27
+ control: 'object',
28
+ description: 'Array of data items to display in the scatter chart. Each item represents a single plotted point defined by its category, xValue, and yValue.',
29
+ table: {
30
+ type: {
31
+ summary: 'ScatterDataItem[]',
32
+ detail: metaDetail,
33
+ },
34
+ defaultValue: { summary: '[]' },
35
+ },
36
+ },
37
+ adSpec: {
38
+ control: 'object',
39
+ description: 'Optional specification object for customizing the scatter chart appearance, including axis titles, point styling, category-based styling, and tooltip behavior.',
40
+ table: {
41
+ type: {
42
+ summary: 'ScatterSpec',
43
+ detail: 'interface ScatterSpec {\n' +
44
+ ' yAxisTitle?: string;\n' +
45
+ ' xAxisTitle?: string;\n' +
46
+ ' defaultPointStyle?: PointStyle;\n' +
47
+ ' pointStyle?: PointStyle;\n' +
48
+ ' categoryPointStyleMap?: {\n' +
49
+ ' [categoryName: string]: PointStyle;\n' +
50
+ ' };\n' +
51
+ " tooltip?: 'auto' | 'none';\n" +
52
+ '}',
53
+ },
54
+ defaultValue: { summary: '{}' },
55
+ },
56
+ },
57
+ },
58
+ decorators: [
59
+ (story, context) => {
60
+ const framework = context.globals?.framework || 'react';
61
+ // Update visibility of installation sections when framework changes
62
+ setTimeout(() => {
63
+ const doc = globalThis.document;
64
+ if (doc) {
65
+ const installSections = {
66
+ react: doc.querySelector('.install-react'),
67
+ vue: doc.querySelector('.install-vue'),
68
+ webcomponent: doc.querySelector('.install-webcomponent'),
69
+ };
70
+ // Hide all sections first
71
+ Object.values(installSections).forEach((section) => {
72
+ if (section) {
73
+ section.setAttribute('style', 'display: none;');
74
+ }
75
+ });
76
+ // Show only the selected framework
77
+ const selectedSection = installSections[framework];
78
+ if (selectedSection) {
79
+ selectedSection.setAttribute('style', 'display: block;');
80
+ }
81
+ }
82
+ }, 0);
83
+ return story();
84
+ },
85
+ ],
86
+ parameters: {
87
+ docs: {
88
+ description: {
89
+ component: `${generateInstallationDocs('react', 'apollo-data-scatter-chart')}
90
+
91
+ ${generateInstallationDocs('vue', 'apollo-data-scatter-chart')}
92
+
93
+ ${generateInstallationDocs('webcomponent', 'apollo-data-scatter-chart')}
94
+
95
+ ---
96
+
97
+ ## Description
98
+
99
+ AA Scatter Chart is used to visualize the relationship between two numeric variables by plotting individual data points on a two-dimensional plane. Each point represents a single data item, positioned based on its xValue and yValue.
100
+
101
+ **Tip:** Use the Framework selector in the toolbar above to switch between React, Vue, and Web Component installation instructions and code examples.`,
102
+ },
103
+ },
104
+ viewMode: 'story',
105
+ },
106
+ };
107
+ export default meta;
108
+ // Single interactive story
109
+ export const ApolloDataScatter = {
110
+ args: {
111
+ adData: scatterExamples[0].props.adData,
112
+ adSpec: scatterExamples[0].props.adSpec || {},
113
+ },
114
+ render: args => html `
115
+ <div style="width: 600px; height: 400px;">
116
+ <apollo-data-scatter-chart .adData=${args.adData} .adSpec=${args.adSpec}></apollo-data-scatter-chart>
117
+ </div>
118
+ `,
119
+ parameters: {
120
+ // Code generator function for the Code addon panel
121
+ codeGenerator: (args, framework) => getCodeForFramework(args, framework),
122
+ docs: {
123
+ description: {
124
+ story: 'Interactive scatter chart. Modify the data and spec using the controls below, switch between React, Vue, or Web Component using the Framework selector in the toolbar, and view the generated code in the Code tab.',
125
+ },
126
+ source: {
127
+ language: 'tsx',
128
+ type: 'dynamic',
129
+ transform: (_code, storyContext) => {
130
+ try {
131
+ const framework = storyContext?.globals?.framework || 'react';
132
+ const props = {
133
+ adData: storyContext?.args?.adData || [],
134
+ adSpec: storyContext?.args?.adSpec || {},
135
+ };
136
+ return getCodeForFramework(props, framework);
137
+ }
138
+ catch (error) {
139
+ // eslint-disable-next-line no-console
140
+ console.error('Error in transform function:', error);
141
+ return `<apollo-data-scatter-chart />`;
142
+ }
143
+ },
144
+ },
145
+ },
146
+ },
147
+ };