@xplortech/apollo-data 0.0.5 → 0.0.7

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 (84) 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-4d3f0792.entry.js +1 -0
  4. package/dist/apollo-data/p-C2k3WBpi.js +11 -0
  5. package/dist/apollo-data/p-D64asVrg.js +2 -0
  6. package/dist/apollo-data/{p-b7471c12.entry.js → p-e2c3a317.entry.js} +1 -1
  7. package/dist/cjs/apollo-data-bar-chart_5.cjs.entry.js +1193 -0
  8. package/dist/cjs/{apollo-data-base-CxVQ-WVP.js → apollo-data-base-COGMOEqL.js} +7 -11
  9. package/dist/cjs/apollo-data-donut-chart.cjs.entry.js +3 -3
  10. package/dist/cjs/apollo-data.cjs.js +3 -3
  11. package/dist/cjs/{index-Cl7HgRm0.js → index-Bd5risOy.js} +116 -63
  12. package/dist/cjs/loader.cjs.js +2 -2
  13. package/dist/collection/apollo-data-base.js +4 -8
  14. package/dist/collection/collection-manifest.json +5 -2
  15. package/dist/collection/components/apollo-data-bar/apollo-data-bar.js +10 -9
  16. package/dist/collection/components/apollo-data-bar/apollo-data-bar.stories.js +122 -0
  17. package/dist/collection/components/apollo-data-donut/apollo-data-donut.js +1 -1
  18. package/dist/collection/components/apollo-data-donut/apollo-data-donut.stories.js +132 -0
  19. package/dist/collection/components/apollo-data-heat-map/apollo-data-heat-map.js +208 -0
  20. package/dist/collection/components/apollo-data-heat-map/apollo-data-heat-map.stories.js +137 -0
  21. package/dist/collection/components/apollo-data-line/apollo-data-line.js +8 -6
  22. package/dist/collection/components/apollo-data-line/apollo-data-line.stories.js +122 -0
  23. package/dist/collection/components/apollo-data-scatter/apollo-data-scatter.js +1 -1
  24. package/dist/collection/components/apollo-data-scatter/apollo-data-scatter.stories.js +147 -0
  25. package/dist/collection/components/apollo-data-world-map/apollo-data-world-map.js +294 -0
  26. package/dist/collection/components/apollo-data-world-map/apollo-data-world-map.stories.js +126 -0
  27. package/dist/collection/examples/apollo-data-heat-map.examples.js +131 -0
  28. package/dist/collection/examples/apollo-data-world-map.examples.js +45 -0
  29. package/dist/collection/examples/index.js +2 -0
  30. package/dist/collection/utils/code-generator.js +1 -1
  31. package/dist/components/apollo-data-bar-chart.js +1 -1
  32. package/dist/components/apollo-data-donut-chart.js +1 -1
  33. package/dist/components/apollo-data-heat-map.d.ts +11 -0
  34. package/dist/components/apollo-data-heat-map.js +1 -0
  35. package/dist/components/apollo-data-line-chart.js +1 -1
  36. package/dist/components/apollo-data-scatter-chart.js +1 -1
  37. package/dist/components/apollo-data-world-map-chart.d.ts +11 -0
  38. package/dist/components/apollo-data-world-map-chart.js +1 -0
  39. package/dist/components/index.js +1 -1
  40. package/dist/components/p-CfbMSXKd.js +11 -0
  41. package/dist/components/p-gcjU8DVr.js +1 -0
  42. package/dist/esm/apollo-data-bar-chart_5.entry.js +1187 -0
  43. package/dist/esm/{apollo-data-base-BWkrM8dc.js → apollo-data-base-C2k3WBpi.js} +7 -11
  44. package/dist/esm/apollo-data-donut-chart.entry.js +3 -3
  45. package/dist/esm/apollo-data.js +4 -4
  46. package/dist/esm/{index-Bb2nY-Tf.js → index-D64asVrg.js} +116 -63
  47. package/dist/esm/loader.js +3 -3
  48. package/dist/types/apollo-data-base.d.ts +2 -2
  49. package/dist/types/components/apollo-data-bar/apollo-data-bar.stories.d.ts +5 -0
  50. package/dist/types/components/apollo-data-donut/apollo-data-donut.stories.d.ts +5 -0
  51. package/dist/types/components/apollo-data-heat-map/apollo-data-heat-map.d.ts +140 -0
  52. package/dist/types/components/apollo-data-heat-map/apollo-data-heat-map.stories.d.ts +5 -0
  53. package/dist/types/components/apollo-data-line/apollo-data-line.stories.d.ts +5 -0
  54. package/dist/types/components/apollo-data-scatter/apollo-data-scatter.d.ts +1 -3
  55. package/dist/types/components/apollo-data-scatter/apollo-data-scatter.stories.d.ts +5 -0
  56. package/dist/types/components/apollo-data-world-map/apollo-data-world-map.d.ts +281 -0
  57. package/dist/types/components/apollo-data-world-map/apollo-data-world-map.stories.d.ts +5 -0
  58. package/dist/types/components.d.ts +128 -8
  59. package/dist/types/examples/apollo-data-heat-map.examples.d.ts +11 -0
  60. package/dist/types/examples/apollo-data-scatter.examples.d.ts +1 -1
  61. package/dist/types/examples/apollo-data-world-map.examples.d.ts +11 -0
  62. package/dist/types/examples/index.d.ts +2 -0
  63. package/dist/types/stencil-public-runtime.d.ts +23 -2
  64. package/dist/types/utils/code-generator.d.ts +1 -3
  65. package/package.json +8 -8
  66. package/src/examples/apollo-data-bar.examples.ts +157 -157
  67. package/src/examples/apollo-data-heat-map.examples.ts +147 -0
  68. package/src/examples/apollo-data-line.examples.ts +91 -91
  69. package/src/examples/apollo-data-scatter.examples.ts +1 -1
  70. package/src/examples/apollo-data-world-map.examples.ts +57 -0
  71. package/src/examples/index.ts +3 -1
  72. package/dist/apollo-data/p-2nuV5Vny.js +0 -1
  73. package/dist/apollo-data/p-4ac3c97c.entry.js +0 -1
  74. package/dist/apollo-data/p-BWkrM8dc.js +0 -11
  75. package/dist/apollo-data/p-Bb2nY-Tf.js +0 -2
  76. package/dist/apollo-data/p-e518baac.entry.js +0 -1
  77. package/dist/cjs/apollo-data-bar-chart.cjs.entry.js +0 -314
  78. package/dist/cjs/apollo-data-line-chart_2.cjs.entry.js +0 -534
  79. package/dist/cjs/constants-B3weDEpc.js +0 -5
  80. package/dist/components/p-7XF5Cax8.js +0 -11
  81. package/dist/components/p-Dws5s-Xe.js +0 -1
  82. package/dist/esm/apollo-data-bar-chart.entry.js +0 -312
  83. package/dist/esm/apollo-data-line-chart_2.entry.js +0 -531
  84. package/dist/esm/constants-2nuV5Vny.js +0 -3
