@xplortech/apollo-data 0.0.3-draft.f8f65f7 → 0.0.4-draft.64ed229

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.
@@ -0,0 +1,346 @@
1
+ import { h, Host } from "@stencil/core";
2
+ import { ApolloBase } from "../../apollo-data-base";
3
+ import { CHART_COLORS } from "../../utils/constants";
4
+ const FONT_FAMILY = "apple-system, system-ui, 'Segoe UI', Arial, Helvetica, Roboto, sans-serif";
5
+ function lineStyleToStrokeDash(lineStyle) {
6
+ switch (lineStyle) {
7
+ case 'dashed':
8
+ return [6, 4];
9
+ case 'dotted':
10
+ return [2, 2];
11
+ case 'solid':
12
+ default:
13
+ return [];
14
+ }
15
+ }
16
+ export class ApolloDataLineChart extends ApolloBase {
17
+ constructor() {
18
+ super();
19
+ }
20
+ el = null;
21
+ adData = [];
22
+ adSpec = null;
23
+ static tooltipStylesInjected = false;
24
+ componentDidLoad() {
25
+ this.injectTooltipStyles();
26
+ }
27
+ async componentDidRender() {
28
+ await this.renderChart();
29
+ }
30
+ injectTooltipStyles() {
31
+ if (ApolloDataLineChart.tooltipStylesInjected) {
32
+ return;
33
+ }
34
+ const styleId = 'apollo-data-line-tooltip-styles';
35
+ if (document.getElementById(styleId)) {
36
+ ApolloDataLineChart.tooltipStylesInjected = true;
37
+ return;
38
+ }
39
+ const style = document.createElement('style');
40
+ style.id = styleId;
41
+ style.textContent = `
42
+ #vg-tooltip-element {
43
+ background-color: #ffffff;
44
+ border: 1px solid #e1e2e8;
45
+ border-radius: 0.25rem;
46
+ box-shadow: 0 4px 6px -1px rgba(48, 45, 59, 0.1), 0 2px 4px -1px rgba(48, 45, 59, 0.05);
47
+ font-family: apple-system, system-ui, 'Segoe UI', Arial, Helvetica, Roboto, sans-serif;
48
+ font-weight: 500;
49
+ padding: 0.25rem 0.75rem;
50
+ pointer-events: none;
51
+ text-align: center;
52
+ transform: translateY(20%);
53
+ white-space: pre;
54
+ z-index: 999999999;
55
+ }
56
+
57
+ #vg-tooltip-element table tr td.key {
58
+ color: #6a6d7d;
59
+ text-align: center;
60
+ }
61
+
62
+ #vg-tooltip-element table tr td.value {
63
+ text-align: center;
64
+ }
65
+
66
+ #vg-tooltip-element.dark-theme {
67
+ background-color: #292632;
68
+ border: 1px solid #6a6d7d;
69
+ box-shadow: 0 4px 6px -1px rgba(48, 45, 59, 0.1), 0 2px 4px -1px rgba(48, 45, 59, 0.5);
70
+ color: #ffffff;
71
+ }
72
+
73
+ #vg-tooltip-element::after {
74
+ border-color: rgba(255, 255, 255, 0.95) transparent transparent transparent;
75
+ border-style: solid;
76
+ border-width: 9px;
77
+ bottom: -17px;
78
+ content: '';
79
+ left: 50%;
80
+ position: absolute;
81
+ transform: translateX(-50%);
82
+ }
83
+ `;
84
+ document.head.appendChild(style);
85
+ ApolloDataLineChart.tooltipStylesInjected = true;
86
+ }
87
+ // @ts-ignore
88
+ async getViewData(data, spec) {
89
+ if (!spec) {
90
+ throw new Error('adSpec is required for apollo-data-line-chart');
91
+ }
92
+ const { tooltipPrefix = '', currencySymbol = '' } = spec;
93
+ if (!data || data.length === 0) {
94
+ throw new Error('Data is required for apollo-data-line-chart');
95
+ }
96
+ const uniqueCategories = Array.from(new Set(data.map(item => item.category)));
97
+ const uniqueXValues = [...new Set(data.map(item => item.xValue))].sort((a, b) => a - b);
98
+ const colorSet = spec?.colorSet ?? CHART_COLORS;
99
+ const xLabelData = uniqueXValues.map(x => {
100
+ const first = data.find(d => d.xValue === x);
101
+ return { xValue: x, displayLabel: first?.xLabel != null ? first.xLabel : String(x) };
102
+ });
103
+ const formatNumber = tooltipPrefix ? '.2f' : '.0f';
104
+ const currencyPrefix = tooltipPrefix ? currencySymbol : '';
105
+ const pointShape = spec.pointStyle ?? 'circle';
106
+ const strokeDash = lineStyleToStrokeDash(spec.lineStyle ?? 'solid');
107
+ const dataSpec = [
108
+ { name: 'raw', values: data },
109
+ { name: 'xLabelData', values: xLabelData },
110
+ ];
111
+ uniqueCategories.forEach((cat, i) => {
112
+ dataSpec.push({
113
+ name: `series_${i}`,
114
+ source: 'raw',
115
+ transform: [
116
+ { type: 'filter', expr: `datum.category === ${JSON.stringify(cat)}` },
117
+ { type: 'collect', sort: { field: 'xValue' } },
118
+ ],
119
+ });
120
+ });
121
+ const lineMarks = uniqueCategories.map((_, i) => ({
122
+ type: 'line',
123
+ from: { data: `series_${i}` },
124
+ encode: {
125
+ enter: {
126
+ x: { scale: 'x', field: 'xValue' },
127
+ y: { scale: 'y', field: 'yValue' },
128
+ stroke: { value: colorSet[i % colorSet.length] },
129
+ strokeWidth: { value: 2 },
130
+ interpolate: { value: 'monotone' },
131
+ ...(strokeDash.length > 0 ? { strokeDash: { value: strokeDash } } : {}),
132
+ },
133
+ },
134
+ }));
135
+ return {
136
+ $schema: 'https://vega.github.io/schema/vega/v5.json',
137
+ config: {
138
+ text: {
139
+ fill: '#6a6d7d',
140
+ font: FONT_FAMILY,
141
+ labelFontSize: 12,
142
+ labelFontWeight: 400,
143
+ },
144
+ axis: {
145
+ labelColor: '#6a6d7d',
146
+ titleColor: '#6a6d7d',
147
+ labelFont: FONT_FAMILY,
148
+ titleFont: FONT_FAMILY,
149
+ titleFontWeight: 400,
150
+ },
151
+ legend: {
152
+ labelColor: '#6a6d7d',
153
+ titleColor: '#6a6d7d',
154
+ labelFont: FONT_FAMILY,
155
+ titleFont: FONT_FAMILY,
156
+ labelFontSize: 12,
157
+ labelLimit: 95,
158
+ },
159
+ title: {
160
+ color: '#6a6d7d',
161
+ font: FONT_FAMILY,
162
+ labelFontSize: 12,
163
+ labelFontWeight: 400,
164
+ },
165
+ },
166
+ height: 250,
167
+ autosize: { type: 'fit-x', contains: 'padding', resize: true },
168
+ signals: [
169
+ {
170
+ name: 'containerW',
171
+ update: 'max(containerSize()[0], 400)',
172
+ },
173
+ {
174
+ name: 'legendColumns',
175
+ update: 'ceil(containerW / 140)',
176
+ },
177
+ ],
178
+ width: { signal: 'containerW' },
179
+ data: dataSpec,
180
+ scales: [
181
+ {
182
+ name: 'x',
183
+ type: 'point',
184
+ domain: uniqueXValues,
185
+ range: 'width',
186
+ padding: 0.5,
187
+ },
188
+ {
189
+ name: 'xLabels',
190
+ type: 'ordinal',
191
+ domain: { data: 'xLabelData', field: 'xValue' },
192
+ range: { data: 'xLabelData', field: 'displayLabel' },
193
+ },
194
+ {
195
+ name: 'y',
196
+ type: 'linear',
197
+ domain: { data: 'raw', field: 'yValue' },
198
+ nice: true,
199
+ zero: true,
200
+ range: 'height',
201
+ },
202
+ {
203
+ name: 'color',
204
+ type: 'ordinal',
205
+ domain: uniqueCategories,
206
+ range: spec?.colorSet ?? CHART_COLORS,
207
+ },
208
+ ],
209
+ axes: [
210
+ {
211
+ orient: 'bottom',
212
+ scale: 'x',
213
+ title: spec?.xAxisTitle,
214
+ labelPadding: 12,
215
+ titlePadding: 12,
216
+ labelAngle: -90,
217
+ labelAlign: 'right',
218
+ labelBaseline: 'middle',
219
+ tickSize: 3,
220
+ labelFontSize: 12,
221
+ titleFontSize: 14,
222
+ ticks: false,
223
+ domain: false,
224
+ encode: {
225
+ labels: {
226
+ update: {
227
+ text: { signal: "scale('xLabels', datum.value)" },
228
+ },
229
+ },
230
+ },
231
+ },
232
+ {
233
+ orient: 'left',
234
+ scale: 'y',
235
+ title: spec?.yAxisTitle || '',
236
+ format: ',.0f',
237
+ grid: true,
238
+ tickCount: 6,
239
+ labelFontSize: 12,
240
+ titleFontSize: 14,
241
+ ticks: false,
242
+ domain: false,
243
+ tickBand: 'extent',
244
+ labelPadding: 10,
245
+ },
246
+ ],
247
+ legends: [
248
+ {
249
+ stroke: 'color',
250
+ orient: 'bottom',
251
+ direction: 'horizontal',
252
+ columns: { signal: 'legendColumns' },
253
+ title: null,
254
+ symbolType: 'stroke',
255
+ symbolStrokeWidth: 3,
256
+ rowPadding: 8,
257
+ symbolOffset: -35,
258
+ symbolSize: 100,
259
+ labelOffset: 8,
260
+ labelLimit: 95,
261
+ },
262
+ ],
263
+ marks: [
264
+ ...lineMarks,
265
+ {
266
+ type: 'symbol',
267
+ from: { data: 'raw' },
268
+ encode: {
269
+ enter: {
270
+ x: { scale: 'x', field: 'xValue' },
271
+ y: { scale: 'y', field: 'yValue' },
272
+ fill: { scale: 'color', field: 'category' },
273
+ size: { value: 50 },
274
+ shape: { value: pointShape },
275
+ tooltip: {
276
+ signal: `(datum.xLabel != null ? datum.xLabel : format(datum.xValue, ',.0f')) + ' · ' + datum.category + ': ' + (datum.yLabel != null ? datum.yLabel : '${currencyPrefix}' + format(datum.yValue, ',${formatNumber}'))`,
277
+ },
278
+ },
279
+ },
280
+ },
281
+ ],
282
+ };
283
+ }
284
+ render() {
285
+ return (h(Host, { key: '7799f01536f212d7a06da08c1e463d8529c5bf21' }, h("div", { key: '25463f10bbc0f5443c35ab03b5b53164d9ad1efd', id: "container", style: { width: '100%', height: '100%' } })));
286
+ }
287
+ static get is() { return "apollo-data-line-chart"; }
288
+ static get encapsulation() { return "shadow"; }
289
+ static get properties() {
290
+ return {
291
+ "adData": {
292
+ "type": "string",
293
+ "mutable": false,
294
+ "complexType": {
295
+ "original": "string | LineDataItem[]",
296
+ "resolved": "LineDataItem[] | string",
297
+ "references": {
298
+ "LineDataItem": {
299
+ "location": "local",
300
+ "path": "/home/runner/work/apollo/apollo/packages/apollo-data/src/components/apollo-data-line/apollo-data-line.tsx",
301
+ "id": "src/components/apollo-data-line/apollo-data-line.tsx::LineDataItem"
302
+ }
303
+ }
304
+ },
305
+ "required": false,
306
+ "optional": false,
307
+ "docs": {
308
+ "tags": [],
309
+ "text": ""
310
+ },
311
+ "getter": false,
312
+ "setter": false,
313
+ "reflect": false,
314
+ "attribute": "ad-data",
315
+ "defaultValue": "[]"
316
+ },
317
+ "adSpec": {
318
+ "type": "string",
319
+ "mutable": false,
320
+ "complexType": {
321
+ "original": "string | LineSpec",
322
+ "resolved": "LineSpec | string",
323
+ "references": {
324
+ "LineSpec": {
325
+ "location": "local",
326
+ "path": "/home/runner/work/apollo/apollo/packages/apollo-data/src/components/apollo-data-line/apollo-data-line.tsx",
327
+ "id": "src/components/apollo-data-line/apollo-data-line.tsx::LineSpec"
328
+ }
329
+ }
330
+ },
331
+ "required": false,
332
+ "optional": false,
333
+ "docs": {
334
+ "tags": [],
335
+ "text": ""
336
+ },
337
+ "getter": false,
338
+ "setter": false,
339
+ "reflect": false,
340
+ "attribute": "ad-spec",
341
+ "defaultValue": "null"
342
+ }
343
+ };
344
+ }
345
+ static get elementRef() { return "el"; }
346
+ }
@@ -0,0 +1,91 @@
1
+ /** Each item has category, xValue, yValue, and optional xLabel/yLabel. When labels are omitted, numeric values are shown. */
2
+ export const lineExamples = [
3
+ {
4
+ name: 'Revenue and Expenses by Day',
5
+ description: 'Line chart showing daily revenue and expenses over a week',
6
+ props: {
7
+ adData: [
8
+ { category: 'Revenue', xValue: 1, yValue: 5000, xLabel: 'Mon' },
9
+ { category: 'Expenses', xValue: 1, yValue: 2000, xLabel: 'Mon' },
10
+ { category: 'Revenue', xValue: 2, yValue: 6000, xLabel: 'Tue' },
11
+ { category: 'Expenses', xValue: 2, yValue: 2500, xLabel: 'Tue' },
12
+ { category: 'Revenue', xValue: 3, yValue: 5500, xLabel: 'Wed' },
13
+ { category: 'Expenses', xValue: 3, yValue: 2200, xLabel: 'Wed' },
14
+ { category: 'Revenue', xValue: 4, yValue: 7000, xLabel: 'Thu' },
15
+ { category: 'Expenses', xValue: 4, yValue: 3000, xLabel: 'Thu' },
16
+ { category: 'Revenue', xValue: 5, yValue: 6500, xLabel: 'Fri' },
17
+ { category: 'Expenses', xValue: 5, yValue: 2800, xLabel: 'Fri' },
18
+ ],
19
+ adSpec: {
20
+ tooltipPrefix: '$',
21
+ currencySymbol: '$',
22
+ yAxisTitle: 'Amount',
23
+ colorSet: ['#FF8DF4', '#74FBD0'],
24
+ },
25
+ },
26
+ },
27
+ {
28
+ name: 'Monthly Sales by Product',
29
+ description: 'Multi-line chart showing sales across products by month',
30
+ props: {
31
+ adData: [
32
+ { category: 'Product A', xValue: 1, yValue: 12000, xLabel: 'Jan' },
33
+ { category: 'Product B', xValue: 1, yValue: 8000, xLabel: 'Jan' },
34
+ { category: 'Product C', xValue: 1, yValue: 6000, xLabel: 'Jan' },
35
+ { category: 'Product A', xValue: 2, yValue: 15000, xLabel: 'Feb' },
36
+ { category: 'Product B', xValue: 2, yValue: 9000, xLabel: 'Feb' },
37
+ { category: 'Product C', xValue: 2, yValue: 7000, xLabel: 'Feb' },
38
+ { category: 'Product A', xValue: 3, yValue: 13000, xLabel: 'Mar' },
39
+ { category: 'Product B', xValue: 3, yValue: 10000, xLabel: 'Mar' },
40
+ { category: 'Product C', xValue: 3, yValue: 5500, xLabel: 'Mar' },
41
+ { category: 'Product A', xValue: 4, yValue: 14000, xLabel: 'Apr' },
42
+ { category: 'Product B', xValue: 4, yValue: 9500, xLabel: 'Apr' },
43
+ { category: 'Product C', xValue: 4, yValue: 6500, xLabel: 'Apr' },
44
+ ],
45
+ adSpec: {
46
+ tooltipPrefix: '$',
47
+ currencySymbol: '$',
48
+ yAxisTitle: 'Monthly Sales',
49
+ colorSet: ['#FF8DF4', '#74FBD0', '#ECFD91'],
50
+ },
51
+ },
52
+ },
53
+ {
54
+ name: 'Single Series',
55
+ description: 'Line chart with one category (visitors over time)',
56
+ props: {
57
+ adData: [
58
+ { category: 'Visitors', xValue: 1, yValue: 2450, xLabel: 'Mon' },
59
+ { category: 'Visitors', xValue: 2, yValue: 2680, xLabel: 'Tue' },
60
+ { category: 'Visitors', xValue: 3, yValue: 2320, xLabel: 'Wed' },
61
+ { category: 'Visitors', xValue: 4, yValue: 2890, xLabel: 'Thu' },
62
+ { category: 'Visitors', xValue: 5, yValue: 3150, xLabel: 'Fri' },
63
+ { category: 'Visitors', xValue: 6, yValue: 3420, xLabel: 'Sat' },
64
+ { category: 'Visitors', xValue: 7, yValue: 3280, xLabel: 'Sun' },
65
+ ],
66
+ adSpec: {
67
+ yAxisTitle: 'Daily Visitors',
68
+ colorSet: ['#6366f1'],
69
+ },
70
+ },
71
+ },
72
+ {
73
+ name: 'Custom Axis Titles',
74
+ description: 'Line chart with custom x-axis and y-axis titles',
75
+ props: {
76
+ adData: [
77
+ { category: 'Inbound', xValue: 1, yValue: 120, xLabel: 'Mon' },
78
+ { category: 'Outbound', xValue: 1, yValue: 80, xLabel: 'Mon' },
79
+ { category: 'Inbound', xValue: 2, yValue: 95, xLabel: 'Tue' },
80
+ { category: 'Outbound', xValue: 2, yValue: 110, xLabel: 'Tue' },
81
+ { category: 'Inbound', xValue: 3, yValue: 130, xLabel: 'Wed' },
82
+ { category: 'Outbound', xValue: 3, yValue: 70, xLabel: 'Wed' },
83
+ ],
84
+ adSpec: {
85
+ yAxisTitle: 'Calls',
86
+ xAxisTitle: 'Support queue (by day)',
87
+ colorSet: ['#4d1ab2', '#f99170'],
88
+ },
89
+ },
90
+ },
91
+ ];
@@ -1,2 +1,3 @@
1
1
  export * from './apollo-data-donut.examples';
