@c2n/chart 0.0.7 → 0.0.9

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 (58) hide show
  1. package/README.md +44 -14
  2. package/dist/area-chart.js +2 -2
  3. package/dist/bar-chart.js +5 -4
  4. package/dist/candlestick-chart.js +139 -0
  5. package/dist/{chart-base-C4-1TyKq.js → chart-base-CEZvMKwW.js} +106 -13
  6. package/dist/chart-base.js +1 -1
  7. package/dist/chart-legend-DJE3HO7C.js +49 -0
  8. package/dist/chart-legend.js +2 -0
  9. package/dist/chart-link-C9vN9Y6c.js +75 -0
  10. package/dist/chart-series.js +75 -1
  11. package/dist/chart-theme.js +4 -2
  12. package/dist/chart-tooltip-J-oC2DKZ.js +130 -0
  13. package/dist/chart-tooltip.js +2 -0
  14. package/dist/chart.js +11 -5
  15. package/dist/decorate-BkO8ArQg.js +9 -0
  16. package/dist/{echarts-chart-base-LogCQN10.js → echarts-chart-base-CImXMzVk.js} +8 -5
  17. package/dist/echarts-chart-base.js +1 -1
  18. package/dist/gauge-chart.js +111 -0
  19. package/dist/line-chart.js +4 -3
  20. package/dist/pie-chart.js +26 -3
  21. package/dist/radar-chart.js +109 -0
  22. package/dist/scatter-chart.js +40 -0
  23. package/dist/sparkline.js +4 -4
  24. package/dist/{uplot-chart-base-BWr0zJE2.js → uplot-chart-base-CLhgOeM_.js} +21 -5
  25. package/dist/uplot-chart-base.js +1 -1
  26. package/dist/{uplot-paths-ChKohvIX.js → uplot-paths-D5HCEKRV.js} +9 -4
  27. package/package.json +31 -3
  28. package/react.d.ts +12 -0
  29. package/types/src/candlestick-chart.d.ts +52 -0
  30. package/types/src/candlestick-chart.d.ts.map +1 -0
  31. package/types/src/chart-base.d.ts +41 -4
  32. package/types/src/chart-base.d.ts.map +1 -1
  33. package/types/src/chart-legend.d.ts +37 -0
  34. package/types/src/chart-legend.d.ts.map +1 -0
  35. package/types/src/chart-link.d.ts +26 -0
  36. package/types/src/chart-link.d.ts.map +1 -0
  37. package/types/src/chart-theme.d.ts +2 -0
  38. package/types/src/chart-theme.d.ts.map +1 -1
  39. package/types/src/chart-tooltip.d.ts +42 -0
  40. package/types/src/chart-tooltip.d.ts.map +1 -0
  41. package/types/src/chart.d.ts +13 -1
  42. package/types/src/chart.d.ts.map +1 -1
  43. package/types/src/echarts-chart-base.d.ts.map +1 -1
  44. package/types/src/engines/echarts-loader.d.ts +1 -1
  45. package/types/src/engines/echarts-loader.d.ts.map +1 -1
  46. package/types/src/engines/uplot-adapter.d.ts.map +1 -1
  47. package/types/src/engines/uplot-paths.d.ts +1 -1
  48. package/types/src/engines/uplot-paths.d.ts.map +1 -1
  49. package/types/src/gauge-chart.d.ts +54 -0
  50. package/types/src/gauge-chart.d.ts.map +1 -0
  51. package/types/src/pie-chart.d.ts +6 -0
  52. package/types/src/pie-chart.d.ts.map +1 -1
  53. package/types/src/radar-chart.d.ts +55 -0
  54. package/types/src/radar-chart.d.ts.map +1 -0
  55. package/types/src/scatter-chart.d.ts +41 -0
  56. package/types/src/scatter-chart.d.ts.map +1 -0
  57. package/vue.d.ts +104 -0
  58. package/dist/chart-series-BnpHO3lm.js +0 -83
