@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.
@@ -67655,7 +67655,7 @@ class ApolloBase {
67655
67655
 
67656
67656
  const CHART_COLORS = ['#4d1ab2', '#f99170', '#e550c8', '#ffd563', '#8857fa', '#52ebba', '#bf1d78', '#31cff8'];
67657
67657
 
67658
- const FONT_FAMILY = "apple-system, system-ui, 'Segoe UI', Arial, Helvetica, Roboto, sans-serif";
67658
+ const FONT_FAMILY$1 = "apple-system, system-ui, 'Segoe UI', Arial, Helvetica, Roboto, sans-serif";
67659
67659
  const ApolloDataBarChart = class extends ApolloBase {
67660
67660
  constructor(hostRef) {
67661
67661
  super();
@@ -67745,28 +67745,28 @@ const ApolloDataBarChart = class extends ApolloBase {
67745
67745
  config: {
67746
67746
  text: {
67747
67747
  fill: '#6a6d7d',
67748
- font: FONT_FAMILY,
67748
+ font: FONT_FAMILY$1,
67749
67749
  labelFontSize: 12,
67750
67750
  labelFontWeight: 400,
67751
67751
  },
67752
67752
  axis: {
67753
67753
  labelColor: '#6a6d7d',
67754
67754
  titleColor: '#6a6d7d',
67755
- labelFont: FONT_FAMILY,
67756
- titleFont: FONT_FAMILY,
67755
+ labelFont: FONT_FAMILY$1,
67756
+ titleFont: FONT_FAMILY$1,
67757
67757
  titleFontWeight: 400,
67758
67758
  },
67759
67759
  legend: {
67760
67760
  labelColor: '#6a6d7d',
67761
67761
  titleColor: '#6a6d7d',
67762
- labelFont: FONT_FAMILY,
67763
- titleFont: FONT_FAMILY,
67762
+ labelFont: FONT_FAMILY$1,
67763
+ titleFont: FONT_FAMILY$1,
67764
67764
  labelFontSize: 12,
67765
67765
  labelLimit: 95,
67766
67766
  },
67767
67767
  title: {
67768
67768
  color: '#6a6d7d',
67769
- font: FONT_FAMILY,
67769
+ font: FONT_FAMILY$1,
67770
67770
  labelFontSize: 12,
67771
67771
  labelFontWeight: 400,
67772
67772
  },
@@ -68364,5 +68364,292 @@ const ApolloDataDonutChart = class extends ApolloBase {
68364
68364
  }
68365
68365
  };
68366
68366
 
68367
+ const FONT_FAMILY = "apple-system, system-ui, 'Segoe UI', Arial, Helvetica, Roboto, sans-serif";
68368
+ function lineStyleToStrokeDash(lineStyle) {
68369
+ switch (lineStyle) {
68370
+ case 'dashed':
68371
+ return [6, 4];
68372
+ case 'dotted':
68373
+ return [2, 2];
68374
+ case 'solid':
68375
+ default:
68376
+ return [];
68377
+ }
68378
+ }
68379
+ const ApolloDataLineChart = class extends ApolloBase {
68380
+ constructor(hostRef) {
68381
+ super();
68382
+ index$2.registerInstance(this, hostRef);
68383
+ }
68384
+ get el() { return index$2.getElement(this); }
68385
+ adData = [];
68386
+ adSpec = null;
68387
+ static tooltipStylesInjected = false;
68388
+ componentDidLoad() {
68389
+ this.injectTooltipStyles();
68390
+ }
68391
+ async componentDidRender() {
68392
+ await this.renderChart();
68393
+ }
68394
+ injectTooltipStyles() {
68395
+ if (ApolloDataLineChart.tooltipStylesInjected) {
68396
+ return;
68397
+ }
68398
+ const styleId = 'apollo-data-line-tooltip-styles';
68399
+ if (document.getElementById(styleId)) {
68400
+ ApolloDataLineChart.tooltipStylesInjected = true;
68401
+ return;
68402
+ }
68403
+ const style = document.createElement('style');
68404
+ style.id = styleId;
68405
+ style.textContent = `
68406
+ #vg-tooltip-element {
68407
+ background-color: #ffffff;
68408
+ border: 1px solid #e1e2e8;
68409
+ border-radius: 0.25rem;
68410
+ box-shadow: 0 4px 6px -1px rgba(48, 45, 59, 0.1), 0 2px 4px -1px rgba(48, 45, 59, 0.05);
68411
+ font-family: apple-system, system-ui, 'Segoe UI', Arial, Helvetica, Roboto, sans-serif;
68412
+ font-weight: 500;
68413
+ padding: 0.25rem 0.75rem;
68414
+ pointer-events: none;
68415
+ text-align: center;
68416
+ transform: translateY(20%);
68417
+ white-space: pre;
68418
+ z-index: 999999999;
68419
+ }
68420
+
68421
+ #vg-tooltip-element table tr td.key {
68422
+ color: #6a6d7d;
68423
+ text-align: center;
68424
+ }
68425
+
68426
+ #vg-tooltip-element table tr td.value {
68427
+ text-align: center;
68428
+ }
68429
+
68430
+ #vg-tooltip-element.dark-theme {
68431
+ background-color: #292632;
68432
+ border: 1px solid #6a6d7d;
68433
+ box-shadow: 0 4px 6px -1px rgba(48, 45, 59, 0.1), 0 2px 4px -1px rgba(48, 45, 59, 0.5);
68434
+ color: #ffffff;
68435
+ }
68436
+
68437
+ #vg-tooltip-element::after {
68438
+ border-color: rgba(255, 255, 255, 0.95) transparent transparent transparent;
68439
+ border-style: solid;
68440
+ border-width: 9px;
68441
+ bottom: -17px;
68442
+ content: '';
68443
+ left: 50%;
68444
+ position: absolute;
68445
+ transform: translateX(-50%);
68446
+ }
68447
+ `;
68448
+ document.head.appendChild(style);
68449
+ ApolloDataLineChart.tooltipStylesInjected = true;
68450
+ }
68451
+ // @ts-ignore
68452
+ async getViewData(data, spec) {
68453
+ if (!spec) {
68454
+ throw new Error('adSpec is required for apollo-data-line-chart');
68455
+ }
68456
+ const { tooltipPrefix = '', currencySymbol = '' } = spec;
68457
+ if (!data || data.length === 0) {
68458
+ throw new Error('Data is required for apollo-data-line-chart');
68459
+ }
68460
+ const uniqueCategories = Array.from(new Set(data.map(item => item.category)));
68461
+ const uniqueXValues = [...new Set(data.map(item => item.xValue))].sort((a, b) => a - b);
68462
+ const colorSet = spec?.colorSet ?? CHART_COLORS;
68463
+ const xLabelData = uniqueXValues.map(x => {
68464
+ const first = data.find(d => d.xValue === x);
68465
+ return { xValue: x, displayLabel: first?.xLabel != null ? first.xLabel : String(x) };
68466
+ });
68467
+ const formatNumber = tooltipPrefix ? '.2f' : '.0f';
68468
+ const currencyPrefix = tooltipPrefix ? currencySymbol : '';
68469
+ const pointShape = spec.pointStyle ?? 'circle';
68470
+ const strokeDash = lineStyleToStrokeDash(spec.lineStyle ?? 'solid');
68471
+ const dataSpec = [
68472
+ { name: 'raw', values: data },
68473
+ { name: 'xLabelData', values: xLabelData },
68474
+ ];
68475
+ uniqueCategories.forEach((cat, i) => {
68476
+ dataSpec.push({
68477
+ name: `series_${i}`,
68478
+ source: 'raw',
68479
+ transform: [
68480
+ { type: 'filter', expr: `datum.category === ${JSON.stringify(cat)}` },
68481
+ { type: 'collect', sort: { field: 'xValue' } },
68482
+ ],
68483
+ });
68484
+ });
68485
+ const lineMarks = uniqueCategories.map((_, i) => ({
68486
+ type: 'line',
68487
+ from: { data: `series_${i}` },
68488
+ encode: {
68489
+ enter: {
68490
+ x: { scale: 'x', field: 'xValue' },
68491
+ y: { scale: 'y', field: 'yValue' },
68492
+ stroke: { value: colorSet[i % colorSet.length] },
68493
+ strokeWidth: { value: 2 },
68494
+ interpolate: { value: 'monotone' },
68495
+ ...(strokeDash.length > 0 ? { strokeDash: { value: strokeDash } } : {}),
68496
+ },
68497
+ },
68498
+ }));
68499
+ return {
68500
+ $schema: 'https://vega.github.io/schema/vega/v5.json',
68501
+ config: {
68502
+ text: {
68503
+ fill: '#6a6d7d',
68504
+ font: FONT_FAMILY,
68505
+ labelFontSize: 12,
68506
+ labelFontWeight: 400,
68507
+ },
68508
+ axis: {
68509
+ labelColor: '#6a6d7d',
68510
+ titleColor: '#6a6d7d',
68511
+ labelFont: FONT_FAMILY,
68512
+ titleFont: FONT_FAMILY,
68513
+ titleFontWeight: 400,
68514
+ },
68515
+ legend: {
68516
+ labelColor: '#6a6d7d',
68517
+ titleColor: '#6a6d7d',
68518
+ labelFont: FONT_FAMILY,
68519
+ titleFont: FONT_FAMILY,
68520
+ labelFontSize: 12,
68521
+ labelLimit: 95,
68522
+ },
68523
+ title: {
68524
+ color: '#6a6d7d',
68525
+ font: FONT_FAMILY,
68526
+ labelFontSize: 12,
68527
+ labelFontWeight: 400,
68528
+ },
68529
+ },
68530
+ height: 250,
68531
+ autosize: { type: 'fit-x', contains: 'padding', resize: true },
68532
+ signals: [
68533
+ {
68534
+ name: 'containerW',
68535
+ update: 'max(containerSize()[0], 400)',
68536
+ },
68537
+ {
68538
+ name: 'legendColumns',
68539
+ update: 'ceil(containerW / 140)',
68540
+ },
68541
+ ],
68542
+ width: { signal: 'containerW' },
68543
+ data: dataSpec,
68544
+ scales: [
68545
+ {
68546
+ name: 'x',
68547
+ type: 'point',
68548
+ domain: uniqueXValues,
68549
+ range: 'width',
68550
+ padding: 0.5,
68551
+ },
68552
+ {
68553
+ name: 'xLabels',
68554
+ type: 'ordinal',
68555
+ domain: { data: 'xLabelData', field: 'xValue' },
68556
+ range: { data: 'xLabelData', field: 'displayLabel' },
68557
+ },
68558
+ {
68559
+ name: 'y',
68560
+ type: 'linear',
68561
+ domain: { data: 'raw', field: 'yValue' },
68562
+ nice: true,
68563
+ zero: true,
68564
+ range: 'height',
68565
+ },
68566
+ {
68567
+ name: 'color',
68568
+ type: 'ordinal',
68569
+ domain: uniqueCategories,
68570
+ range: spec?.colorSet ?? CHART_COLORS,
68571
+ },
68572
+ ],
68573
+ axes: [
68574
+ {
68575
+ orient: 'bottom',
68576
+ scale: 'x',
68577
+ title: spec?.xAxisTitle,
68578
+ labelPadding: 12,
68579
+ titlePadding: 12,
68580
+ labelAngle: -90,
68581
+ labelAlign: 'right',
68582
+ labelBaseline: 'middle',
68583
+ tickSize: 3,
68584
+ labelFontSize: 12,
68585
+ titleFontSize: 14,
68586
+ ticks: false,
68587
+ domain: false,
68588
+ encode: {
68589
+ labels: {
68590
+ update: {
68591
+ text: { signal: "scale('xLabels', datum.value)" },
68592
+ },
68593
+ },
68594
+ },
68595
+ },
68596
+ {
68597
+ orient: 'left',
68598
+ scale: 'y',
68599
+ title: spec?.yAxisTitle || '',
68600
+ format: ',.0f',
68601
+ grid: true,
68602
+ tickCount: 6,
68603
+ labelFontSize: 12,
68604
+ titleFontSize: 14,
68605
+ ticks: false,
68606
+ domain: false,
68607
+ tickBand: 'extent',
68608
+ labelPadding: 10,
68609
+ },
68610
+ ],
68611
+ legends: [
68612
+ {
68613
+ stroke: 'color',
68614
+ orient: 'bottom',
68615
+ direction: 'horizontal',
68616
+ columns: { signal: 'legendColumns' },
68617
+ title: null,
68618
+ symbolType: 'stroke',
68619
+ symbolStrokeWidth: 3,
68620
+ rowPadding: 8,
68621
+ symbolOffset: -35,
68622
+ symbolSize: 100,
68623
+ labelOffset: 8,
68624
+ labelLimit: 95,
68625
+ },
68626
+ ],
68627
+ marks: [
68628
+ ...lineMarks,
68629
+ {
68630
+ type: 'symbol',
68631
+ from: { data: 'raw' },
68632
+ encode: {
68633
+ enter: {
68634
+ x: { scale: 'x', field: 'xValue' },
68635
+ y: { scale: 'y', field: 'yValue' },
68636
+ fill: { scale: 'color', field: 'category' },
68637
+ size: { value: 50 },
68638
+ shape: { value: pointShape },
68639
+ tooltip: {
68640
+ signal: `(datum.xLabel != null ? datum.xLabel : format(datum.xValue, ',.0f')) + ' · ' + datum.category + ': ' + (datum.yLabel != null ? datum.yLabel : '${currencyPrefix}' + format(datum.yValue, ',${formatNumber}'))`,
68641
+ },
68642
+ },
68643
+ },
68644
+ },
68645
+ ],
68646
+ };
68647
+ }
68648
+ render() {
68649
+ return (index$2.h(index$2.Host, { key: '7799f01536f212d7a06da08c1e463d8529c5bf21' }, index$2.h("div", { key: '25463f10bbc0f5443c35ab03b5b53164d9ad1efd', id: "container", style: { width: '100%', height: '100%' } })));
68650
+ }
68651
+ };
68652
+
68367
68653
  exports.apollo_data_bar_chart = ApolloDataBarChart;
68368
68654
  exports.apollo_data_donut_chart = ApolloDataDonutChart;
68655
+ exports.apollo_data_line_chart = ApolloDataLineChart;
@@ -19,7 +19,7 @@ var patchBrowser = () => {
19
19
 
20
20
  patchBrowser().then(async (options) => {
21
21
  await appGlobals.globalScripts();
22
- return index.bootstrapLazy([["apollo-data-bar-chart_2.cjs",[[513,"apollo-data-bar-chart",{"adData":[1,"ad-data"],"adSpec":[1,"ad-spec"]}],[513,"apollo-data-donut-chart",{"adData":[1,"ad-data"],"adSpec":[1,"ad-spec"]}]]]], options);
22
+ return index.bootstrapLazy([["apollo-data-bar-chart_3.cjs",[[513,"apollo-data-bar-chart",{"adData":[1,"ad-data"],"adSpec":[1,"ad-spec"]}],[513,"apollo-data-donut-chart",{"adData":[1,"ad-data"],"adSpec":[1,"ad-spec"]}],[513,"apollo-data-line-chart",{"adData":[1,"ad-data"],"adSpec":[1,"ad-spec"]}]]]], options);
23
23
  });
24
24
 
25
25
  exports.setNonce = index.setNonce;
@@ -6,7 +6,7 @@ var appGlobals = require('./app-globals-V2Kpy_OQ.js');
6
6
  const defineCustomElements = async (win, options) => {
7
7
  if (typeof window === 'undefined') return undefined;
8
8
  await appGlobals.globalScripts();
9
- return index.bootstrapLazy([["apollo-data-bar-chart_2.cjs",[[513,"apollo-data-bar-chart",{"adData":[1,"ad-data"],"adSpec":[1,"ad-spec"]}],[513,"apollo-data-donut-chart",{"adData":[1,"ad-data"],"adSpec":[1,"ad-spec"]}]]]], options);
9
+ return index.bootstrapLazy([["apollo-data-bar-chart_3.cjs",[[513,"apollo-data-bar-chart",{"adData":[1,"ad-data"],"adSpec":[1,"ad-spec"]}],[513,"apollo-data-donut-chart",{"adData":[1,"ad-data"],"adSpec":[1,"ad-spec"]}],[513,"apollo-data-line-chart",{"adData":[1,"ad-data"],"adSpec":[1,"ad-spec"]}]]]], options);
10
10
  };
11
11
 
12
12
  exports.setNonce = index.setNonce;
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "entries": [
3
3
  "components/apollo-data-bar/apollo-data-bar.js",
4
- "components/apollo-data-donut/apollo-data-donut.js"
4
+ "components/apollo-data-donut/apollo-data-donut.js",
5
+ "components/apollo-data-line/apollo-data-line.js"
5
6
  ],
6
7
  "compiler": {
7
8
  "name": "@stencil/core",