2
2
  export * from './apollo-data-bar.examples';
3
+ export * from './apollo-data-line.examples';
@@ -1 +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}
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";import{C as n}from"./p-2nuV5Vny.js";const 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 ApolloDataLineChart extends Components.ApolloDataLineChart, HTMLElement {}
4
+ export const ApolloDataLineChart: {
5
+ prototype: ApolloDataLineChart;
6
+ new (): ApolloDataLineChart;
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 t,H as a,t as l}from"./p-Dws5s-Xe.js";import{A as n}from"./p-7XF5Cax8.js";import{C as o}from"./p-2nuV5Vny.js";const i="apple-system, system-ui, 'Segoe UI', Arial, Helvetica, Roboto, sans-serif",r=e(class e extends n{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-line-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-line-chart");const{tooltipPrefix:a="",currencySymbol:l=""}=t;if(!e||0===e.length)throw Error("Data is required for apollo-data-line-chart");const n=Array.from(new Set(e.map((e=>e.category)))),r=[...new Set(e.map((e=>e.xValue)))].sort(((e,t)=>e-t)),d=t?.colorSet??o,s=r.map((t=>{const a=e.find((e=>e.xValue===t));return{xValue:t,displayLabel:null!=a?.xLabel?a.xLabel:t+""}})),c=a?".2f":".0f",m=a?l:"",p=t.pointStyle??"circle",u=function(e){switch(e){case"dashed":return[6,4];case"dotted":return[2,2];default:return[]}}(t.lineStyle??"solid"),f=[{name:"raw",values:e},{name:"xLabelData",values:s}];n.forEach(((e,t)=>{f.push({name:"series_"+t,source:"raw",transform:[{type:"filter",expr:"datum.category === "+JSON.stringify(e)},{type:"collect",sort:{field:"xValue"}}]})}));const b=n.map(((e,t)=>({type:"line",from:{data:"series_"+t},encode:{enter:{x:{scale:"x",field:"xValue"},y:{scale:"y",field:"yValue"},stroke:{value:d[t%d.length]},strokeWidth:{value:2},interpolate:{value:"monotone"},...u.length>0?{strokeDash:{value:u}}:{}}}})));return{$schema:"https://vega.github.io/schema/vega/v5.json",config:{text:{fill:"#6a6d7d",font:i,labelFontSize:12,labelFontWeight:400},axis:{labelColor:"#6a6d7d",titleColor:"#6a6d7d",labelFont:i,titleFont:i,titleFontWeight:400},legend:{labelColor:"#6a6d7d",titleColor:"#6a6d7d",labelFont:i,titleFont:i,labelFontSize:12,labelLimit:95},title:{color:"#6a6d7d",font:i,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)"}],width:{signal:"containerW"},data:f,scales:[{name:"x",type:"point",domain:r,range:"width",padding:.5},{name:"xLabels",type:"ordinal",domain:{data:"xLabelData",field:"xValue"},range:{data:"xLabelData",field:"displayLabel"}},{name:"y",type:"linear",domain:{data:"raw",field:"yValue"},nice:!0,zero:!0,range:"height"},{name:"color",type:"ordinal",domain:n,range:t?.colorSet??o}],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:[{stroke:"color",orient:"bottom",direction:"horizontal",columns:{signal:"legendColumns"},title:null,symbolType:"stroke",symbolStrokeWidth:3,rowPadding:8,symbolOffset:-35,symbolSize:100,labelOffset:8,labelLimit:95}],marks:[...b,{type:"symbol",from:{data:"raw"},encode:{enter:{x:{scale:"x",field:"xValue"},y:{scale:"y",field:"yValue"},fill:{scale:"color",field:"category"},size:{value:50},shape:{value:p},tooltip:{signal:`(datum.xLabel != null ? datum.xLabel : format(datum.xValue, ',.0f')) + ' · ' + datum.category + ': ' + (datum.yLabel != null ? datum.yLabel : '${m}' + format(datum.yValue, ',${c}'))`}}}}]}}render(){return t(a,{key:"7799f01536f212d7a06da08c1e463d8529c5bf21"},t("div",{key:"25463f10bbc0f5443c35ab03b5b53164d9ad1efd",id:"container",style:{width:"100%",height:"100%"}}))}},[513,"apollo-data-line-chart",{adData:[1,"ad-data"],adSpec:[1,"ad-spec"]}]),d=r,s=function(){"undefined"!=typeof customElements&&["apollo-data-line-chart"].forEach((e=>{"apollo-data-line-chart"===e&&(customElements.get(l(e))||customElements.define(l(e),r))}))};export{d as ApolloDataLineChart,s as defineCustomElement}
@@ -0,0 +1 @@
1
+ const f=["#4d1ab2","#f99170","#e550c8","#ffd563","#8857fa","#52ebba","#bf1d78","#31cff8"];export{f as C}