@@ -0,0 +1,75 @@
1
+ import { t as __decorate } from "./decorate-BkO8ArQg.js";
2
+ import { property } from "lit/decorators.js";
3
+ import { LitElement, isServer } from "lit";
4
+ //#region src/chart-link.ts
5
+ /** Resolves and follows a chart by id within the companion's document or shadow root. */
6
+ var ChartLinkedElement = class ChartLinkedElement extends LitElement {
7
+ constructor(..._args) {
8
+ super(..._args);
9
+ this.for = "";
10
+ }
11
+ static #watchers = /* @__PURE__ */ new WeakMap();
12
+ #watchedRoot;
13
+ connectedCallback() {
14
+ super.connectedCallback();
15
+ if (isServer) return;
16
+ queueMicrotask(() => this.#resolveChart());
17
+ const root = this.getRootNode();
18
+ const observed = root instanceof Document ? root.documentElement : root;
19
+ let watcher = ChartLinkedElement.#watchers.get(root);
20
+ if (!watcher) {
21
+ const elements = /* @__PURE__ */ new Set();
22
+ const observer = new MutationObserver(() => elements.forEach((element) => element.#resolveChart()));
23
+ observer.observe(observed, {
24
+ childList: true,
25
+ subtree: true,
26
+ attributes: true,
27
+ attributeFilter: ["id"]
28
+ });
29
+ watcher = {
30
+ elements,
31
+ observer
32
+ };
33
+ ChartLinkedElement.#watchers.set(root, watcher);
34
+ }
35
+ watcher.elements.add(this);
36
+ this.#watchedRoot = root;
37
+ }
38
+ disconnectedCallback() {
39
+ super.disconnectedCallback();
40
+ if (this.#watchedRoot) {
41
+ const watcher = ChartLinkedElement.#watchers.get(this.#watchedRoot);
42
+ watcher?.elements.delete(this);
43
+ if (watcher?.elements.size === 0) {
44
+ watcher.observer.disconnect();
45
+ ChartLinkedElement.#watchers.delete(this.#watchedRoot);
46
+ }
47
+ }
48
+ this.#watchedRoot = void 0;
49
+ this.#setChart(void 0);
50
+ }
51
+ willUpdate(changed) {
52
+ if (changed.has("for") && !isServer) queueMicrotask(() => this.#resolveChart());
53
+ }
54
+ chartConnected(_chart) {}
55
+ chartDisconnected(_chart) {}
56
+ #resolveChart() {
57
+ const root = this.getRootNode();
58
+ const candidate = this.for && (root instanceof Document || root instanceof ShadowRoot) ? root.getElementById(this.for) : null;
59
+ const chart = candidate && "getLegendItems" in candidate && "getTooltipContext" in candidate && "getPlotBounds" in candidate && "registerLegendPresenter" in candidate && "unregisterLegendPresenter" in candidate && "registerTooltipPresenter" in candidate && "unregisterTooltipPresenter" in candidate ? candidate : void 0;
60
+ this.#setChart(chart);
61
+ }
62
+ #setChart(chart) {
63
+ if (chart === this.chart) return;
64
+ if (this.chart) this.chartDisconnected(this.chart);
65
+ this.chart = chart;
66
+ if (chart) this.chartConnected(chart);
67
+ this.requestUpdate();
68
+ }
69
+ };
70
+ __decorate([property({
71
+ type: String,
72
+ reflect: true
73
+ })], ChartLinkedElement.prototype, "for", void 0);
74
+ //#endregion
75
+ export { ChartLinkedElement as t };
@@ -1,2 +1,76 @@
1
- import { n as SERIES_CHANGE_EVENT, r as SERIES_TAG, t as ChartSeries } from "./chart-series-BnpHO3lm.js";
1
+ import { t as __decorate } from "./decorate-BkO8ArQg.js";
2
+ import { property } from "lit/decorators.js";
3
+ import { customElement } from "@c2n/core/element-helper.js";
4
+ import { LitElement, css } from "lit";
5
+ //#region src/chart-series.ts
6
+ /** Fired at the parent chart whenever a series definition changes. */
7
+ var SERIES_CHANGE_EVENT = "c2-chart-series-change";
8
+ /** The tag, so a chart can match a definition by name rather than by class identity. */
9
+ var SERIES_TAG = "c2-chart-series";
10
+ var ChartSeries = class ChartSeries extends LitElement {
11
+ constructor(..._args) {
12
+ super(..._args);
13
+ this.field = "";
14
+ this.axis = "left";
15
+ this.spanGaps = false;
16
+ this.hidden = false;
17
+ }
18
+ static {
19
+ this.styles = css`
20
+ :host {
21
+ display: none;
22
+ }
23
+ `;
24
+ }
25
+ /** A plain snapshot of this definition, so the chart never holds a reference to the element. */
26
+ toConfig() {
27
+ return {
28
+ field: this.field,
29
+ label: this.label,
30
+ color: this.color,
31
+ lineWidth: this.lineWidth,
32
+ axis: this.axis,
33
+ spanGaps: this.spanGaps,
34
+ hidden: this.hidden,
35
+ format: this.format
36
+ };
37
+ }
38
+ connectedCallback() {
39
+ super.connectedCallback();
40
+ this.#notify();
41
+ }
42
+ disconnectedCallback() {
43
+ super.disconnectedCallback();
44
+ this.#notify();
45
+ }
46
+ updated(_changed) {
47
+ this.#notify();
48
+ }
49
+ /** Composed so it crosses the shadow boundary of a chart that wraps its slot; the chart stops it there. */
50
+ #notify() {
51
+ this.dispatchEvent(new CustomEvent(SERIES_CHANGE_EVENT, {
52
+ bubbles: true,
53
+ composed: true
54
+ }));
55
+ }
56
+ };
57
+ __decorate([property({ type: String })], ChartSeries.prototype, "field", void 0);
58
+ __decorate([property({ type: String })], ChartSeries.prototype, "label", void 0);
59
+ __decorate([property({ type: String })], ChartSeries.prototype, "color", void 0);
60
+ __decorate([property({
61
+ type: Number,
62
+ attribute: "line-width"
63
+ })], ChartSeries.prototype, "lineWidth", void 0);
64
+ __decorate([property({ type: String })], ChartSeries.prototype, "axis", void 0);
65
+ __decorate([property({
66
+ type: Boolean,
67
+ attribute: "span-gaps"
68
+ })], ChartSeries.prototype, "spanGaps", void 0);
69
+ __decorate([property({
70
+ type: Boolean,
71
+ reflect: true
72
+ })], ChartSeries.prototype, "hidden", void 0);
73
+ __decorate([property({ attribute: false })], ChartSeries.prototype, "format", void 0);
74
+ ChartSeries = __decorate([customElement("c2-chart-series")], ChartSeries);
75
+ //#endregion
2
76
  export { ChartSeries, SERIES_CHANGE_EVENT, SERIES_TAG };
@@ -61,7 +61,8 @@ var FALLBACK = {
61
61
  fontFamily: "inherit",
62
62
  fontSize: 12,
63
63
  lineWidth: 2,
64
- pointRadius: 2.5
64
+ pointRadius: 2.5,
65
+ barRadius: 0
65
66
  };
66
67
  /**
67
68
  * Resolves and caches the host's chart theme, and invalidates it whenever the page's colour scheme moves.
@@ -143,7 +144,8 @@ var ChartThemeController = class {
143
144
  fontFamily: style.getPropertyValue("--c2-chart--font-family").trim() || FALLBACK.fontFamily,
144
145
  fontSize: scalar("--c2-chart--font-size", FALLBACK.fontSize),
145
146
  lineWidth: scalar("--c2-chart__line--width", FALLBACK.lineWidth),
146
- pointRadius: scalar("--c2-chart__point--radius", FALLBACK.pointRadius)
147
+ pointRadius: scalar("--c2-chart__point--radius", FALLBACK.pointRadius),
148
+ barRadius: Math.min(.5, Math.max(0, scalar("--c2-chart__bar--border-radius", FALLBACK.barRadius)))
147
149
  };
148
150
  }
149
151
  };
@@ -0,0 +1,130 @@
1
+ import { t as __decorate } from "./decorate-BkO8ArQg.js";
2
+ import { t as ChartLinkedElement } from "./chart-link-C9vN9Y6c.js";
3
+ import { property, query } from "lit/decorators.js";
4
+ import { customElement } from "@c2n/core/element-helper.js";
5
+ import { html, isServer, unsafeCSS } from "lit";
6
+ //#region src/chart-tooltip.scss?inline
7
+ var chart_tooltip_default = "/* ex : var((width: 24px), width, c2-checkbox) returns var(--c2-checkbox-width, 24px) */\n:host {\n position: fixed;\n z-index: 1000;\n display: block;\n pointer-events: none;\n}\n\n:host([hidden]) {\n display: none;\n}\n\n:host([position=inline]) {\n position: static;\n}\n\n.bubble {\n display: flex;\n flex-direction: column;\n gap: var(--c2-chart__tooltip--gap,6px);\n padding: var(--c2-chart__tooltip--padding,8px 10px);\n border-radius: var(--c2-chart__tooltip--border-radius,6px);\n background: var(--c2-chart__tooltip--background-color,#18181b);\n color: var(--c2-chart__tooltip--color,#fafafa);\n font-size: var(--c2-chart__tooltip--font-size,12px);\n box-shadow: var(--c2-chart__tooltip--box-shadow,0 8px 24px rgba(24, 24, 27, 0.08));\n white-space: nowrap;\n}\n\n.row {\n display: flex;\n align-items: center;\n gap: 6px;\n}\n\n.marker {\n width: var(--c2-chart__legend-marker--size,10px);\n height: var(--c2-chart__legend-marker--size,10px);\n border-radius: var(--c2-chart__legend-marker--border-radius,999px);\n flex: none;\n}\n\n.label {\n flex: 1 1 auto;\n}\n\n.value {\n font-variant-numeric: tabular-nums;\n font-weight: 600;\n}";
8
+ //#endregion
9
+ //#region src/chart-tooltip.ts
10
+ var ChartTooltip = class ChartTooltip extends ChartLinkedElement {
11
+ static {
12
+ this.styles = unsafeCSS(chart_tooltip_default);
13
+ }
14
+ #context;
15
+ #handleViewportChange;
16
+ constructor() {
17
+ super();
18
+ this.position = "floating";
19
+ this.placement = "top";
20
+ this.#context = null;
21
+ this.#handleViewportChange = () => this.#position();
22
+ this.#handleTooltipChange = (event) => {
23
+ const next = event.detail;
24
+ const contentChanged = !sameTooltipContent(this.#context, next);
25
+ this.#context = next;
26
+ this.hidden = !next;
27
+ if (contentChanged) this.requestUpdate();
28
+ this.updateComplete.then(() => this.#position());
29
+ };
30
+ this.hidden = true;
31
+ }
32
+ connectedCallback() {
33
+ super.connectedCallback();
34
+ if (isServer) return;
35
+ window.addEventListener("resize", this.#handleViewportChange);
36
+ window.addEventListener("scroll", this.#handleViewportChange, true);
37
+ }
38
+ disconnectedCallback() {
39
+ if (!isServer) {
40
+ window.removeEventListener("resize", this.#handleViewportChange);
41
+ window.removeEventListener("scroll", this.#handleViewportChange, true);
42
+ }
43
+ super.disconnectedCallback();
44
+ }
45
+ #handleTooltipChange;
46
+ chartConnected(chart) {
47
+ chart.registerTooltipPresenter(this);
48
+ chart.addEventListener("tooltip-change", this.#handleTooltipChange);
49
+ this.#handleTooltipChange(new CustomEvent("tooltip-change", { detail: chart.getTooltipContext() }));
50
+ }
51
+ chartDisconnected(chart) {
52
+ chart.removeEventListener("tooltip-change", this.#handleTooltipChange);
53
+ chart.unregisterTooltipPresenter(this);
54
+ this.#context = null;
55
+ this.hidden = true;
56
+ }
57
+ updated(changed) {
58
+ super.updated(changed);
59
+ if (changed.has("position") || changed.has("placement") || changed.has("renderTooltip")) this.#position();
60
+ }
61
+ render() {
62
+ const context = this.#context;
63
+ return html`
64
+ <div class="bubble" part="bubble" role="tooltip">
65
+ <slot>
66
+ ${context ? this.renderTooltip?.(context) ?? html`
67
+ <div>${context.formattedX}</div>
68
+ ${context.entries.map((entry) => html`
69
+ <div class="row">
70
+ <span class="marker" style="background:${entry.color}"></span>
71
+ <span class="label">${entry.series.label ?? entry.series.field}</span>
72
+ <span class="value">${entry.formatted}</span>
73
+ </div>
74
+ `)}
75
+ ` : void 0}
76
+ </slot>
77
+ </div>
78
+ `;
79
+ }
80
+ #position() {
81
+ if (this.position === "inline") {
82
+ this.style.removeProperty("left");
83
+ this.style.removeProperty("top");
84
+ return;
85
+ }
86
+ const context = this.#context;
87
+ const chart = this.chart;
88
+ const bubble = this.bubble;
89
+ if (!context || !chart || !bubble) return;
90
+ const plot = chart.getPlotBounds();
91
+ const bounds = bubble.getBoundingClientRect();
92
+ const anchorX = plot.left + context.px;
93
+ const anchorY = plot.top + context.py;
94
+ const gap = 10;
95
+ const edge = 8;
96
+ let placement = this.placement;
97
+ if (placement === "top" && anchorY - bounds.height - gap < edge) placement = "bottom";
98
+ else if (placement === "bottom" && anchorY + bounds.height + gap > window.innerHeight - edge) placement = "top";
99
+ else if (placement === "start" && anchorX - bounds.width - gap < edge) placement = "end";
100
+ else if (placement === "end" && anchorX + bounds.width + gap > window.innerWidth - edge) placement = "start";
101
+ let left = anchorX - bounds.width / 2;
102
+ let top = placement === "top" ? anchorY - bounds.height - gap : anchorY + gap;
103
+ if (placement === "start" || placement === "end") {
104
+ left = placement === "start" ? anchorX - bounds.width - gap : anchorX + gap;
105
+ top = anchorY - bounds.height / 2;
106
+ }
107
+ left = Math.max(edge, Math.min(left, window.innerWidth - bounds.width - edge));
108
+ top = Math.max(edge, Math.min(top, window.innerHeight - bounds.height - edge));
109
+ this.style.left = `${left}px`;
110
+ this.style.top = `${top}px`;
111
+ }
112
+ };
113
+ __decorate([property({
114
+ type: String,
115
+ reflect: true
116
+ })], ChartTooltip.prototype, "position", void 0);
117
+ __decorate([property({
118
+ type: String,
119
+ reflect: true
120
+ })], ChartTooltip.prototype, "placement", void 0);
121
+ __decorate([property({ attribute: false })], ChartTooltip.prototype, "renderTooltip", void 0);
122
+ __decorate([query(".bubble")], ChartTooltip.prototype, "bubble", void 0);
123
+ ChartTooltip = __decorate([customElement("c2-chart-tooltip")], ChartTooltip);
124
+ function sameTooltipContent(previous, next) {
125
+ if (!previous || !next) return previous === next;
126
+ if (previous.index !== next.index || previous.entries.length !== next.entries.length) return false;
127
+ return previous.entries.every((entry, index) => entry.seriesIndex === next.entries[index]?.seriesIndex && entry.formatted === next.entries[index]?.formatted);
128
+ }
129
+ //#endregion
130
+ export { ChartTooltip as t };
@@ -0,0 +1,2 @@
1
+ import { t as ChartTooltip } from "./chart-tooltip-J-oC2DKZ.js";
2
+ export { ChartTooltip };
package/dist/chart.js CHANGED
@@ -1,13 +1,19 @@
1
- import { t as ChartBase } from "./chart-base-C4-1TyKq.js";
1
+ import { t as ChartBase } from "./chart-base-CEZvMKwW.js";
2
2
  import { isChartFrame } from "./chart-types.js";
3
3
  import { ChartFrameBuilder, columnValue } from "./chart-data.js";
4
4
  import { ChartThemeController, PALETTE_SIZE, PROBE_COLORS } from "./chart-theme.js";
5
- import { n as SERIES_CHANGE_EVENT, t as ChartSeries } from "./chart-series-BnpHO3lm.js";
6
- import { t as UplotChartBase } from "./uplot-chart-base-BWr0zJE2.js";
5
+ import { ChartSeries, SERIES_CHANGE_EVENT } from "./chart-series.js";
6
+ import { t as UplotChartBase } from "./uplot-chart-base-CLhgOeM_.js";
7
7
  import { LineChart } from "./line-chart.js";
8
8
  import { AreaChart } from "./area-chart.js";
9
9
  import { BarChart } from "./bar-chart.js";
10
10
  import { Sparkline } from "./sparkline.js";
11
- import { t as EchartsChartBase } from "./echarts-chart-base-LogCQN10.js";
11
+ import { t as EchartsChartBase } from "./echarts-chart-base-CImXMzVk.js";
12
12
  import { PieChart } from "./pie-chart.js";
13
- export { AreaChart, BarChart, ChartBase, ChartFrameBuilder, ChartSeries, ChartThemeController, EchartsChartBase, LineChart, PALETTE_SIZE, PROBE_COLORS, PieChart, SERIES_CHANGE_EVENT, Sparkline, UplotChartBase, columnValue, isChartFrame };
13
+ import { GaugeChart } from "./gauge-chart.js";
14
+ import { RadarChart } from "./radar-chart.js";
15
+ import { ScatterChart } from "./scatter-chart.js";
16
+ import { CandlestickChart } from "./candlestick-chart.js";
17
+ import { t as ChartLegend } from "./chart-legend-DJE3HO7C.js";
18
+ import { t as ChartTooltip } from "./chart-tooltip-J-oC2DKZ.js";
19
+ export { AreaChart, BarChart, CandlestickChart, ChartBase, ChartFrameBuilder, ChartLegend, ChartSeries, ChartThemeController, ChartTooltip, EchartsChartBase, GaugeChart, LineChart, PALETTE_SIZE, PROBE_COLORS, PieChart, RadarChart, SERIES_CHANGE_EVENT, ScatterChart, Sparkline, UplotChartBase, columnValue, isChartFrame };
@@ -0,0 +1,9 @@
1
+ //#region \0@oxc-project+runtime@0.148.0/helpers/esm/decorate.js
2
+ function __decorate(decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ }
8
+ //#endregion
9
+ export { __decorate as t };
@@ -1,19 +1,18 @@
1
- import { t as ChartBase } from "./chart-base-C4-1TyKq.js";
2
- import { i as __decorate } from "./chart-series-BnpHO3lm.js";
1
+ import { t as ChartBase } from "./chart-base-CEZvMKwW.js";
2
+ import { t as __decorate } from "./decorate-BkO8ArQg.js";
3
3
  import { property } from "lit/decorators.js";
4
4
  //#region src/engines/echarts-loader.ts
5
5
  var LOADERS = {
6
6
  pie: () => import("echarts/charts").then((m) => [m.PieChart]),
7
7
  gauge: () => import("echarts/charts").then((m) => [m.GaugeChart]),
8
+ radar: () => import("echarts/charts").then((m) => [m.RadarChart]),
8
9
  scatter: () => import("echarts/charts").then((m) => [m.ScatterChart]),
9
- heatmap: () => import("echarts/charts").then((m) => [m.HeatmapChart]),
10
10
  candlestick: () => import("echarts/charts").then((m) => [m.CandlestickChart]),
11
11
  bar: () => import("echarts/charts").then((m) => [m.BarChart]),
12
12
  line: () => import("echarts/charts").then((m) => [m.LineChart]),
13
13
  grid: () => import("echarts/components").then((m) => [m.GridComponent]),
14
14
  legend: () => import("echarts/components").then((m) => [m.LegendComponent]),
15
15
  tooltip: () => import("echarts/components").then((m) => [m.TooltipComponent]),
16
- visualMap: () => import("echarts/components").then((m) => [m.VisualMapComponent]),
17
16
  dataZoom: () => import("echarts/components").then((m) => [m.DataZoomComponent])
18
17
  };
19
18
  var corePending;
@@ -206,8 +205,12 @@ var EchartsChartBase = class extends ChartBase {
206
205
  }
207
206
  buildOptions(context) {
208
207
  const { theme, series } = context;
208
+ const animate = this.animation === "auto" && !globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
209
209
  return {
210
- animation: this.animation === "auto",
210
+ animation: animate,
211
+ animationDuration: animate ? 500 : 0,
212
+ animationDurationUpdate: 0,
213
+ animationEasing: "cubicOut",
211
214
  color: theme.palette,
212
215
  textStyle: {
213
216
  fontFamily: theme.fontFamily === "inherit" ? void 0 : theme.fontFamily,
@@ -1,2 +1,2 @@
1
- import { t as EchartsChartBase } from "./echarts-chart-base-LogCQN10.js";
1
+ import { t as EchartsChartBase } from "./echarts-chart-base-CImXMzVk.js";
2
2
  export { EchartsChartBase };
@@ -0,0 +1,111 @@
1
+ import { t as __decorate } from "./decorate-BkO8ArQg.js";
2
+ import "./chart-series.js";
3
+ import { t as EchartsChartBase } from "./echarts-chart-base-CImXMzVk.js";
4
+ import { property } from "lit/decorators.js";
5
+ import { customElement } from "@c2n/core/element-helper.js";
6
+ //#region src/gauge-chart.ts
7
+ var GaugeChart = class GaugeChart extends EchartsChartBase {
8
+ constructor() {
9
+ super();
10
+ this.features = ["gauge"];
11
+ this.min = 0;
12
+ this.max = 100;
13
+ this.startAngle = 225;
14
+ this.endAngle = -45;
15
+ this.splitNumber = 5;
16
+ this.precision = 0;
17
+ this.valueSuffix = "";
18
+ this.progress = "show";
19
+ this.pointer = "show";
20
+ this.marks = "show";
21
+ this.tooltip = "item";
22
+ this.legend = "none";
23
+ }
24
+ coordinateSystem() {
25
+ return {};
26
+ }
27
+ dataShape() {
28
+ return "named";
29
+ }
30
+ seriesOption(index, context) {
31
+ const color = this.colorOf(context.series[index] ?? { field: "" }, index, context.theme);
32
+ const precision = Math.max(0, Math.min(20, Math.trunc(this.precision)));
33
+ const number = new Intl.NumberFormat(this.locale, {
34
+ maximumFractionDigits: precision,
35
+ minimumFractionDigits: precision
36
+ });
37
+ const formatValue = (value) => `${number.format(value)}${this.valueSuffix}`;
38
+ return {
39
+ type: "gauge",
40
+ min: this.min,
41
+ max: this.max,
42
+ startAngle: this.startAngle,
43
+ endAngle: this.endAngle,
44
+ splitNumber: this.splitNumber,
45
+ progress: {
46
+ show: this.progress === "show",
47
+ width: 12,
48
+ roundCap: true,
49
+ itemStyle: { color }
50
+ },
51
+ pointer: {
52
+ show: this.pointer === "show",
53
+ itemStyle: { color }
54
+ },
55
+ axisLine: { lineStyle: {
56
+ width: 12,
57
+ color: [[1, context.theme.gridColor]]
58
+ } },
59
+ axisTick: {
60
+ show: this.marks === "show",
61
+ lineStyle: { color: context.theme.axisColor }
62
+ },
63
+ splitLine: {
64
+ show: this.marks === "show",
65
+ lineStyle: { color: context.theme.axisColor }
66
+ },
67
+ axisLabel: {
68
+ color: context.theme.axisColor,
69
+ fontSize: context.theme.fontSize,
70
+ formatter: formatValue
71
+ },
72
+ title: {
73
+ color: context.theme.mutedColor,
74
+ fontSize: context.theme.fontSize,
75
+ offsetCenter: [0, "25%"]
76
+ },
77
+ detail: {
78
+ color: context.theme.color,
79
+ fontSize: Math.max(20, context.theme.fontSize * 1.8),
80
+ fontWeight: 650,
81
+ offsetCenter: [0, "-3%"],
82
+ formatter: formatValue
83
+ }
84
+ };
85
+ }
86
+ };
87
+ __decorate([property({ type: Number })], GaugeChart.prototype, "min", void 0);
88
+ __decorate([property({ type: Number })], GaugeChart.prototype, "max", void 0);
89
+ __decorate([property({
90
+ type: Number,
91
+ attribute: "start-angle"
92
+ })], GaugeChart.prototype, "startAngle", void 0);
93
+ __decorate([property({
94
+ type: Number,
95
+ attribute: "end-angle"
96
+ })], GaugeChart.prototype, "endAngle", void 0);
97
+ __decorate([property({
98
+ type: Number,
99
+ attribute: "split-number"
100
+ })], GaugeChart.prototype, "splitNumber", void 0);
101
+ __decorate([property({ type: Number })], GaugeChart.prototype, "precision", void 0);
102
+ __decorate([property({
103
+ type: String,
104
+ attribute: "value-suffix"
105
+ })], GaugeChart.prototype, "valueSuffix", void 0);
106
+ __decorate([property({ type: String })], GaugeChart.prototype, "progress", void 0);
107
+ __decorate([property({ type: String })], GaugeChart.prototype, "pointer", void 0);
108
+ __decorate([property({ type: String })], GaugeChart.prototype, "marks", void 0);
109
+ GaugeChart = __decorate([customElement("c2-gauge-chart")], GaugeChart);
110
+ //#endregion
111
+ export { GaugeChart };
@@ -1,6 +1,7 @@
1
- import { i as __decorate } from "./chart-series-BnpHO3lm.js";
2
- import { t as UplotChartBase } from "./uplot-chart-base-BWr0zJE2.js";
3
- import { n as linePaths } from "./uplot-paths-ChKohvIX.js";
1
+ import { t as __decorate } from "./decorate-BkO8ArQg.js";
2
+ import "./chart-series.js";
3
+ import { t as UplotChartBase } from "./uplot-chart-base-CLhgOeM_.js";
4
+ import { n as linePaths } from "./uplot-paths-D5HCEKRV.js";
4
5
  import { property } from "lit/decorators.js";
5
6
  import { customElement } from "@c2n/core/element-helper.js";
6
7
  //#region src/line-chart.ts
package/dist/pie-chart.js CHANGED
@@ -1,5 +1,6 @@
1
- import { i as __decorate } from "./chart-series-BnpHO3lm.js";
2
- import { t as EchartsChartBase } from "./echarts-chart-base-LogCQN10.js";
1
+ import { t as __decorate } from "./decorate-BkO8ArQg.js";
2
+ import "./chart-series.js";
3
+ import { t as EchartsChartBase } from "./echarts-chart-base-CImXMzVk.js";
3
4
  import { property, state } from "lit/decorators.js";
4
5
  import { customElement } from "@c2n/core/element-helper.js";
5
6
  //#region src/pie-chart.ts
@@ -11,11 +12,15 @@ var PieChart = class PieChart extends EchartsChartBase {
11
12
  this.outerRadius = .75;
12
13
  this.startAngle = 90;
13
14
  this.labels = "none";
15
+ this.labelContent = "name";
14
16
  this.sort = "none";
15
17
  this.hiddenSlices = /* @__PURE__ */ new Set();
16
18
  this.tooltip = "item";
17
19
  this.legend = "end";
18
20
  }
21
+ get legendDependsOnData() {
22
+ return true;
23
+ }
19
24
  /** A pie has no grid and no axes at all: contributing them would draw an empty cartesian frame. */
20
25
  coordinateSystem() {
21
26
  return {};
@@ -45,6 +50,11 @@ var PieChart = class PieChart extends EchartsChartBase {
45
50
  else next.add(label);
46
51
  this.hiddenSlices = next;
47
52
  this.adapter?.setDatumVisibility?.(label, visible);
53
+ this.notifyLegendChange();
54
+ }
55
+ restoreVisibility(adapter) {
56
+ super.restoreVisibility(adapter);
57
+ for (const label of this.hiddenSlices) adapter.setDatumVisibility?.(label, false);
48
58
  }
49
59
  dataShape() {
50
60
  return "named";
@@ -59,13 +69,22 @@ var PieChart = class PieChart extends EchartsChartBase {
59
69
  show: this.labels !== "none",
60
70
  position: this.labels === "inside" ? "inside" : "outside",
61
71
  color: this.labels === "inside" ? theme.surface : theme.color,
62
- fontSize: theme.fontSize
72
+ fontSize: theme.fontSize,
73
+ formatter: this.labelFormatter()
63
74
  },
64
75
  labelLine: { show: this.labels === "outside" },
65
76
  itemStyle: sliceBorder(this, theme.surface),
66
77
  sort: this.sort === "none" ? void 0 : this.sort === "asc" ? "ascending" : "descending"
67
78
  };
68
79
  }
80
+ labelFormatter() {
81
+ switch (this.labelContent) {
82
+ case "value": return "{c}";
83
+ case "percent": return "{d}%";
84
+ case "name-percent": return "{b} · {d}%";
85
+ default: return "{b}";
86
+ }
87
+ }
69
88
  };
70
89
  __decorate([property({
71
90
  type: Number,
@@ -80,6 +99,10 @@ __decorate([property({
80
99
  attribute: "start-angle"
81
100
  })], PieChart.prototype, "startAngle", void 0);
82
101
  __decorate([property({ type: String })], PieChart.prototype, "labels", void 0);
102
+ __decorate([property({
103
+ type: String,
104
+ attribute: "label-content"
105
+ })], PieChart.prototype, "labelContent", void 0);
83
106
  __decorate([property({ type: String })], PieChart.prototype, "sort", void 0);
84
107
  __decorate([state()], PieChart.prototype, "hiddenSlices", void 0);
85
108
  PieChart = __decorate([customElement("c2-pie-chart")], PieChart);