@xplortech/apollo-data 0.0.3-draft.64d0fa1
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.
- package/LICENSE +21 -0
- package/README.md +112 -0
- package/dist/apollo-data/apollo-data.esm.js +1 -0
- package/dist/apollo-data/index.esm.js +1 -0
- package/dist/apollo-data/p-Bb2nY-Tf.js +2 -0
- package/dist/apollo-data/p-DQuL1Twl.js +1 -0
- package/dist/apollo-data/p-e6584598.entry.js +11 -0
- package/dist/cjs/apollo-data-bar-chart_2.cjs.entry.js +68368 -0
- package/dist/cjs/apollo-data.cjs.js +25 -0
- package/dist/cjs/app-globals-V2Kpy_OQ.js +5 -0
- package/dist/cjs/index-Cl7HgRm0.js +1198 -0
- package/dist/cjs/index.cjs.js +7 -0
- package/dist/cjs/loader.cjs.js +13 -0
- package/dist/collection/apollo-data-base.js +38 -0
- package/dist/collection/collection-manifest.json +13 -0
- package/dist/collection/components/apollo-data-bar/apollo-data-bar.js +367 -0
- package/dist/collection/components/apollo-data-donut/apollo-data-donut.js +479 -0
- package/dist/collection/examples/apollo-data-bar.examples.js +160 -0
- package/dist/collection/examples/apollo-data-donut.examples.js +100 -0
- package/dist/collection/examples/index.js +2 -0
- package/dist/collection/index.js +10 -0
- package/dist/collection/utils/code-generator.js +240 -0
- package/dist/collection/utils/constants.js +2 -0
- package/dist/collection/utils/utils.js +3 -0
- package/dist/components/apollo-data-bar-chart.d.ts +11 -0
- package/dist/components/apollo-data-bar-chart.js +1 -0
- package/dist/components/apollo-data-donut-chart.d.ts +11 -0
- package/dist/components/apollo-data-donut-chart.js +1 -0
- package/dist/components/index.d.ts +35 -0
- package/dist/components/index.js +1 -0
- package/dist/components/p-7XF5Cax8.js +11 -0
- package/dist/components/p-Dws5s-Xe.js +1 -0
- package/dist/esm/apollo-data-bar-chart_2.entry.js +68365 -0
- package/dist/esm/apollo-data.js +21 -0
- package/dist/esm/app-globals-DQuL1Twl.js +3 -0
- package/dist/esm/index-Bb2nY-Tf.js +1190 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/loader.js +11 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/types/apollo-data-base.d.ts +7 -0
- package/dist/types/components/apollo-data-bar/apollo-data-bar.d.ts +298 -0
- package/dist/types/components/apollo-data-donut/apollo-data-donut.d.ts +533 -0
- package/dist/types/components.d.ts +102 -0
- package/dist/types/examples/apollo-data-bar.examples.d.ts +12 -0
- package/dist/types/examples/apollo-data-donut.examples.d.ts +11 -0
- package/dist/types/examples/index.d.ts +2 -0
- package/dist/types/index.d.ts +11 -0
- package/dist/types/stencil-public-runtime.d.ts +1839 -0
- package/dist/types/utils/code-generator.d.ts +12 -0
- package/dist/types/utils/constants.d.ts +2 -0
- package/dist/types/utils/utils.d.ts +1 -0
- package/loader/cdn.js +1 -0
- package/loader/index.cjs.js +1 -0
- package/loader/index.d.ts +24 -0
- package/loader/index.es2017.js +1 -0
- package/loader/index.js +2 -0
- package/package.json +92 -0
- package/src/examples/apollo-data-bar.examples.ts +172 -0
- package/src/examples/apollo-data-donut.examples.ts +118 -0
- package/src/examples/index.ts +2 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
export const donutExamples = [
|
|
2
|
+
{
|
|
3
|
+
name: 'Basic Revenue Distribution',
|
|
4
|
+
description: 'A simple donut chart showing revenue distribution across different categories',
|
|
5
|
+
props: {
|
|
6
|
+
adData: [
|
|
7
|
+
{ category: 'Product Sales', value: 350000 },
|
|
8
|
+
{ category: 'Services', value: 250000 },
|
|
9
|
+
{ category: 'Subscriptions', value: 150000 },
|
|
10
|
+
{ category: 'Consulting', value: 100000 },
|
|
11
|
+
],
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
name: 'Custom Colors',
|
|
16
|
+
description: 'Donut chart with custom color scheme',
|
|
17
|
+
props: {
|
|
18
|
+
adData: [
|
|
19
|
+
{ category: 'Region A', value: 450000 },
|
|
20
|
+
{ category: 'Region B', value: 300000 },
|
|
21
|
+
{ category: 'Region C', value: 200000 },
|
|
22
|
+
],
|
|
23
|
+
adSpec: {
|
|
24
|
+
colorSet: ['#FF6B6B', '#4ECDC4', '#45B7D1'],
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: 'Many Categories',
|
|
30
|
+
description: 'Donut chart with multiple categories',
|
|
31
|
+
props: {
|
|
32
|
+
adData: [
|
|
33
|
+
{ category: 'Marketing', value: 120000 },
|
|
34
|
+
{ category: 'Engineering', value: 280000 },
|
|
35
|
+
{ category: 'Sales', value: 210000 },
|
|
36
|
+
{ category: 'Operations', value: 150000 },
|
|
37
|
+
{ category: 'Customer Support', value: 90000 },
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: 'Prefix',
|
|
43
|
+
description: 'Donut chart with prefix',
|
|
44
|
+
props: {
|
|
45
|
+
adData: [
|
|
46
|
+
{ category: 'Marketing', value: 120000 },
|
|
47
|
+
{ category: 'Engineering', value: 280000 },
|
|
48
|
+
{ category: 'Sales', value: 210000 },
|
|
49
|
+
{ category: 'Operations', value: 150000 },
|
|
50
|
+
{ category: 'Customer Support', value: 90000 },
|
|
51
|
+
],
|
|
52
|
+
adSpec: {
|
|
53
|
+
prefix: '€',
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
name: 'Prefix and Suffix',
|
|
59
|
+
description: 'Donut chart with prefix and suffix',
|
|
60
|
+
props: {
|
|
61
|
+
adData: [
|
|
62
|
+
{ category: 'Marketing', value: 120000 },
|
|
63
|
+
{ category: 'Engineering', value: 280000 },
|
|
64
|
+
{ category: 'Sales', value: 210000 },
|
|
65
|
+
{ category: 'Operations', value: 150000 },
|
|
66
|
+
{ category: 'Customer Support', value: 90000 },
|
|
67
|
+
],
|
|
68
|
+
adSpec: {
|
|
69
|
+
prefix: '€',
|
|
70
|
+
suffix: '€',
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
name: 'Prefix, suffix and color set',
|
|
76
|
+
description: 'Donut chart with prefix and suffix and color set',
|
|
77
|
+
props: {
|
|
78
|
+
adData: [
|
|
79
|
+
{ category: 'Marketing', value: 120000 },
|
|
80
|
+
{ category: 'Engineering', value: 280000 },
|
|
81
|
+
{ category: 'Sales', value: 210000 },
|
|
82
|
+
{ category: 'Operations', value: 150000 },
|
|
83
|
+
{ category: 'Customer Support', value: 90000 },
|
|
84
|
+
],
|
|
85
|
+
adSpec: {
|
|
86
|
+
prefix: '€',
|
|
87
|
+
suffix: '€',
|
|
88
|
+
colorSet: [
|
|
89
|
+
'#FF0000', // Red
|
|
90
|
+
'#FF7F00', // Orange
|
|
91
|
+
'#FFD700', // Yellow
|
|
92
|
+
'#00C853', // Green
|
|
93
|
+
'#00B0FF', // Blue
|
|
94
|
+
'#3F51B5', // Indigo
|
|
95
|
+
'#8E24AA', // Violet
|
|
96
|
+
],
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview entry point for your component library
|
|
3
|
+
*
|
|
4
|
+
* This is the entry point for your component library. Use this file to export utilities,
|
|
5
|
+
* constants or data structure that accompany your components.
|
|
6
|
+
*
|
|
7
|
+
* DO NOT use this file to export your components. Instead, use the recommended approaches
|
|
8
|
+
* to consume components of this package as outlined in the `README.md`.
|
|
9
|
+
*/
|
|
10
|
+
export { format } from './utils/utils';
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import packageJson from "../../package.json";
|
|
2
|
+
// Package version - loaded from package.json
|
|
3
|
+
const PACKAGE_VERSION = packageJson.version;
|
|
4
|
+
// Generate installation documentation based on framework
|
|
5
|
+
export function generateInstallationDocs(framework = 'react', componentName) {
|
|
6
|
+
const packageMap = {
|
|
7
|
+
react: '@xplortech/apollo-data-react',
|
|
8
|
+
vue: '@xplortech/apollo-data-vue',
|
|
9
|
+
webcomponent: '@xplortech/apollo-data',
|
|
10
|
+
};
|
|
11
|
+
const packageName = packageMap[framework] || packageMap.webcomponent;
|
|
12
|
+
const installCmd = `npm install ${packageName}@${PACKAGE_VERSION}`;
|
|
13
|
+
const yarnCmd = `yarn add ${packageName}@${PACKAGE_VERSION}`;
|
|
14
|
+
const pnpmCmd = `pnpm add ${packageName}@${PACKAGE_VERSION}`;
|
|
15
|
+
let importExample = '';
|
|
16
|
+
const componentNamePascal = componentName
|
|
17
|
+
? componentName
|
|
18
|
+
.split('-')
|
|
19
|
+
.map(part => part.charAt(0).toUpperCase() + part.slice(1))
|
|
20
|
+
.join('')
|
|
21
|
+
: 'ApolloDataDonutChart';
|
|
22
|
+
if (framework === 'react') {
|
|
23
|
+
importExample = `
|
|
24
|
+
### Import in React
|
|
25
|
+
|
|
26
|
+
\`\`\`tsx
|
|
27
|
+
import { ${componentNamePascal} } from '@xplortech/apollo-data-react';
|
|
28
|
+
|
|
29
|
+
function MyComponent() {
|
|
30
|
+
const data = [
|
|
31
|
+
{ category: 'A', value: 30 },
|
|
32
|
+
{ category: 'B', value: 70 }
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
return <${componentNamePascal} adData={data} />;
|
|
36
|
+
}
|
|
37
|
+
\`\`\``;
|
|
38
|
+
}
|
|
39
|
+
else if (framework === 'vue') {
|
|
40
|
+
importExample = `
|
|
41
|
+
### Import in Vue
|
|
42
|
+
|
|
43
|
+
\`\`\`vue
|
|
44
|
+
<template>
|
|
45
|
+
<${componentNamePascal} :adData="data" />
|
|
46
|
+
</template>
|
|
47
|
+
|
|
48
|
+
<script setup>
|
|
49
|
+
import { ${componentNamePascal} } from '@xplortech/apollo-data-vue';
|
|
50
|
+
|
|
51
|
+
const data = [
|
|
52
|
+
{ category: 'A', value: 30 },
|
|
53
|
+
{ category: 'B', value: 70 }
|
|
54
|
+
];
|
|
55
|
+
</script>
|
|
56
|
+
\`\`\``;
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
const kebabName = componentName || 'apollo-data-donut-chart';
|
|
60
|
+
importExample = `
|
|
61
|
+
### Import as Web Component
|
|
62
|
+
|
|
63
|
+
\`\`\`html
|
|
64
|
+
<script type="module">
|
|
65
|
+
import { defineCustomElements } from '@xplortech/apollo-data/loader';
|
|
66
|
+
defineCustomElements();
|
|
67
|
+
</script>
|
|
68
|
+
|
|
69
|
+
<${kebabName}></${kebabName}>
|
|
70
|
+
|
|
71
|
+
<script>
|
|
72
|
+
const chart = document.querySelector('${kebabName}');
|
|
73
|
+
chart.adData = [
|
|
74
|
+
{ category: 'A', value: 30 },
|
|
75
|
+
{ category: 'B', value: 70 }
|
|
76
|
+
];
|
|
77
|
+
</script>
|
|
78
|
+
\`\`\``;
|
|
79
|
+
}
|
|
80
|
+
const frameworkLabel = framework === 'react' ? 'React' : framework === 'vue' ? 'Vue' : 'Web Component';
|
|
81
|
+
const classPrefix = framework === 'react' ? 'install-react' : framework === 'vue' ? 'install-vue' : 'install-webcomponent';
|
|
82
|
+
const hideByDefault = framework !== 'react' ? ' style="display: none;"' : '';
|
|
83
|
+
return `<div class="${classPrefix}"${hideByDefault}>
|
|
84
|
+
|
|
85
|
+
## Installation (v${PACKAGE_VERSION}) - ${frameworkLabel}
|
|
86
|
+
|
|
87
|
+
Install the package using your preferred package manager:
|
|
88
|
+
|
|
89
|
+
\`\`\`bash
|
|
90
|
+
# npm
|
|
91
|
+
${installCmd}
|
|
92
|
+
|
|
93
|
+
# yarn
|
|
94
|
+
${yarnCmd}
|
|
95
|
+
|
|
96
|
+
# pnpm
|
|
97
|
+
${pnpmCmd}
|
|
98
|
+
\`\`\`
|
|
99
|
+
${importExample}
|
|
100
|
+
|
|
101
|
+
</div>`;
|
|
102
|
+
}
|
|
103
|
+
function formatValue(value, indent = '') {
|
|
104
|
+
if (typeof value === 'function') {
|
|
105
|
+
return value.toString();
|
|
106
|
+
}
|
|
107
|
+
if (Array.isArray(value) || typeof value === 'object') {
|
|
108
|
+
return JSON.stringify(value, null, 2)
|
|
109
|
+
.split('\n')
|
|
110
|
+
.map((line, i) => (i === 0 ? line : indent + line))
|
|
111
|
+
.join('\n');
|
|
112
|
+
}
|
|
113
|
+
return JSON.stringify(value);
|
|
114
|
+
}
|
|
115
|
+
function extractPropsAndValues(props) {
|
|
116
|
+
const propEntries = Object.entries(props).filter(([_, value]) => value !== undefined);
|
|
117
|
+
return propEntries;
|
|
118
|
+
}
|
|
119
|
+
export function generateReactCode(componentName, props) {
|
|
120
|
+
const componentNamePascal = componentName
|
|
121
|
+
.split('-')
|
|
122
|
+
.map(part => part.charAt(0).toUpperCase() + part.slice(1))
|
|
123
|
+
.join('');
|
|
124
|
+
const propEntries = extractPropsAndValues(props);
|
|
125
|
+
// Separate data declarations and event handlers
|
|
126
|
+
const dataProps = [];
|
|
127
|
+
const eventProps = [];
|
|
128
|
+
const declarations = [];
|
|
129
|
+
propEntries.forEach(([key, value]) => {
|
|
130
|
+
const camelKey = key.replace(/-([a-z])/g, g => g[1].toUpperCase());
|
|
131
|
+
if (key.startsWith('on') || typeof value === 'function') {
|
|
132
|
+
// Event handler
|
|
133
|
+
const handlerName = camelKey;
|
|
134
|
+
declarations.push(`const ${handlerName} = ${formatValue(value, ' ')};`);
|
|
135
|
+
eventProps.push(`${camelKey}={${handlerName}}`);
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
// Data prop
|
|
139
|
+
const varName = camelKey === 'adData' ? 'data' : camelKey === 'adSpec' ? 'spec' : camelKey;
|
|
140
|
+
if (value && typeof value === 'object') {
|
|
141
|
+
declarations.push(`const ${varName} = ${formatValue(value, ' ')};`);
|
|
142
|
+
dataProps.push(`${camelKey}={${varName}}`);
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
dataProps.push(`${camelKey}={${formatValue(value)}}`);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
const allProps = [...dataProps, ...eventProps].join('\n ');
|
|
150
|
+
return `import { ${componentNamePascal} } from '@xplortech/apollo-data-react';
|
|
151
|
+
|
|
152
|
+
${declarations.join('\n\n')}
|
|
153
|
+
|
|
154
|
+
function MyComponent() {
|
|
155
|
+
return (
|
|
156
|
+
<${componentNamePascal}
|
|
157
|
+
${allProps}
|
|
158
|
+
/>
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export default MyComponent;`;
|
|
163
|
+
}
|
|
164
|
+
export function generateVueCode(componentName, props) {
|
|
165
|
+
const componentNamePascal = componentName
|
|
166
|
+
.split('-')
|
|
167
|
+
.map(part => part.charAt(0).toUpperCase() + part.slice(1))
|
|
168
|
+
.join('');
|
|
169
|
+
const propEntries = extractPropsAndValues(props);
|
|
170
|
+
// Separate data declarations and event handlers
|
|
171
|
+
const templateProps = [];
|
|
172
|
+
const declarations = [];
|
|
173
|
+
propEntries.forEach(([key, value]) => {
|
|
174
|
+
const kebabKey = key.replace(/([A-Z])/g, '-$1').toLowerCase();
|
|
175
|
+
if (key.startsWith('on') || typeof value === 'function') {
|
|
176
|
+
// Event handler
|
|
177
|
+
const eventName = key.startsWith('on') ? key.slice(2).toLowerCase() : key;
|
|
178
|
+
const handlerName = `handle${key.charAt(2).toUpperCase() + key.slice(3)}`;
|
|
179
|
+
declarations.push(`const ${handlerName} = ${formatValue(value, ' ')};`);
|
|
180
|
+
templateProps.push(`@${eventName}="${handlerName}"`);
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
// Data prop
|
|
184
|
+
const varName = kebabKey === 'ad-data' ? 'data' : kebabKey === 'ad-spec' ? 'spec' : kebabKey;
|
|
185
|
+
if (value && typeof value === 'object') {
|
|
186
|
+
declarations.push(`const ${varName} = ${formatValue(value, ' ')};`);
|
|
187
|
+
templateProps.push(`:${kebabKey}="${varName}"`);
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
templateProps.push(`:${kebabKey}="${formatValue(value)}"`);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
const allProps = templateProps.join('\n ');
|
|
195
|
+
return `<template>
|
|
196
|
+
<${componentNamePascal}
|
|
197
|
+
${allProps}
|
|
198
|
+
/>
|
|
199
|
+
</template>
|
|
200
|
+
|
|
201
|
+
<script setup lang="ts">
|
|
202
|
+
import { ${componentNamePascal} } from '@xplortech/apollo-data-vue';
|
|
203
|
+
|
|
204
|
+
${declarations.join('\n\n')}
|
|
205
|
+
</script>`;
|
|
206
|
+
}
|
|
207
|
+
export function generateWebComponentCode(componentName, props) {
|
|
208
|
+
const propEntries = extractPropsAndValues(props);
|
|
209
|
+
const propertyAssignments = [];
|
|
210
|
+
const eventListeners = [];
|
|
211
|
+
propEntries.forEach(([key, value]) => {
|
|
212
|
+
if (key.startsWith('on') || typeof value === 'function') {
|
|
213
|
+
// Event handler
|
|
214
|
+
const eventName = key.startsWith('on') ? key.slice(2).toLowerCase() : key;
|
|
215
|
+
eventListeners.push(` component.addEventListener('${eventName}', ${formatValue(value, ' ')});`);
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
// Property
|
|
219
|
+
propertyAssignments.push(` component.${key} = ${formatValue(value, ' ')};`);
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
return `<!DOCTYPE html>
|
|
223
|
+
<html>
|
|
224
|
+
<head>
|
|
225
|
+
<script type="module">
|
|
226
|
+
import { defineCustomElements } from '@xplortech/apollo-data/loader';
|
|
227
|
+
defineCustomElements();
|
|
228
|
+
</script>
|
|
229
|
+
</head>
|
|
230
|
+
<body>
|
|
231
|
+
<${componentName}></${componentName}>
|
|
232
|
+
|
|
233
|
+
<script>
|
|
234
|
+
const component = document.querySelector('${componentName}');
|
|
235
|
+
${propertyAssignments.join('\n')}
|
|
236
|
+
${eventListeners.length > 0 ? '\n' + eventListeners.join('\n') : ''}
|
|
237
|
+
</script>
|
|
238
|
+
</body>
|
|
239
|
+
</html>`;
|
|
240
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface ApolloDataBarChart extends Components.ApolloDataBarChart, HTMLElement {}
|
|
4
|
+
export const ApolloDataBarChart: {
|
|
5
|
+
prototype: ApolloDataBarChart;
|
|
6
|
+
new (): ApolloDataBarChart;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{p as e,t,h as a,H as o}from"./p-Dws5s-Xe.js";import{A as l}from"./p-7XF5Cax8.js";const n=["#4d1ab2","#f99170","#e550c8","#ffd563","#8857fa","#52ebba","#bf1d78","#31cff8"],r="apple-system, system-ui, 'Segoe UI', Arial, Helvetica, Roboto, sans-serif",i=e(class e extends l{constructor(e){super(!1),!1!==e&&this.__registerHost(),this.__attachShadow()}get el(){return this}adData=[];adSpec=null;static tooltipStylesInjected=!1;componentDidLoad(){this.injectTooltipStyles()}async componentDidRender(){await this.renderChart()}injectTooltipStyles(){if(e.tooltipStylesInjected)return;const t="apollo-data-bar-tooltip-styles";if(document.getElementById(t))return void(e.tooltipStylesInjected=!0);const a=document.createElement("style");a.id=t,a.textContent="\n #vg-tooltip-element {\n background-color: #ffffff;\n border: 1px solid #e1e2e8;\n border-radius: 0.25rem;\n box-shadow: 0 4px 6px -1px rgba(48, 45, 59, 0.1), 0 2px 4px -1px rgba(48, 45, 59, 0.05);\n font-family: apple-system, system-ui, 'Segoe UI', Arial, Helvetica, Roboto, sans-serif;\n font-weight: 500;\n padding: 0.25rem 0.75rem;\n pointer-events: none;\n text-align: center;\n transform: translateY(20%);\n white-space: pre;\n z-index: 999999999;\n }\n\n #vg-tooltip-element table tr td.key {\n color: #6a6d7d;\n text-align: center;\n }\n\n #vg-tooltip-element table tr td.value {\n text-align: center;\n }\n\n #vg-tooltip-element.dark-theme {\n background-color: #292632;\n border: 1px solid #6a6d7d;\n box-shadow: 0 4px 6px -1px rgba(48, 45, 59, 0.1), 0 2px 4px -1px rgba(48, 45, 59, 0.5);\n color: #ffffff;\n }\n\n #vg-tooltip-element::after {\n border-color: rgba(255, 255, 255, 0.95) transparent transparent transparent;\n border-style: solid;\n border-width: 9px;\n bottom: -17px;\n content: '';\n left: 50%;\n position: absolute;\n transform: translateX(-50%);\n }\n ",document.head.appendChild(a),e.tooltipStylesInjected=!0}async getViewData(e,t){if(!t)throw Error("adSpec is required for apollo-data-bar-chart");const{tooltipPrefix:a="",currencySymbol:o=""}=t;if(!e||0===e.length)throw Error("Data is required for apollo-data-bar-chart");const l=Array.from(new Set(e.map((e=>e.category)))),i=a?".2f":".0f",d=a?o:"";return{$schema:"https://vega.github.io/schema/vega/v5.json",config:{text:{fill:"#6a6d7d",font:r,labelFontSize:12,labelFontWeight:400},axis:{labelColor:"#6a6d7d",titleColor:"#6a6d7d",labelFont:r,titleFont:r,titleFontWeight:400},legend:{labelColor:"#6a6d7d",titleColor:"#6a6d7d",labelFont:r,titleFont:r,labelFontSize:12,labelLimit:95},title:{color:"#6a6d7d",font:r,labelFontSize:12,labelFontWeight:400}},height:250,autosize:{type:"fit-x",contains:"padding",resize:!0},signals:[{name:"containerW",update:"max(containerSize()[0], 400)"},{name:"legendColumns",update:"ceil(containerW / 140)"},{name:"hoveredPeriod",value:null,on:[{events:"rect:mouseover",update:"datum.period"},{events:"rect:mouseout",update:"null"}]}],width:{signal:"containerW"},data:[{name:"raw",values:e},{name:"periodTotals",source:"raw",transform:[{type:"aggregate",groupby:["periodId"],fields:["value"],ops:["sum"],as:["total"]}]},{name:"table",source:"raw",transform:[{type:"lookup",from:"periodTotals",key:"periodId",fields:["periodId"],values:["total"],as:["total"]},{type:"stack",groupby:["periodId"],sort:{field:"category"},field:"value"},{type:"formula",as:"periodId",expr:"datum.periodId"},{type:"formula",as:"labelOnly",expr:"datum.label"}]},{name:"periodLabels",source:"raw",transform:[{type:"aggregate",groupby:["periodId","label"]}]}],scales:[{name:"x",type:"band",domain:{data:"table",field:"periodId"},range:"width",paddingInner:.35,paddingOuter:.02},{name:"xLabels",type:"ordinal",domain:{data:"periodLabels",field:"periodId"},range:{data:"periodLabels",field:"label"}},{name:"y",type:"linear",domain:{data:"table",field:"y1"},nice:!0,zero:!0,range:"height"},{name:"color",type:"ordinal",domain:l,range:t?.colorSet??n}],axes:[{orient:"bottom",scale:"x",title:t?.xAxisTitle,labelPadding:12,titlePadding:12,labelAngle:-90,labelAlign:"right",labelBaseline:"middle",tickSize:3,labelFontSize:12,titleFontSize:14,ticks:!1,domain:!1,encode:{labels:{update:{text:{signal:"scale('xLabels', datum.value)"}}}}},{orient:"left",scale:"y",title:t?.yAxisTitle||"",format:",.0f",grid:!0,tickCount:6,labelFontSize:12,titleFontSize:14,ticks:!1,domain:!1,tickBand:"extent",labelPadding:10}],legends:[{fill:"color",orient:"bottom",direction:"horizontal",columns:{signal:"legendColumns"},title:null,symbolType:"square",rowPadding:8,symbolOffset:-35,symbolSize:100,labelOffset:8,labelLimit:95}],marks:[{type:"rect",from:{data:"table"},encode:{enter:{x:{scale:"x",field:"periodId"},width:{scale:"x",band:1},y:{scale:"y",field:"y1"},y2:{scale:"y",field:"y0"},fill:{scale:"color",field:"category"},tooltip:{signal:`datum.category + ': ${d}' + format(datum.value, ',${i}') + '\\nTotal: ${d}' + format(datum.total, ',${i}')`}},update:{opacity:[{test:"hoveredPeriod && datum.period !== hoveredPeriod",value:.2},{value:1}]}}}]}}render(){return a(o,{key:"86ed2e74e5abd57e684a93bc9cf6a014b3ed081c"},a("div",{key:"96e5f7dd2dfa6a104ca709d1399308a86041c2f3",id:"container",style:{width:"100%",height:"100%"}}))}},[513,"apollo-data-bar-chart",{adData:[1,"ad-data"],adSpec:[1,"ad-spec"]}]),d=i,s=function(){"undefined"!=typeof customElements&&["apollo-data-bar-chart"].forEach((e=>{"apollo-data-bar-chart"===e&&(customElements.get(t(e))||customElements.define(t(e),i))}))};export{d as ApolloDataBarChart,s as defineCustomElement}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface ApolloDataDonutChart extends Components.ApolloDataDonutChart, HTMLElement {}
|
|
4
|
+
export const ApolloDataDonutChart: {
|
|
5
|
+
prototype: ApolloDataDonutChart;
|
|
6
|
+
new (): ApolloDataDonutChart;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{p as e,h as a,H as t,t as n}from"./p-Dws5s-Xe.js";import{A as l}from"./p-7XF5Cax8.js";const r=e(class extends l{constructor(e){super(!1),!1!==e&&this.__registerHost(),this.__attachShadow()}get el(){return this}adData=[];adSpec={};categories;dataValues;totalRevenue;chartColors;defaultChartColors=["#4d1ab2","#f99170","#e550c8","#ffd563","#8857fa","#52ebba","#bf1d78","#31cff8"];defaultCenterText="Total Revenue";async componentDidRender(){await this.renderChart()}async getViewData(e,a){const t=e;return this.chartColors=a?.colorSet?a.colorSet:this.defaultChartColors,this.categories=t.map((e=>e.category)),this.dataValues=t.map(((e,a)=>({...e,order:a+1}))),this.totalRevenue=Math.round(100*t.reduce(((e,a)=>e+a.value),0))/100,{$schema:"https://vega.github.io/schema/vega/v5.json",description:"Donut chart with correctly placed percentage labels and exploded 'Other' slices on hover",height:250,signals:[{name:"containerW",update:"min(containerSize()[0], 400)"},{name:"centerX",update:"containerW / 2"},{name:"centerY",update:"250 / 2"},{name:"radius",update:"min(containerW, 250) / 2 - 20"},{name:"categoryDisplay",value:null,on:[{events:{type:"mouseover",markname:"mainArc"},update:"datum.category"},{events:{type:"mouseover",markname:"mainArcLabel"},update:"datum.category"},{events:{type:"mouseout",markname:"mainArc"},update:"null"},{events:{type:"mouseout",markname:"mainArcLabel"},update:"null"},{events:{type:"mouseover",markname:"innerArc"},update:"null"},{events:{type:"mouseover",markname:"outerArc"},update:"null"},{events:{type:"mouseover",markname:"otherArc"},update:"datum.category"},{events:{type:"mouseout",markname:"otherArc"},update:"null"}]},{name:"displayText",update:`categoryDisplay && length(categoryDisplay) > 18 ? (lastindexof(categoryDisplay, ' ') > 0 ? slice(categoryDisplay, 0, lastindexof(categoryDisplay, ' ')) + '\\n' + slice(categoryDisplay, lastindexof(categoryDisplay, ' ') + 1) : categoryDisplay) : categoryDisplay || '${a?.centerText?a.centerText:this.defaultCenterText}'`},{name:"hoveredCategory",value:null,on:[{events:{type:"mouseover",markname:"mainArc"},update:"datum.category"},{events:{type:"mouseover",markname:"mainArcLabel"},update:"datum.category"},{events:{type:"mouseover",markname:"outerArc"},update:"null"},{events:{type:"mouseover",markname:"innerArc"},update:"null"},{events:{type:"mouseout",markname:"innerArc"},update:"null"}]},{name:"hoveredValue",value:null,on:[{events:{type:"mouseover",markname:"mainArc"},update:"datum.value"},{events:{type:"mouseover",markname:"mainArcLabel"},update:"datum.value"},{events:{type:"mouseout",markname:"mainArc"},update:"null"},{events:{type:"mouseover",markname:"otherArc"},update:"datum.value"},{events:{type:"mouseout",markname:"otherArc"},update:"null"}]}],width:{signal:"containerW"},data:[{name:"table",values:this.dataValues,transform:[{type:"joinaggregate",fields:["value"],ops:["sum"],as:["total"]},{type:"formula",as:"percent",expr:"datum.value / datum.total"},{type:"collect",sort:{field:"order",order:"descending"}},{type:"pie",field:"value",as:["startAngle","endAngle"]},{type:"formula",as:"midAngle",expr:"((datum.startAngle + datum.endAngle) + 9.418) / 2"},{type:"formula",as:"labelX",expr:"centerX + (radius * 1.2 * cos(datum.midAngle))"},{type:"formula",as:"labelY",expr:"centerY + (radius * 1.2 * sin(datum.midAngle))"},{type:"formula",as:"percentLabel",expr:`format(datum.value / ${this.totalRevenue} * 100, '.1f') + '%'`}]},{name:"defaultCenterText",values:[{category:a?.centerText?a.centerText:this.defaultCenterText,value:this.totalRevenue,order:4}],transform:[{type:"filter",expr:"hoveredCategory === null"},{type:"formula",as:"textDisplay",expr:`'${a?.prefix??"$"}' + format(floor(datum.value), ',') + '${a?.suffix??""}' `}]}],scales:[{name:"mainColor",type:"ordinal",domain:this.categories,range:this.chartColors}],legends:[{fill:"mainColor",orient:"bottom",direction:"horizontal",columns:2,title:"",padding:10,symbolType:"square",symbolSize:100,labelFontSize:12,labelColor:"#6A6D7D",rowPadding:8}],marks:[{type:"rule",name:"labelLines",from:{data:"table"},encode:{enter:{stroke:{value:"black"},strokeWidth:{value:1},x:{signal:"centerX + (radius * 0.9) * cos(datum.midAngle)"},y:{signal:"centerY + (radius * 0.9) * sin(datum.midAngle)"},x2:{signal:"datum.labelX - 12 * cos(datum.midAngle)"},y2:{signal:"datum.labelY - 12 * sin(datum.midAngle)"}},update:{opacity:{value:1}}},zindex:5},{type:"arc",name:"mainArc",from:{data:"table"},encode:{enter:{fill:{scale:"mainColor",field:"category"},x:{signal:"centerX"},y:{signal:"centerY"},startAngle:{field:"startAngle"},endAngle:{field:"endAngle"},innerRadius:{signal:"radius * 0.5"},outerRadius:{signal:"radius * 0.9"},padAngle:{value:.03},cornerRadius:{value:1}}},interactive:!0},{type:"arc",name:"innerArc",from:{data:"table"},encode:{enter:{fill:{value:"transparent"},x:{signal:"centerX"},y:{signal:"centerY"},startAngle:{field:"startAngle"},endAngle:{field:"endAngle"},innerRadius:{signal:"radius * 0.4"},outerRadius:{signal:"radius * 0.5"},padAngle:{value:.03},cornerRadius:{value:1}}},zindex:1},{type:"arc",name:"outerArc",from:{data:"table"},encode:{enter:{fill:{value:"transparent"},x:{signal:"centerX"},y:{signal:"centerY"},startAngle:{field:"startAngle"},endAngle:{field:"endAngle"},innerRadius:{signal:"radius * 0.91"},outerRadius:{signal:"radius * 1.30"}}},zindex:1},{type:"text",name:"mainArcLabel",from:{data:"table"},encode:{enter:{text:{field:"percentLabel"},align:{value:"center"},baseline:{value:"middle"},fill:{value:"#302D3B"},fontSize:{value:10},x:{field:"labelX"},y:{field:"labelY"},font:{value:"apple-system, system-ui, 'Segoe UI', Arial, Helvetica, Roboto, sans-serif"},fontWeight:600}}},{type:"text",encode:{enter:{text:{value:"$850,000"},x:{signal:"centerX"},y:{signal:"centerY"},align:{value:"center"},baseline:{value:"middle"},fontSize:{value:16},fontWeight:{value:"bold"},fill:{value:"#302D3B"},font:{value:"apple-system, system-ui, 'Segoe UI', Arial, Helvetica, Roboto, sans-serif"}},update:{text:{signal:`hoveredValue ? '${a?.prefix??"$"}' + format(floor(hoveredValue), ',') + '${a?.suffix??""}' : '${a?.prefix??"$"}' + format(floor(${this.totalRevenue??1}), ',') + '${a?.suffix??""}'`}}}},{type:"text",encode:{enter:{x:{signal:"centerX"},y:{signal:"centerY + 15"},align:{value:"center"},baseline:{value:"middle"},fontSize:{value:10},fill:{value:"#6A6D7D"},font:{value:"apple-system, system-ui, 'Segoe UI', Arial, Helvetica, Roboto, sans-serif"},fontWeight:400,limit:{value:100},lineBreak:{value:"\\n"}},update:{text:{signal:"displayText"}}}}]}}render(){return a(t,{key:"fb26a6b02b83b0ce64a8301149b66f5d09a4a7b4"},a("div",{key:"fc08cdc3c0c0fda7f7c13149532eb61f511aa035",id:"container",style:{width:"100%",height:"100%"}}))}},[513,"apollo-data-donut-chart",{adData:[1,"ad-data"],adSpec:[1,"ad-spec"]}]),s=r,o=function(){"undefined"!=typeof customElements&&["apollo-data-donut-chart"].forEach((e=>{"apollo-data-donut-chart"===e&&(customElements.get(n(e))||customElements.define(n(e),r))}))};export{s as ApolloDataDonutChart,o as defineCustomElement}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the base path to where the assets can be found. Use "setAssetPath(path)"
|
|
3
|
+
* if the path needs to be customized.
|
|
4
|
+
*/
|
|
5
|
+
export declare const getAssetPath: (path: string) => string;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Used to manually set the base path where assets can be found.
|
|
9
|
+
* If the script is used as "module", it's recommended to use "import.meta.url",
|
|
10
|
+
* such as "setAssetPath(import.meta.url)". Other options include
|
|
11
|
+
* "setAssetPath(document.currentScript.src)", or using a bundler's replace plugin to
|
|
12
|
+
* dynamically set the path at build time, such as "setAssetPath(process.env.ASSET_PATH)".
|
|
13
|
+
* But do note that this configuration depends on how your script is bundled, or lack of
|
|
14
|
+
* bundling, and where your assets can be loaded from. Additionally custom bundling
|
|
15
|
+
* will have to ensure the static assets are copied to its build directory.
|
|
16
|
+
*/
|
|
17
|
+
export declare const setAssetPath: (path: string) => void;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Used to specify a nonce value that corresponds with an application's CSP.
|
|
21
|
+
* When set, the nonce will be added to all dynamically created script and style tags at runtime.
|
|
22
|
+
* Alternatively, the nonce value can be set on a meta tag in the DOM head
|
|
23
|
+
* (<meta name="csp-nonce" content="{ nonce value here }" />) which
|
|
24
|
+
* will result in the same behavior.
|
|
25
|
+
*/
|
|
26
|
+
export declare const setNonce: (nonce: string) => void
|
|
27
|
+
|
|
28
|
+
export interface SetPlatformOptions {
|
|
29
|
+
raf?: (c: FrameRequestCallback) => number;
|
|
30
|
+
ael?: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;
|
|
31
|
+
rel?: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;
|
|
32
|
+
}
|
|
33
|
+
export declare const setPlatformOptions: (opts: SetPlatformOptions) => void;
|
|
34
|
+
|
|
35
|
+
export * from '../types';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{g as getAssetPath,r as render,s as setAssetPath,a as setNonce,b as setPlatformOptions}from"./p-Dws5s-Xe.js";function t(s,t,e){return(s||"")+(t?" "+t:"")+(e?" "+e:"")}export{t as format}
|