@c2n/chart 0.0.7 → 0.0.8
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/README.md +44 -14
- package/dist/area-chart.js +2 -2
- package/dist/bar-chart.js +4 -3
- package/dist/candlestick-chart.js +139 -0
- package/dist/{chart-base-C4-1TyKq.js → chart-base-BwPwRgHt.js} +89 -10
- package/dist/chart-base.js +1 -1
- package/dist/chart-legend-DJE3HO7C.js +49 -0
- package/dist/chart-legend.js +2 -0
- package/dist/chart-link-C9vN9Y6c.js +75 -0
- package/dist/chart-series.js +75 -1
- package/dist/chart-tooltip-J-oC2DKZ.js +130 -0
- package/dist/chart-tooltip.js +2 -0
- package/dist/chart.js +10 -5
- package/dist/decorate-BkO8ArQg.js +9 -0
- package/dist/{echarts-chart-base-LogCQN10.js → echarts-chart-base-6JsZbB05.js} +2 -4
- package/dist/echarts-chart-base.js +1 -1
- package/dist/gauge-chart.js +103 -0
- package/dist/line-chart.js +4 -3
- package/dist/pie-chart.js +11 -2
- package/dist/scatter-chart.js +40 -0
- package/dist/sparkline.js +4 -4
- package/dist/{uplot-chart-base-BWr0zJE2.js → uplot-chart-base-CDHzOLwa.js} +21 -5
- package/dist/uplot-chart-base.js +1 -1
- package/dist/{uplot-paths-ChKohvIX.js → uplot-paths-BRtF33Wh.js} +1 -1
- package/package.json +26 -3
- package/react.d.ts +10 -0
- package/types/src/candlestick-chart.d.ts +52 -0
- package/types/src/candlestick-chart.d.ts.map +1 -0
- package/types/src/chart-base.d.ts +31 -1
- package/types/src/chart-base.d.ts.map +1 -1
- package/types/src/chart-legend.d.ts +37 -0
- package/types/src/chart-legend.d.ts.map +1 -0
- package/types/src/chart-link.d.ts +26 -0
- package/types/src/chart-link.d.ts.map +1 -0
- package/types/src/chart-tooltip.d.ts +42 -0
- package/types/src/chart-tooltip.d.ts.map +1 -0
- package/types/src/chart.d.ts +11 -1
- package/types/src/chart.d.ts.map +1 -1
- package/types/src/engines/echarts-loader.d.ts +1 -1
- package/types/src/engines/echarts-loader.d.ts.map +1 -1
- package/types/src/engines/uplot-adapter.d.ts.map +1 -1
- package/types/src/gauge-chart.d.ts +52 -0
- package/types/src/gauge-chart.d.ts.map +1 -0
- package/types/src/pie-chart.d.ts +3 -0
- package/types/src/pie-chart.d.ts.map +1 -1
- package/types/src/scatter-chart.d.ts +41 -0
- package/types/src/scatter-chart.d.ts.map +1 -0
- package/vue.d.ts +81 -0
- package/dist/chart-series-BnpHO3lm.js +0 -83
package/dist/chart-series.js
CHANGED
|
@@ -1,2 +1,76 @@
|
|
|
1
|
-
import {
|
|
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 };
|
|
@@ -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 };
|
package/dist/chart.js
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
import { t as ChartBase } from "./chart-base-
|
|
1
|
+
import { t as ChartBase } from "./chart-base-BwPwRgHt.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 {
|
|
6
|
-
import { t as UplotChartBase } from "./uplot-chart-base-
|
|
5
|
+
import { ChartSeries, SERIES_CHANGE_EVENT } from "./chart-series.js";
|
|
6
|
+
import { t as UplotChartBase } from "./uplot-chart-base-CDHzOLwa.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-
|
|
11
|
+
import { t as EchartsChartBase } from "./echarts-chart-base-6JsZbB05.js";
|
|
12
12
|
import { PieChart } from "./pie-chart.js";
|
|
13
|
-
|
|
13
|
+
import { GaugeChart } from "./gauge-chart.js";
|
|
14
|
+
import { ScatterChart } from "./scatter-chart.js";
|
|
15
|
+
import { CandlestickChart } from "./candlestick-chart.js";
|
|
16
|
+
import { t as ChartLegend } from "./chart-legend-DJE3HO7C.js";
|
|
17
|
+
import { t as ChartTooltip } from "./chart-tooltip-J-oC2DKZ.js";
|
|
18
|
+
export { AreaChart, BarChart, CandlestickChart, ChartBase, ChartFrameBuilder, ChartLegend, ChartSeries, ChartThemeController, ChartTooltip, EchartsChartBase, GaugeChart, LineChart, PALETTE_SIZE, PROBE_COLORS, PieChart, 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,17 @@
|
|
|
1
|
-
import { t as ChartBase } from "./chart-base-
|
|
2
|
-
import {
|
|
1
|
+
import { t as ChartBase } from "./chart-base-BwPwRgHt.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
8
|
scatter: () => import("echarts/charts").then((m) => [m.ScatterChart]),
|
|
9
|
-
heatmap: () => import("echarts/charts").then((m) => [m.HeatmapChart]),
|
|
10
9
|
candlestick: () => import("echarts/charts").then((m) => [m.CandlestickChart]),
|
|
11
10
|
bar: () => import("echarts/charts").then((m) => [m.BarChart]),
|
|
12
11
|
line: () => import("echarts/charts").then((m) => [m.LineChart]),
|
|
13
12
|
grid: () => import("echarts/components").then((m) => [m.GridComponent]),
|
|
14
13
|
legend: () => import("echarts/components").then((m) => [m.LegendComponent]),
|
|
15
14
|
tooltip: () => import("echarts/components").then((m) => [m.TooltipComponent]),
|
|
16
|
-
visualMap: () => import("echarts/components").then((m) => [m.VisualMapComponent]),
|
|
17
15
|
dataZoom: () => import("echarts/components").then((m) => [m.DataZoomComponent])
|
|
18
16
|
};
|
|
19
17
|
var corePending;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as EchartsChartBase } from "./echarts-chart-base-
|
|
1
|
+
import { t as EchartsChartBase } from "./echarts-chart-base-6JsZbB05.js";
|
|
2
2
|
export { EchartsChartBase };
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { t as __decorate } from "./decorate-BkO8ArQg.js";
|
|
2
|
+
import "./chart-series.js";
|
|
3
|
+
import { t as EchartsChartBase } from "./echarts-chart-base-6JsZbB05.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.tooltip = "item";
|
|
21
|
+
this.legend = "none";
|
|
22
|
+
}
|
|
23
|
+
coordinateSystem() {
|
|
24
|
+
return {};
|
|
25
|
+
}
|
|
26
|
+
dataShape() {
|
|
27
|
+
return "named";
|
|
28
|
+
}
|
|
29
|
+
seriesOption(index, context) {
|
|
30
|
+
const color = this.colorOf(context.series[index] ?? { field: "" }, index, context.theme);
|
|
31
|
+
const precision = Math.max(0, Math.min(20, Math.trunc(this.precision)));
|
|
32
|
+
const number = new Intl.NumberFormat(this.locale, {
|
|
33
|
+
maximumFractionDigits: precision,
|
|
34
|
+
minimumFractionDigits: precision
|
|
35
|
+
});
|
|
36
|
+
const formatValue = (value) => `${number.format(value)}${this.valueSuffix}`;
|
|
37
|
+
return {
|
|
38
|
+
type: "gauge",
|
|
39
|
+
min: this.min,
|
|
40
|
+
max: this.max,
|
|
41
|
+
startAngle: this.startAngle,
|
|
42
|
+
endAngle: this.endAngle,
|
|
43
|
+
splitNumber: this.splitNumber,
|
|
44
|
+
progress: {
|
|
45
|
+
show: this.progress === "show",
|
|
46
|
+
width: 12,
|
|
47
|
+
roundCap: true,
|
|
48
|
+
itemStyle: { color }
|
|
49
|
+
},
|
|
50
|
+
pointer: {
|
|
51
|
+
show: this.pointer === "show",
|
|
52
|
+
itemStyle: { color }
|
|
53
|
+
},
|
|
54
|
+
axisLine: { lineStyle: {
|
|
55
|
+
width: 12,
|
|
56
|
+
color: [[1, context.theme.gridColor]]
|
|
57
|
+
} },
|
|
58
|
+
axisTick: { lineStyle: { color: context.theme.axisColor } },
|
|
59
|
+
splitLine: { lineStyle: { color: context.theme.axisColor } },
|
|
60
|
+
axisLabel: {
|
|
61
|
+
color: context.theme.axisColor,
|
|
62
|
+
fontSize: context.theme.fontSize,
|
|
63
|
+
formatter: formatValue
|
|
64
|
+
},
|
|
65
|
+
title: {
|
|
66
|
+
color: context.theme.mutedColor,
|
|
67
|
+
fontSize: context.theme.fontSize,
|
|
68
|
+
offsetCenter: [0, "43%"]
|
|
69
|
+
},
|
|
70
|
+
detail: {
|
|
71
|
+
color: context.theme.color,
|
|
72
|
+
fontSize: Math.max(20, context.theme.fontSize * 1.8),
|
|
73
|
+
fontWeight: 650,
|
|
74
|
+
offsetCenter: [0, "67%"],
|
|
75
|
+
formatter: formatValue
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
__decorate([property({ type: Number })], GaugeChart.prototype, "min", void 0);
|
|
81
|
+
__decorate([property({ type: Number })], GaugeChart.prototype, "max", void 0);
|
|
82
|
+
__decorate([property({
|
|
83
|
+
type: Number,
|
|
84
|
+
attribute: "start-angle"
|
|
85
|
+
})], GaugeChart.prototype, "startAngle", void 0);
|
|
86
|
+
__decorate([property({
|
|
87
|
+
type: Number,
|
|
88
|
+
attribute: "end-angle"
|
|
89
|
+
})], GaugeChart.prototype, "endAngle", void 0);
|
|
90
|
+
__decorate([property({
|
|
91
|
+
type: Number,
|
|
92
|
+
attribute: "split-number"
|
|
93
|
+
})], GaugeChart.prototype, "splitNumber", void 0);
|
|
94
|
+
__decorate([property({ type: Number })], GaugeChart.prototype, "precision", void 0);
|
|
95
|
+
__decorate([property({
|
|
96
|
+
type: String,
|
|
97
|
+
attribute: "value-suffix"
|
|
98
|
+
})], GaugeChart.prototype, "valueSuffix", void 0);
|
|
99
|
+
__decorate([property({ type: String })], GaugeChart.prototype, "progress", void 0);
|
|
100
|
+
__decorate([property({ type: String })], GaugeChart.prototype, "pointer", void 0);
|
|
101
|
+
GaugeChart = __decorate([customElement("c2-gauge-chart")], GaugeChart);
|
|
102
|
+
//#endregion
|
|
103
|
+
export { GaugeChart };
|
package/dist/line-chart.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
1
|
+
import { t as __decorate } from "./decorate-BkO8ArQg.js";
|
|
2
|
+
import "./chart-series.js";
|
|
3
|
+
import { t as UplotChartBase } from "./uplot-chart-base-CDHzOLwa.js";
|
|
4
|
+
import { n as linePaths } from "./uplot-paths-BRtF33Wh.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 {
|
|
2
|
-
import
|
|
1
|
+
import { t as __decorate } from "./decorate-BkO8ArQg.js";
|
|
2
|
+
import "./chart-series.js";
|
|
3
|
+
import { t as EchartsChartBase } from "./echarts-chart-base-6JsZbB05.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
|
|
@@ -16,6 +17,9 @@ var PieChart = class PieChart extends EchartsChartBase {
|
|
|
16
17
|
this.tooltip = "item";
|
|
17
18
|
this.legend = "end";
|
|
18
19
|
}
|
|
20
|
+
get legendDependsOnData() {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
19
23
|
/** A pie has no grid and no axes at all: contributing them would draw an empty cartesian frame. */
|
|
20
24
|
coordinateSystem() {
|
|
21
25
|
return {};
|
|
@@ -45,6 +49,11 @@ var PieChart = class PieChart extends EchartsChartBase {
|
|
|
45
49
|
else next.add(label);
|
|
46
50
|
this.hiddenSlices = next;
|
|
47
51
|
this.adapter?.setDatumVisibility?.(label, visible);
|
|
52
|
+
this.notifyLegendChange();
|
|
53
|
+
}
|
|
54
|
+
restoreVisibility(adapter) {
|
|
55
|
+
super.restoreVisibility(adapter);
|
|
56
|
+
for (const label of this.hiddenSlices) adapter.setDatumVisibility?.(label, false);
|
|
48
57
|
}
|
|
49
58
|
dataShape() {
|
|
50
59
|
return "named";
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { t as __decorate } from "./decorate-BkO8ArQg.js";
|
|
2
|
+
import "./chart-series.js";
|
|
3
|
+
import { t as EchartsChartBase } from "./echarts-chart-base-6JsZbB05.js";
|
|
4
|
+
import { property } from "lit/decorators.js";
|
|
5
|
+
import { customElement } from "@c2n/core/element-helper.js";
|
|
6
|
+
//#region src/scatter-chart.ts
|
|
7
|
+
var ScatterChart = class ScatterChart extends EchartsChartBase {
|
|
8
|
+
constructor() {
|
|
9
|
+
super();
|
|
10
|
+
this.features = ["scatter", "grid"];
|
|
11
|
+
this.symbolSize = 10;
|
|
12
|
+
this.symbol = "circle";
|
|
13
|
+
this.large = false;
|
|
14
|
+
this.largeThreshold = 2e3;
|
|
15
|
+
this.tooltip = "item";
|
|
16
|
+
}
|
|
17
|
+
seriesOption(index, context) {
|
|
18
|
+
return {
|
|
19
|
+
type: "scatter",
|
|
20
|
+
symbol: this.symbol,
|
|
21
|
+
symbolSize: this.symbolSize,
|
|
22
|
+
large: this.large,
|
|
23
|
+
largeThreshold: this.largeThreshold,
|
|
24
|
+
itemStyle: { color: this.colorOf(context.series[index] ?? { field: "" }, index, context.theme) }
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
__decorate([property({
|
|
29
|
+
type: Number,
|
|
30
|
+
attribute: "symbol-size"
|
|
31
|
+
})], ScatterChart.prototype, "symbolSize", void 0);
|
|
32
|
+
__decorate([property({ type: String })], ScatterChart.prototype, "symbol", void 0);
|
|
33
|
+
__decorate([property({ type: Boolean })], ScatterChart.prototype, "large", void 0);
|
|
34
|
+
__decorate([property({
|
|
35
|
+
type: Number,
|
|
36
|
+
attribute: "large-threshold"
|
|
37
|
+
})], ScatterChart.prototype, "largeThreshold", void 0);
|
|
38
|
+
ScatterChart = __decorate([customElement("c2-scatter-chart")], ScatterChart);
|
|
39
|
+
//#endregion
|
|
40
|
+
export { ScatterChart };
|
package/dist/sparkline.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { n as chart_default } from "./chart-base-
|
|
2
|
-
import {
|
|
3
|
-
import { t as UplotChartBase } from "./uplot-chart-base-
|
|
4
|
-
import { n as linePaths, r as withAlpha } from "./uplot-paths-
|
|
1
|
+
import { n as chart_default } from "./chart-base-BwPwRgHt.js";
|
|
2
|
+
import { t as __decorate } from "./decorate-BkO8ArQg.js";
|
|
3
|
+
import { t as UplotChartBase } from "./uplot-chart-base-CDHzOLwa.js";
|
|
4
|
+
import { n as linePaths, r as withAlpha } from "./uplot-paths-BRtF33Wh.js";
|
|
5
5
|
import { property } from "lit/decorators.js";
|
|
6
6
|
import { customElement } from "@c2n/core/element-helper.js";
|
|
7
7
|
import { css, unsafeCSS } from "lit";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as ChartBase } from "./chart-base-
|
|
2
|
-
import {
|
|
1
|
+
import { t as ChartBase } from "./chart-base-BwPwRgHt.js";
|
|
2
|
+
import { t as __decorate } from "./decorate-BkO8ArQg.js";
|
|
3
3
|
import { property } from "lit/decorators.js";
|
|
4
4
|
//#region src/engines/uplot-loader.ts
|
|
5
5
|
var pending;
|
|
@@ -44,11 +44,27 @@ async function createUplotAdapter() {
|
|
|
44
44
|
events?.hover(null);
|
|
45
45
|
return;
|
|
46
46
|
}
|
|
47
|
+
let nearestSeriesIndex = 0;
|
|
48
|
+
let nearestDistance = Number.POSITIVE_INFINITY;
|
|
49
|
+
const cursorY = self.cursor.top ?? 0;
|
|
50
|
+
for (let engineIndex = 1; engineIndex < self.series.length; engineIndex += 1) {
|
|
51
|
+
const series = self.series[engineIndex];
|
|
52
|
+
const value = data[engineIndex]?.[index];
|
|
53
|
+
if (!series?.show || value === null || value === void 0 || !Number.isFinite(value)) continue;
|
|
54
|
+
const pointY = self.valToPos(value, series.scale ?? "y", true);
|
|
55
|
+
const distance = Math.abs(pointY - cursorY);
|
|
56
|
+
if (distance < nearestDistance) {
|
|
57
|
+
nearestDistance = distance;
|
|
58
|
+
nearestSeriesIndex = engineIndex - 1;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const pointer = self.cursor.event;
|
|
62
|
+
const bounds = container?.getBoundingClientRect();
|
|
47
63
|
events?.hover({
|
|
48
64
|
index,
|
|
49
|
-
seriesIndex:
|
|
50
|
-
px: self.cursor.left ?? 0,
|
|
51
|
-
py: self.cursor.top ?? 0
|
|
65
|
+
seriesIndex: nearestSeriesIndex,
|
|
66
|
+
px: pointer && bounds ? pointer.clientX - bounds.left : self.cursor.left ?? 0,
|
|
67
|
+
py: pointer && bounds ? pointer.clientY - bounds.top : self.cursor.top ?? 0
|
|
52
68
|
});
|
|
53
69
|
}],
|
|
54
70
|
setSelect: [(self) => {
|
package/dist/uplot-chart-base.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as UplotChartBase } from "./uplot-chart-base-
|
|
1
|
+
import { t as UplotChartBase } from "./uplot-chart-base-CDHzOLwa.js";
|
|
2
2
|
export { UplotChartBase };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@c2n/chart",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/chart.js",
|
|
6
6
|
"exports": {
|
|
@@ -28,10 +28,30 @@
|
|
|
28
28
|
"types": "./types/src/pie-chart.d.ts",
|
|
29
29
|
"default": "./dist/pie-chart.js"
|
|
30
30
|
},
|
|
31
|
+
"./gauge-chart.js": {
|
|
32
|
+
"types": "./types/src/gauge-chart.d.ts",
|
|
33
|
+
"default": "./dist/gauge-chart.js"
|
|
34
|
+
},
|
|
35
|
+
"./scatter-chart.js": {
|
|
36
|
+
"types": "./types/src/scatter-chart.d.ts",
|
|
37
|
+
"default": "./dist/scatter-chart.js"
|
|
38
|
+
},
|
|
39
|
+
"./candlestick-chart.js": {
|
|
40
|
+
"types": "./types/src/candlestick-chart.d.ts",
|
|
41
|
+
"default": "./dist/candlestick-chart.js"
|
|
42
|
+
},
|
|
31
43
|
"./chart-series.js": {
|
|
32
44
|
"types": "./types/src/chart-series.d.ts",
|
|
33
45
|
"default": "./dist/chart-series.js"
|
|
34
46
|
},
|
|
47
|
+
"./chart-legend.js": {
|
|
48
|
+
"types": "./types/src/chart-legend.d.ts",
|
|
49
|
+
"default": "./dist/chart-legend.js"
|
|
50
|
+
},
|
|
51
|
+
"./chart-tooltip.js": {
|
|
52
|
+
"types": "./types/src/chart-tooltip.d.ts",
|
|
53
|
+
"default": "./dist/chart-tooltip.js"
|
|
54
|
+
},
|
|
35
55
|
"./chart-base.js": {
|
|
36
56
|
"types": "./types/src/chart-base.d.ts",
|
|
37
57
|
"default": "./dist/chart-base.js"
|
|
@@ -84,6 +104,9 @@
|
|
|
84
104
|
"graph",
|
|
85
105
|
"data visualization",
|
|
86
106
|
"line chart",
|
|
107
|
+
"gauge chart",
|
|
108
|
+
"scatter plot",
|
|
109
|
+
"candlestick chart",
|
|
87
110
|
"sparkline",
|
|
88
111
|
"uplot",
|
|
89
112
|
"echarts",
|
|
@@ -121,7 +144,7 @@
|
|
|
121
144
|
}
|
|
122
145
|
},
|
|
123
146
|
"dependencies": {
|
|
124
|
-
"@c2n/core": "0.0.
|
|
147
|
+
"@c2n/core": "0.0.8",
|
|
125
148
|
"lit": "3.3.3"
|
|
126
149
|
},
|
|
127
150
|
"devDependencies": {
|
|
@@ -142,5 +165,5 @@
|
|
|
142
165
|
"optional": true
|
|
143
166
|
}
|
|
144
167
|
},
|
|
145
|
-
"gitHead": "
|
|
168
|
+
"gitHead": "be59cbccee1d33ca248e39f69b05c0b595ec6c6d"
|
|
146
169
|
}
|
package/react.d.ts
CHANGED
|
@@ -10,9 +10,14 @@
|
|
|
10
10
|
import type { DetailedHTMLProps, HTMLAttributes } from 'react'
|
|
11
11
|
import type { AreaChart } from '@c2n/chart/area-chart.js'
|
|
12
12
|
import type { BarChart } from '@c2n/chart/bar-chart.js'
|
|
13
|
+
import type { CandlestickChart } from '@c2n/chart/candlestick-chart.js'
|
|
14
|
+
import type { ChartLegend } from '@c2n/chart/chart-legend.js'
|
|
13
15
|
import type { ChartSeries } from '@c2n/chart/chart-series.js'
|
|
16
|
+
import type { ChartTooltip } from '@c2n/chart/chart-tooltip.js'
|
|
17
|
+
import type { GaugeChart } from '@c2n/chart/gauge-chart.js'
|
|
14
18
|
import type { LineChart } from '@c2n/chart/line-chart.js'
|
|
15
19
|
import type { PieChart } from '@c2n/chart/pie-chart.js'
|
|
20
|
+
import type { ScatterChart } from '@c2n/chart/scatter-chart.js'
|
|
16
21
|
import type { Sparkline } from '@c2n/chart/sparkline.js'
|
|
17
22
|
|
|
18
23
|
/** Standard React host-element attributes plus the element's own public properties. */
|
|
@@ -23,9 +28,14 @@ declare module 'react' {
|
|
|
23
28
|
interface IntrinsicElements {
|
|
24
29
|
'c2-area-chart': C2Props<AreaChart>
|
|
25
30
|
'c2-bar-chart': C2Props<BarChart>
|
|
31
|
+
'c2-candlestick-chart': C2Props<CandlestickChart>
|
|
32
|
+
'c2-chart-legend': C2Props<ChartLegend>
|
|
26
33
|
'c2-chart-series': C2Props<ChartSeries>
|
|
34
|
+
'c2-chart-tooltip': C2Props<ChartTooltip>
|
|
35
|
+
'c2-gauge-chart': C2Props<GaugeChart>
|
|
27
36
|
'c2-line-chart': C2Props<LineChart>
|
|
28
37
|
'c2-pie-chart': C2Props<PieChart>
|
|
38
|
+
'c2-scatter-chart': C2Props<ScatterChart>
|
|
29
39
|
'c2-sparkline': C2Props<Sparkline>
|
|
30
40
|
}
|
|
31
41
|
}
|