@@ -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
+ };
@@ -0,0 +1,294 @@
1
+ import { h, Host } from "@stencil/core";
2
+ import { ApolloBase } from "../../apollo-data-base";
3
+ export class ApolloDataWorldMapChart extends ApolloBase {
4
+ constructor() {
5
+ super();
6
+ }
7
+ el = null;
8
+ /**
9
+ * Represents a single data point in the world map chart.
10
+ * @property {number} lon - Longitude coordinate used to position the point on the map.
11
+ * @property {number} lat - Latitude coordinate used to position the point on the map.
12
+ * @property {number} value - A numeric metric tied to the point.
13
+ * @property {string} label - Label displayed for the place or location represented by the point.
14
+ */
15
+ adData = [];
16
+ /**
17
+ * @property {string} pinColor - Color of the pin representing the point.
18
+ * @property {'circle' | 'square' | 'triangle'} pinShape - Shape of the pin representing the point.
19
+ */
20
+ adSpec = {};
21
+ async componentDidRender() {
22
+ await this.renderChart();
23
+ }
24
+ // @ts-ignore
25
+ // eslint-disable-next-line class-methods-use-this
26
+ async getViewData(data, spec) {
27
+ const pinColor = spec?.pinColor || '#d3544b';
28
+ const pinShape = spec?.pinShape || 'circle';
29
+ return {
30
+ $schema: 'https://vega.github.io/schema/vega/v6.json',
31
+ description: 'World map + tooltip + points.',
32
+ width: 600,
33
+ height: 400,
34
+ autosize: 'none',
35
+ background: '#cfe3f1',
36
+ signals: [
37
+ {
38
+ name: 'scale',
39
+ value: 85,
40
+ on: [
41
+ {
42
+ events: { type: 'wheel', consume: true },
43
+ update: 'clamp(scale * pow(1.002, -event.deltaY), 85, 2000)',
44
+ },
45
+ ],
46
+ },
47
+ {
48
+ name: 'xc',
49
+ value: 0,
50
+ on: [{ events: 'mousedown', update: 'x()' }],
51
+ },
52
+ {
53
+ name: 'yc',
54
+ value: 0,
55
+ on: [{ events: 'mousedown', update: 'y()' }],
56
+ },
57
+ {
58
+ name: 'xo',
59
+ value: 300,
60
+ on: [{ events: 'mousedown', update: 'tx' }],
61
+ },
62
+ {
63
+ name: 'yo',
64
+ value: 175,
65
+ on: [{ events: 'mousedown', update: 'ty' }],
66
+ },
67
+ {
68
+ name: 'tx',
69
+ value: 300,
70
+ on: [
71
+ {
72
+ events: '[mousedown, window:mouseup] > window:mousemove',
73
+ update: 'xo - (x() - xc)',
74
+ },
75
+ ],
76
+ },
77
+ {
78
+ name: 'ty',
79
+ value: 270,
80
+ on: [
81
+ {
82
+ events: '[mousedown, window:mouseup] > window:mousemove',
83
+ update: 'clamp(yo + y() - yc, -scale * 0.5, scale * 2.5 + height)',
84
+ },
85
+ ],
86
+ },
87
+ ],
88
+ projections: [
89
+ {
90
+ name: 'projection',
91
+ type: 'mercator',
92
+ scale: { signal: 'scale' },
93
+ rotate: [{ signal: '-(tx - width / 2) * 180 / (scale * PI)' }, 0, 0],
94
+ center: [0, 0],
95
+ translate: [{ signal: 'width / 2' }, { signal: 'ty' }],
96
+ },
97
+ ],
98
+ data: [
99
+ {
100
+ name: 'names',
101
+ url: 'https://raw.githubusercontent.com/KoGor/Map-Icons-Generator/master/data/world-110m-country-names.tsv',
102
+ format: { type: 'tsv' },
103
+ transform: [{ type: 'formula', as: 'id', expr: 'toNumber(datum.id)' }],
104
+ },
105
+ {
106
+ name: 'metrics',
107
+ values: data,
108
+ },
109
+ {
110
+ name: 'world',
111
+ url: 'https://vega.github.io/editor/data/world-110m.json',
112
+ format: { type: 'topojson', feature: 'countries' },
113
+ transform: [
114
+ {
115
+ type: 'lookup',
116
+ from: 'names',
117
+ key: 'id',
118
+ fields: ['id'],
119
+ values: ['name'],
120
+ as: ['name'],
121
+ },
122
+ { type: 'filter', expr: "datum.name != 'Antarctica'" },
123
+ ],
124
+ },
125
+ {
126
+ name: 'points',
127
+ source: 'metrics',
128
+ transform: [
129
+ { type: 'filter', expr: 'isValid(datum.lon) && isValid(datum.lat)' },
130
+ {
131
+ type: 'geopoint',
132
+ projection: 'projection',
133
+ fields: ['lon', 'lat'],
134
+ as: ['x', 'y'],
135
+ },
136
+ ],
137
+ },
138
+ {
139
+ name: 'continentLabels',
140
+ values: [
141
+ { name: 'North America', lon: -105, lat: 45 },
142
+ { name: 'South America', lon: -60, lat: -15 },
143
+ { name: 'Europe', lon: 15, lat: 52 },
144
+ { name: 'Africa', lon: 20, lat: 5 },
145
+ { name: 'Asia', lon: 90, lat: 35 },
146
+ { name: 'Oceania', lon: 135, lat: -25 },
147
+ ],
148
+ transform: [
149
+ {
150
+ type: 'geopoint',
151
+ projection: 'projection',
152
+ fields: ['lon', 'lat'],
153
+ as: ['x', 'y'],
154
+ },
155
+ ],
156
+ },
157
+ ],
158
+ marks: [
159
+ {
160
+ type: 'shape',
161
+ from: { data: 'world' },
162
+ transform: [{ type: 'geoshape', projection: 'projection' }],
163
+ encode: {
164
+ update: {
165
+ fill: { value: '#8fbf8f' },
166
+ stroke: { value: '#6c8c8c' },
167
+ strokeWidth: { value: 0.7 },
168
+ tooltip: { signal: "{Country: datum.name ? datum.name : 'Unknown'}" },
169
+ },
170
+ hover: {
171
+ stroke: { value: '#2b3a42' },
172
+ strokeWidth: { value: 1.3 },
173
+ },
174
+ },
175
+ },
176
+ {
177
+ type: 'symbol',
178
+ from: { data: 'points' },
179
+ encode: {
180
+ update: {
181
+ x: { field: 'x' },
182
+ y: { field: 'y' },
183
+ size: { value: 80 },
184
+ fill: { value: pinColor },
185
+ stroke: { value: 'white' },
186
+ shape: { value: pinShape },
187
+ strokeWidth: { value: 1 },
188
+ tooltip: {
189
+ signal: '{Label: datum.label, Value: datum.value, Latitude: datum.lat, Longitude: datum.lon}',
190
+ },
191
+ },
192
+ },
193
+ },
194
+ {
195
+ type: 'text',
196
+ from: { data: 'continentLabels' },
197
+ encode: {
198
+ update: {
199
+ x: { field: 'x' },
200
+ y: { field: 'y' },
201
+ text: { field: 'name' },
202
+ align: { value: 'center' },
203
+ baseline: { value: 'middle' },
204
+ fontSize: { value: 12 },
205
+ fontWeight: { value: '600' },
206
+ fill: { value: '#2b3a42' },
207
+ fillOpacity: { value: 0.5 },
208
+ },
209
+ },
210
+ },
211
+ ],
212
+ };
213
+ }
214
+ render() {
215
+ return (h(Host, { key: '8053ea3b9706cdd03a430157b3f63e93c1201d1f' }, h("div", { key: '514807ae8dd4868d3d74e86c4260b7b9967c0ac2', id: "container", style: { width: '100%', height: '100%' } })));
216
+ }
217
+ static get is() { return "apollo-data-world-map-chart"; }
218
+ static get encapsulation() { return "shadow"; }
219
+ static get properties() {
220
+ return {
221
+ "adData": {
222
+ "type": "string",
223
+ "mutable": false,
224
+ "complexType": {
225
+ "original": "string | WorldMapDataItem[]",
226
+ "resolved": "WorldMapDataItem[] | string",
227
+ "references": {
228
+ "WorldMapDataItem": {
229
+ "location": "local",
230
+ "path": "/home/runner/work/apollo/apollo/packages/apollo-data/src/components/apollo-data-world-map/apollo-data-world-map.tsx",
231
+ "id": "src/components/apollo-data-world-map/apollo-data-world-map.tsx::WorldMapDataItem"
232
+ }
233
+ }
234
+ },
235
+ "required": false,
236
+ "optional": false,
237
+ "docs": {
238
+ "tags": [{
239
+ "name": "property",
240
+ "text": "{number} lon - Longitude coordinate used to position the point on the map."
241
+ }, {
242
+ "name": "property",
243
+ "text": "{number} lat - Latitude coordinate used to position the point on the map."
244
+ }, {
245
+ "name": "property",
246
+ "text": "{number} value - A numeric metric tied to the point."
247
+ }, {
248
+ "name": "property",
249
+ "text": "{string} label - Label displayed for the place or location represented by the point."
250
+ }],
251
+ "text": "Represents a single data point in the world map chart."
252
+ },
253
+ "getter": false,
254
+ "setter": false,
255
+ "reflect": false,
256
+ "attribute": "ad-data",
257
+ "defaultValue": "[]"
258
+ },
259
+ "adSpec": {
260
+ "type": "string",
261
+ "mutable": false,
262
+ "complexType": {
263
+ "original": "string | WorldMapSpec",
264
+ "resolved": "WorldMapSpec | string",
265
+ "references": {
266
+ "WorldMapSpec": {
267
+ "location": "local",
268
+ "path": "/home/runner/work/apollo/apollo/packages/apollo-data/src/components/apollo-data-world-map/apollo-data-world-map.tsx",
269
+ "id": "src/components/apollo-data-world-map/apollo-data-world-map.tsx::WorldMapSpec"
270
+ }
271
+ }
272
+ },
273
+ "required": false,
274
+ "optional": false,
275
+ "docs": {
276
+ "tags": [{
277
+ "name": "property",
278
+ "text": "{string} pinColor - Color of the pin representing the point."
279
+ }, {
280
+ "name": "property",
281
+ "text": "{'circle' | 'square' | 'triangle'} pinShape - Shape of the pin representing the point."
282
+ }],
283
+ "text": ""
284
+ },
285
+ "getter": false,
286
+ "setter": false,
287
+ "reflect": false,
288
+ "attribute": "ad-spec",
289
+ "defaultValue": "{}"
290
+ }
291
+ };
292
+ }
293
+ static get elementRef() { return "el"; }
294
+ }
@@ -0,0 +1,126 @@
1
+ import { html } from "lit-html";
2
+ import { worldMapExamples } from "../../examples/apollo-data-world-map.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-world-map-chart', props);
8
+ case 'webcomponent':
9
+ return generateWebComponentCode('apollo-data-world-map-chart', props);
10
+ case 'react':
11
+ default:
12
+ return generateReactCode('apollo-data-world-map-chart', props);
13
+ }
14
+ }
15
+ const meta = {
16
+ title: 'Apollo Data/World Map Chart',
17
+ tags: ['autodocs'],
18
+ argTypes: {
19
+ adData: {
20
+ control: 'object',
21
+ description: 'Array of map data items. Each item contains geographic coordinates (lon/lat), a label, and a value displayed in the tooltip.',
22
+ table: {
23
+ type: {
24
+ summary: 'WorldMapDataItem[]',
25
+ detail: 'interface WorldMapDataItem {\n lon: number;\n lat: number;\n value: number;\n label: string;\n}',
26
+ },
27
+ defaultValue: { summary: '[]' },
28
+ },
29
+ },
30
+ adSpec: {
31
+ control: 'object',
32
+ description: 'Optional specification object for world map customization (for example pin color and pin shape).',
33
+ table: {
34
+ type: {
35
+ summary: 'WorldMapSpec',
36
+ detail: "interface WorldMapSpec {\n pinColor?: string;\n pinShape?: 'circle' | 'square' | 'triangle';\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
+ });
58
+ const selectedSection = installSections[framework];
59
+ if (selectedSection) {
60
+ selectedSection.setAttribute('style', 'display: block;');
61
+ }
62
+ }
63
+ }, 0);
64
+ return story();
65
+ },
66
+ ],
67
+ parameters: {
68
+ docs: {
69
+ description: {
70
+ component: `${generateInstallationDocs('react', 'apollo-data-world-map-chart')}
71
+
72
+ ${generateInstallationDocs('vue', 'apollo-data-world-map-chart')}
73
+
74
+ ${generateInstallationDocs('webcomponent', 'apollo-data-world-map-chart')}
75
+
76
+ ---
77
+
78
+ ## Description
79
+
80
+ A world map chart component built with Vega that renders countries with interactive city markers using longitude and latitude coordinates.
81
+
82
+ **Tip:** Use the Framework selector in the toolbar above to switch between React, Vue, and Web Component installation instructions and code examples.`,
83
+ },
84
+ },
85
+ viewMode: 'story',
86
+ },
87
+ };
88
+ export default meta;
89
+ const chartWrapper = (args) => html `
90
+ <div style="width: 800px; height: 460px;">
91
+ <apollo-data-world-map-chart .adData=${args.adData} .adSpec=${args.adSpec}></apollo-data-world-map-chart>
92
+ </div>
93
+ `;
94
+ export const ApolloDataWorldMap = {
95
+ args: {
96
+ adData: worldMapExamples[0].props.adData,
97
+ adSpec: { ...(worldMapExamples[0].props.adSpec || {}), pinShape: 'circle' },
98
+ },
99
+ render: args => chartWrapper(args),
100
+ parameters: {
101
+ codeGenerator: (args, framework) => getCodeForFramework(args, framework),
102
+ docs: {
103
+ description: {
104
+ story: 'Interactive world map chart. Modify **adData** and **adSpec** in the controls, switch frameworks from the toolbar, and view generated usage code in the Code tab.',
105
+ },
106
+ source: {
107
+ language: 'tsx',
108
+ type: 'dynamic',
109
+ transform: (_code, storyContext) => {
110
+ try {
111
+ const framework = storyContext?.globals?.framework || 'react';
112
+ const props = {
113
+ adData: storyContext?.args?.adData || [],
114
+ adSpec: storyContext?.args?.adSpec || {},
115
+ };
116
+ return getCodeForFramework(props, framework);
117
+ }
118
+ catch (error) {
119
+ console.error('Error in transform function:', error);
120
+ return `<apollo-data-world-map-chart />`;
121
+ }
122
+ },
123
+ },
124
+ },
125
+ },
126
+ };