@mantine-vue/charts 1.1.1
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/cjs/index.cjs +822 -0
- package/cjs/index.cjs.map +1 -0
- package/esm/index.mjs +780 -0
- package/esm/index.mjs.map +1 -0
- package/lib/AreaChart/AreaChart.d.ts +2 -0
- package/lib/AreaChart/index.d.ts +1 -0
- package/lib/BarChart/BarChart.d.ts +2 -0
- package/lib/BarChart/index.d.ts +1 -0
- package/lib/BarsList/BarsList.d.ts +2 -0
- package/lib/BarsList/index.d.ts +1 -0
- package/lib/BubbleChart/BubbleChart.d.ts +2 -0
- package/lib/BubbleChart/index.d.ts +1 -0
- package/lib/ChartLegend/ChartLegend.d.ts +54 -0
- package/lib/ChartLegend/index.d.ts +2 -0
- package/lib/ChartTooltip/ChartTooltip.d.ts +48 -0
- package/lib/ChartTooltip/index.d.ts +2 -0
- package/lib/CompositeChart/CompositeChart.d.ts +2 -0
- package/lib/CompositeChart/index.d.ts +1 -0
- package/lib/DonutChart/DonutChart.d.ts +2 -0
- package/lib/DonutChart/index.d.ts +1 -0
- package/lib/FunnelChart/FunnelChart.d.ts +2 -0
- package/lib/FunnelChart/index.d.ts +1 -0
- package/lib/Heatmap/Heatmap.d.ts +2 -0
- package/lib/Heatmap/index.d.ts +1 -0
- package/lib/LineChart/LineChart.d.ts +2 -0
- package/lib/LineChart/index.d.ts +1 -0
- package/lib/PieChart/PieChart.d.ts +2 -0
- package/lib/PieChart/index.d.ts +1 -0
- package/lib/RadarChart/RadarChart.d.ts +2 -0
- package/lib/RadarChart/index.d.ts +1 -0
- package/lib/RadialBarChart/RadialBarChart.d.ts +2 -0
- package/lib/RadialBarChart/index.d.ts +1 -0
- package/lib/SankeyChart/SankeyChart.d.ts +2 -0
- package/lib/SankeyChart/index.d.ts +1 -0
- package/lib/ScatterChart/ScatterChart.d.ts +2 -0
- package/lib/ScatterChart/index.d.ts +1 -0
- package/lib/Sparkline/Sparkline.d.ts +2 -0
- package/lib/Sparkline/index.d.ts +1 -0
- package/lib/Treemap/Treemap.d.ts +2 -0
- package/lib/Treemap/index.d.ts +1 -0
- package/lib/charts.d.ts +319 -0
- package/lib/index.d.mts +6 -0
- package/lib/index.d.ts +6 -0
- package/lib/internal/colors.d.ts +1 -0
- package/lib/internal/component.d.ts +4 -0
- package/lib/internal/echarts.d.ts +1 -0
- package/lib/internal/options.d.ts +11 -0
- package/lib/types.d.ts +79 -0
- package/lib/utils/get-series-labels/get-series-labels.d.ts +2 -0
- package/lib/utils/index.d.ts +1 -0
- package/package.json +46 -0
- package/styles.css +12 -0
- package/styles.layer.css +14 -0
package/cjs/index.cjs
ADDED
|
@@ -0,0 +1,822 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
|
+
get: ((k) => from[k]).bind(null, key),
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
20
|
+
value: mod,
|
|
21
|
+
enumerable: true
|
|
22
|
+
}) : target, mod));
|
|
23
|
+
//#endregion
|
|
24
|
+
let vue = require("vue");
|
|
25
|
+
let vue_echarts = require("vue-echarts");
|
|
26
|
+
vue_echarts = __toESM(vue_echarts);
|
|
27
|
+
let echarts_core = require("echarts/core");
|
|
28
|
+
let echarts_charts = require("echarts/charts");
|
|
29
|
+
let echarts_components = require("echarts/components");
|
|
30
|
+
let echarts_renderers = require("echarts/renderers");
|
|
31
|
+
//#region src/internal/echarts.ts
|
|
32
|
+
var registered = false;
|
|
33
|
+
function registerECharts() {
|
|
34
|
+
if (registered) return;
|
|
35
|
+
(0, echarts_core.use)([
|
|
36
|
+
echarts_charts.BarChart,
|
|
37
|
+
echarts_charts.EffectScatterChart,
|
|
38
|
+
echarts_charts.FunnelChart,
|
|
39
|
+
echarts_charts.GaugeChart,
|
|
40
|
+
echarts_charts.GraphChart,
|
|
41
|
+
echarts_charts.HeatmapChart,
|
|
42
|
+
echarts_charts.LineChart,
|
|
43
|
+
echarts_charts.PieChart,
|
|
44
|
+
echarts_charts.RadarChart,
|
|
45
|
+
echarts_charts.SankeyChart,
|
|
46
|
+
echarts_charts.ScatterChart,
|
|
47
|
+
echarts_charts.TreemapChart,
|
|
48
|
+
echarts_components.AriaComponent,
|
|
49
|
+
echarts_components.CalendarComponent,
|
|
50
|
+
echarts_components.DatasetComponent,
|
|
51
|
+
echarts_components.DataZoomComponent,
|
|
52
|
+
echarts_components.GraphicComponent,
|
|
53
|
+
echarts_components.GridComponent,
|
|
54
|
+
echarts_components.LegendComponent,
|
|
55
|
+
echarts_components.MarkLineComponent,
|
|
56
|
+
echarts_components.PolarComponent,
|
|
57
|
+
echarts_components.RadarComponent,
|
|
58
|
+
echarts_components.TitleComponent,
|
|
59
|
+
echarts_components.ToolboxComponent,
|
|
60
|
+
echarts_components.TooltipComponent,
|
|
61
|
+
echarts_components.TransformComponent,
|
|
62
|
+
echarts_components.VisualMapComponent,
|
|
63
|
+
echarts_renderers.CanvasRenderer,
|
|
64
|
+
echarts_renderers.SVGRenderer
|
|
65
|
+
]);
|
|
66
|
+
registered = true;
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region src/internal/component.ts
|
|
70
|
+
registerECharts();
|
|
71
|
+
function createChartComponent(name, buildOption) {
|
|
72
|
+
return (0, vue.defineComponent)({
|
|
73
|
+
name: `Mantine${name}`,
|
|
74
|
+
inheritAttrs: false,
|
|
75
|
+
props: {
|
|
76
|
+
option: Object,
|
|
77
|
+
height: {
|
|
78
|
+
type: [Number, String],
|
|
79
|
+
default: 300
|
|
80
|
+
},
|
|
81
|
+
width: {
|
|
82
|
+
type: [Number, String],
|
|
83
|
+
default: "100%"
|
|
84
|
+
},
|
|
85
|
+
loading: Boolean,
|
|
86
|
+
autoresize: {
|
|
87
|
+
type: Boolean,
|
|
88
|
+
default: true
|
|
89
|
+
},
|
|
90
|
+
renderer: {
|
|
91
|
+
type: String,
|
|
92
|
+
default: "canvas"
|
|
93
|
+
},
|
|
94
|
+
initOptions: Object
|
|
95
|
+
},
|
|
96
|
+
emits: [
|
|
97
|
+
"click",
|
|
98
|
+
"dblclick",
|
|
99
|
+
"mouseover",
|
|
100
|
+
"mouseout",
|
|
101
|
+
"legendselectchanged",
|
|
102
|
+
"datazoom"
|
|
103
|
+
],
|
|
104
|
+
setup(props, { attrs, emit, expose }) {
|
|
105
|
+
const chart = (0, vue.ref)();
|
|
106
|
+
const option = (0, vue.computed)(() => ({
|
|
107
|
+
...buildOption(attrs),
|
|
108
|
+
...props.option
|
|
109
|
+
}));
|
|
110
|
+
expose({
|
|
111
|
+
getEchartsInstance: () => chart.value?.chart,
|
|
112
|
+
resize: () => chart.value?.resize(),
|
|
113
|
+
setOption: (next) => chart.value?.setOption(next)
|
|
114
|
+
});
|
|
115
|
+
const size = (value) => typeof value === "number" ? `${value}px` : value;
|
|
116
|
+
const rootAttributes = (0, vue.computed)(() => Object.fromEntries(Object.entries(attrs).filter(([key]) => [
|
|
117
|
+
"id",
|
|
118
|
+
"dir",
|
|
119
|
+
"role",
|
|
120
|
+
"tabindex",
|
|
121
|
+
"title"
|
|
122
|
+
].includes(key) || key.startsWith("aria-") || key.startsWith("data-") && key !== "data")));
|
|
123
|
+
return () => (0, vue.h)("div", {
|
|
124
|
+
...rootAttributes.value,
|
|
125
|
+
class: [
|
|
126
|
+
"mantine-Chart-root",
|
|
127
|
+
`mantine-${name}-root`,
|
|
128
|
+
attrs.class
|
|
129
|
+
],
|
|
130
|
+
style: [{
|
|
131
|
+
width: size(props.width),
|
|
132
|
+
height: size(props.height)
|
|
133
|
+
}, attrs.style]
|
|
134
|
+
}, [(0, vue.h)(vue_echarts.default, {
|
|
135
|
+
ref: chart,
|
|
136
|
+
option: option.value,
|
|
137
|
+
autoresize: props.autoresize,
|
|
138
|
+
loading: props.loading,
|
|
139
|
+
initOptions: {
|
|
140
|
+
...props.initOptions,
|
|
141
|
+
renderer: props.renderer
|
|
142
|
+
},
|
|
143
|
+
class: "mantine-Chart-container",
|
|
144
|
+
onClick: (event) => emit("click", event),
|
|
145
|
+
onDblclick: (event) => emit("dblclick", event),
|
|
146
|
+
onMouseover: (event) => emit("mouseover", event),
|
|
147
|
+
onMouseout: (event) => emit("mouseout", event),
|
|
148
|
+
onLegendselectchanged: (event) => emit("legendselectchanged", event),
|
|
149
|
+
onDatazoom: (event) => emit("datazoom", event)
|
|
150
|
+
})]);
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
//#endregion
|
|
155
|
+
//#region src/internal/colors.ts
|
|
156
|
+
var shadeMap = {
|
|
157
|
+
blue: [
|
|
158
|
+
"#e7f5ff",
|
|
159
|
+
"#d0ebff",
|
|
160
|
+
"#a5d8ff",
|
|
161
|
+
"#74c0fc",
|
|
162
|
+
"#4dabf7",
|
|
163
|
+
"#339af0",
|
|
164
|
+
"#228be6",
|
|
165
|
+
"#1c7ed6",
|
|
166
|
+
"#1971c2",
|
|
167
|
+
"#1864ab"
|
|
168
|
+
],
|
|
169
|
+
cyan: [
|
|
170
|
+
"#e3fafc",
|
|
171
|
+
"#c5f6fa",
|
|
172
|
+
"#99e9f2",
|
|
173
|
+
"#66d9e8",
|
|
174
|
+
"#3bc9db",
|
|
175
|
+
"#22b8cf",
|
|
176
|
+
"#15aabf",
|
|
177
|
+
"#1098ad",
|
|
178
|
+
"#0c8599",
|
|
179
|
+
"#0b7285"
|
|
180
|
+
],
|
|
181
|
+
green: [
|
|
182
|
+
"#ebfbee",
|
|
183
|
+
"#d3f9d8",
|
|
184
|
+
"#b2f2bb",
|
|
185
|
+
"#8ce99a",
|
|
186
|
+
"#69db7c",
|
|
187
|
+
"#51cf66",
|
|
188
|
+
"#40c057",
|
|
189
|
+
"#37b24d",
|
|
190
|
+
"#2f9e44",
|
|
191
|
+
"#2b8a3e"
|
|
192
|
+
],
|
|
193
|
+
grape: [
|
|
194
|
+
"#f8f0fc",
|
|
195
|
+
"#f3d9fa",
|
|
196
|
+
"#eebefa",
|
|
197
|
+
"#e599f7",
|
|
198
|
+
"#da77f2",
|
|
199
|
+
"#cc5de8",
|
|
200
|
+
"#be4bdb",
|
|
201
|
+
"#ae3ec9",
|
|
202
|
+
"#9c36b5",
|
|
203
|
+
"#862e9c"
|
|
204
|
+
],
|
|
205
|
+
gray: [
|
|
206
|
+
"#f8f9fa",
|
|
207
|
+
"#f1f3f5",
|
|
208
|
+
"#e9ecef",
|
|
209
|
+
"#dee2e6",
|
|
210
|
+
"#ced4da",
|
|
211
|
+
"#adb5bd",
|
|
212
|
+
"#868e96",
|
|
213
|
+
"#495057",
|
|
214
|
+
"#343a40",
|
|
215
|
+
"#212529"
|
|
216
|
+
],
|
|
217
|
+
orange: [
|
|
218
|
+
"#fff4e6",
|
|
219
|
+
"#ffe8cc",
|
|
220
|
+
"#ffd8a8",
|
|
221
|
+
"#ffc078",
|
|
222
|
+
"#ffa94d",
|
|
223
|
+
"#ff922b",
|
|
224
|
+
"#fd7e14",
|
|
225
|
+
"#f76707",
|
|
226
|
+
"#e8590c",
|
|
227
|
+
"#d9480f"
|
|
228
|
+
],
|
|
229
|
+
pink: [
|
|
230
|
+
"#fff0f6",
|
|
231
|
+
"#ffdeeb",
|
|
232
|
+
"#fcc2d7",
|
|
233
|
+
"#faa2c1",
|
|
234
|
+
"#f783ac",
|
|
235
|
+
"#f06595",
|
|
236
|
+
"#e64980",
|
|
237
|
+
"#d6336c",
|
|
238
|
+
"#c2255c",
|
|
239
|
+
"#a61e4d"
|
|
240
|
+
],
|
|
241
|
+
red: [
|
|
242
|
+
"#fff5f5",
|
|
243
|
+
"#ffe3e3",
|
|
244
|
+
"#ffc9c9",
|
|
245
|
+
"#ffa8a8",
|
|
246
|
+
"#ff8787",
|
|
247
|
+
"#ff6b6b",
|
|
248
|
+
"#fa5252",
|
|
249
|
+
"#f03e3e",
|
|
250
|
+
"#e03131",
|
|
251
|
+
"#c92a2a"
|
|
252
|
+
],
|
|
253
|
+
teal: [
|
|
254
|
+
"#e6fcf5",
|
|
255
|
+
"#c3fae8",
|
|
256
|
+
"#96f2d7",
|
|
257
|
+
"#63e6be",
|
|
258
|
+
"#38d9a9",
|
|
259
|
+
"#20c997",
|
|
260
|
+
"#12b886",
|
|
261
|
+
"#0ca678",
|
|
262
|
+
"#099268",
|
|
263
|
+
"#087f5b"
|
|
264
|
+
],
|
|
265
|
+
violet: [
|
|
266
|
+
"#f3f0ff",
|
|
267
|
+
"#e5dbff",
|
|
268
|
+
"#d0bfff",
|
|
269
|
+
"#b197fc",
|
|
270
|
+
"#9775fa",
|
|
271
|
+
"#845ef7",
|
|
272
|
+
"#7950f2",
|
|
273
|
+
"#7048e8",
|
|
274
|
+
"#6741d9",
|
|
275
|
+
"#5f3dc4"
|
|
276
|
+
],
|
|
277
|
+
yellow: [
|
|
278
|
+
"#fff9db",
|
|
279
|
+
"#fff3bf",
|
|
280
|
+
"#ffec99",
|
|
281
|
+
"#ffe066",
|
|
282
|
+
"#ffd43b",
|
|
283
|
+
"#fcc419",
|
|
284
|
+
"#fab005",
|
|
285
|
+
"#f59f00",
|
|
286
|
+
"#f08c00",
|
|
287
|
+
"#e67700"
|
|
288
|
+
]
|
|
289
|
+
};
|
|
290
|
+
function resolveColor(color, fallback = "#228be6") {
|
|
291
|
+
if (typeof color !== "string" || !color) return fallback;
|
|
292
|
+
const [name, rawShade] = color.split(".");
|
|
293
|
+
const shade = Number(rawShade ?? 6);
|
|
294
|
+
return shadeMap[name]?.[Number.isInteger(shade) ? shade : 6] ?? color;
|
|
295
|
+
}
|
|
296
|
+
//#endregion
|
|
297
|
+
//#region src/internal/options.ts
|
|
298
|
+
var bool = (value, fallback) => typeof value === "boolean" ? value : fallback;
|
|
299
|
+
var num = (value, fallback) => typeof value === "number" ? value : fallback;
|
|
300
|
+
var obj = (value) => value && typeof value === "object" ? value : {};
|
|
301
|
+
var list = (value) => Array.isArray(value) ? value : [];
|
|
302
|
+
var formatter = (props) => typeof props.valueFormatter === "function" ? props.valueFormatter : void 0;
|
|
303
|
+
function tooltip(props) {
|
|
304
|
+
if (!bool(props.withTooltip, true)) return { show: false };
|
|
305
|
+
const format = formatter(props);
|
|
306
|
+
return {
|
|
307
|
+
trigger: "axis",
|
|
308
|
+
transitionDuration: num(props.tooltipAnimationDuration, 0) / 1e3,
|
|
309
|
+
valueFormatter: format ? (value) => format(Number(value)) : void 0,
|
|
310
|
+
...obj(props.tooltipProps)
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
function markLine(referenceLines) {
|
|
314
|
+
if (!referenceLines?.length) return void 0;
|
|
315
|
+
return {
|
|
316
|
+
silent: true,
|
|
317
|
+
symbol: "none",
|
|
318
|
+
data: referenceLines.map((line) => ({
|
|
319
|
+
xAxis: line.x,
|
|
320
|
+
yAxis: line.y,
|
|
321
|
+
label: typeof line.label === "string" ? { formatter: line.label } : line.label,
|
|
322
|
+
lineStyle: {
|
|
323
|
+
color: resolveColor(line.color, "#868e96"),
|
|
324
|
+
type: line.strokeDasharray ? "dashed" : "solid"
|
|
325
|
+
}
|
|
326
|
+
}))
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
function cartesianOption(props, kind) {
|
|
330
|
+
const data = list(props.data);
|
|
331
|
+
const series = list(props.series);
|
|
332
|
+
const dataKey = String(props.dataKey ?? "name");
|
|
333
|
+
const horizontal = props.orientation !== "vertical";
|
|
334
|
+
const chartType = String(props.type ?? "default");
|
|
335
|
+
const category = data.map((item) => item[dataKey]);
|
|
336
|
+
const commonAxis = { axisLabel: { color: resolveColor(props.textColor, "#868e96") } };
|
|
337
|
+
const categoryAxis = {
|
|
338
|
+
type: "category",
|
|
339
|
+
data: category,
|
|
340
|
+
...commonAxis
|
|
341
|
+
};
|
|
342
|
+
const valueAxis = {
|
|
343
|
+
type: "value",
|
|
344
|
+
name: props.yAxisLabel,
|
|
345
|
+
...commonAxis
|
|
346
|
+
};
|
|
347
|
+
const mapped = series.map((item, index) => {
|
|
348
|
+
const itemKind = kind === "composite" ? item.type ?? "line" : kind === "area" ? "line" : kind;
|
|
349
|
+
const color = resolveColor(item.color, resolveColor(`blue.${6 + index % 3}`));
|
|
350
|
+
const stack = chartType === "stacked" || chartType === "percent" ? "stack" : item.stackId;
|
|
351
|
+
const base = {
|
|
352
|
+
name: item.label ?? item.name,
|
|
353
|
+
data: data.map((entry) => entry[item.name]),
|
|
354
|
+
yAxisIndex: item.yAxisId ? 1 : 0,
|
|
355
|
+
stack,
|
|
356
|
+
markLine: index === 0 ? markLine(props.referenceLines) : void 0
|
|
357
|
+
};
|
|
358
|
+
if (itemKind === "bar") return {
|
|
359
|
+
...base,
|
|
360
|
+
type: "bar",
|
|
361
|
+
barMaxWidth: props.maxBarWidth,
|
|
362
|
+
barMinHeight: num(props.minBarSize, 0),
|
|
363
|
+
itemStyle: {
|
|
364
|
+
color,
|
|
365
|
+
opacity: num(props.fillOpacity, 1)
|
|
366
|
+
},
|
|
367
|
+
label: {
|
|
368
|
+
show: bool(props.withBarValueLabel, false),
|
|
369
|
+
position: horizontal ? "top" : "right"
|
|
370
|
+
}
|
|
371
|
+
};
|
|
372
|
+
return {
|
|
373
|
+
...base,
|
|
374
|
+
type: "line",
|
|
375
|
+
smooth: ![
|
|
376
|
+
"linear",
|
|
377
|
+
"step",
|
|
378
|
+
"stepBefore",
|
|
379
|
+
"stepAfter"
|
|
380
|
+
].includes(String(props.curveType ?? item.curveType ?? "monotone")),
|
|
381
|
+
step: String(props.curveType).startsWith("step") ? "middle" : false,
|
|
382
|
+
connectNulls: bool(props.connectNulls, true),
|
|
383
|
+
showSymbol: bool(props.withDots, true),
|
|
384
|
+
symbolSize: 6,
|
|
385
|
+
lineStyle: {
|
|
386
|
+
color,
|
|
387
|
+
width: num(props.strokeWidth, 2),
|
|
388
|
+
type: item.strokeDasharray ? "dashed" : "solid"
|
|
389
|
+
},
|
|
390
|
+
itemStyle: {
|
|
391
|
+
color,
|
|
392
|
+
opacity: num(props.fillOpacity, 1)
|
|
393
|
+
},
|
|
394
|
+
areaStyle: itemKind === "area" ? {
|
|
395
|
+
color,
|
|
396
|
+
opacity: num(props.fillOpacity, .2)
|
|
397
|
+
} : void 0,
|
|
398
|
+
label: {
|
|
399
|
+
show: bool(props.withPointLabels, false),
|
|
400
|
+
position: "top"
|
|
401
|
+
}
|
|
402
|
+
};
|
|
403
|
+
});
|
|
404
|
+
return {
|
|
405
|
+
animationDurationUpdate: num(props.tooltipAnimationDuration, 0),
|
|
406
|
+
color: series.map((item) => resolveColor(item.color)),
|
|
407
|
+
grid: {
|
|
408
|
+
left: 48,
|
|
409
|
+
right: bool(props.withRightYAxis, false) ? 48 : 16,
|
|
410
|
+
top: bool(props.withLegend, false) ? 44 : 16,
|
|
411
|
+
bottom: 38,
|
|
412
|
+
containLabel: true,
|
|
413
|
+
...obj(props.gridProps)
|
|
414
|
+
},
|
|
415
|
+
legend: {
|
|
416
|
+
show: bool(props.withLegend, false),
|
|
417
|
+
...obj(props.legendProps)
|
|
418
|
+
},
|
|
419
|
+
tooltip: tooltip(props),
|
|
420
|
+
xAxis: horizontal ? {
|
|
421
|
+
...categoryAxis,
|
|
422
|
+
show: bool(props.withXAxis, true),
|
|
423
|
+
name: props.xAxisLabel,
|
|
424
|
+
...obj(props.xAxisProps)
|
|
425
|
+
} : {
|
|
426
|
+
...valueAxis,
|
|
427
|
+
show: bool(props.withXAxis, true),
|
|
428
|
+
...obj(props.xAxisProps)
|
|
429
|
+
},
|
|
430
|
+
yAxis: horizontal ? [{
|
|
431
|
+
...valueAxis,
|
|
432
|
+
show: bool(props.withYAxis, true),
|
|
433
|
+
...obj(props.yAxisProps)
|
|
434
|
+
}, {
|
|
435
|
+
...valueAxis,
|
|
436
|
+
show: bool(props.withRightYAxis, false),
|
|
437
|
+
position: "right",
|
|
438
|
+
name: props.rightYAxisLabel,
|
|
439
|
+
...obj(props.rightYAxisProps)
|
|
440
|
+
}] : {
|
|
441
|
+
...categoryAxis,
|
|
442
|
+
show: bool(props.withYAxis, true),
|
|
443
|
+
...obj(props.yAxisProps)
|
|
444
|
+
},
|
|
445
|
+
series: mapped
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
function radialOption(props, donut = false) {
|
|
449
|
+
const data = list(props.data);
|
|
450
|
+
return {
|
|
451
|
+
color: data.map((item) => resolveColor(item.color)),
|
|
452
|
+
legend: {
|
|
453
|
+
show: bool(props.withLabels, false) || bool(props.withLegend, false),
|
|
454
|
+
...obj(props.legendProps)
|
|
455
|
+
},
|
|
456
|
+
tooltip: {
|
|
457
|
+
trigger: "item",
|
|
458
|
+
show: bool(props.withTooltip, true),
|
|
459
|
+
...obj(props.tooltipProps)
|
|
460
|
+
},
|
|
461
|
+
series: [{
|
|
462
|
+
type: "pie",
|
|
463
|
+
radius: donut ? [`${num(props.thickness, 40)}%`, "75%"] : ["0%", "75%"],
|
|
464
|
+
startAngle: num(props.startAngle, 90),
|
|
465
|
+
minAngle: num(props.minAngle, 0),
|
|
466
|
+
padAngle: num(props.paddingAngle, 0),
|
|
467
|
+
roseType: props.type === "pie" ? void 0 : props.type === "donut" ? void 0 : props.type,
|
|
468
|
+
label: {
|
|
469
|
+
show: bool(props.withLabels, false),
|
|
470
|
+
formatter: props.withLabelsLine ? "{b}: {d}%" : "{b}"
|
|
471
|
+
},
|
|
472
|
+
labelLine: { show: bool(props.withLabelsLine, false) },
|
|
473
|
+
data: data.map((item) => ({
|
|
474
|
+
...item,
|
|
475
|
+
itemStyle: { color: resolveColor(item.color) }
|
|
476
|
+
}))
|
|
477
|
+
}],
|
|
478
|
+
graphic: props.chartLabel ? [{
|
|
479
|
+
type: "text",
|
|
480
|
+
left: "center",
|
|
481
|
+
top: "middle",
|
|
482
|
+
style: {
|
|
483
|
+
text: String(props.chartLabel),
|
|
484
|
+
fill: resolveColor(props.chartLabelColor, "#212529"),
|
|
485
|
+
fontSize: num(props.chartLabelFontSize, 18)
|
|
486
|
+
}
|
|
487
|
+
}] : void 0
|
|
488
|
+
};
|
|
489
|
+
}
|
|
490
|
+
function scatterOption(props, bubble = false) {
|
|
491
|
+
const data = list(props.data);
|
|
492
|
+
const series = list(props.series);
|
|
493
|
+
const xKey = String(props.dataKey ?? props.xAxisKey ?? "x");
|
|
494
|
+
const yKey = String(props.yAxisKey ?? "y");
|
|
495
|
+
const zKey = String(props.zAxisKey ?? "z");
|
|
496
|
+
return {
|
|
497
|
+
grid: {
|
|
498
|
+
containLabel: true,
|
|
499
|
+
...obj(props.gridProps)
|
|
500
|
+
},
|
|
501
|
+
legend: {
|
|
502
|
+
show: bool(props.withLegend, false),
|
|
503
|
+
...obj(props.legendProps)
|
|
504
|
+
},
|
|
505
|
+
tooltip: {
|
|
506
|
+
trigger: "item",
|
|
507
|
+
show: bool(props.withTooltip, true),
|
|
508
|
+
...obj(props.tooltipProps)
|
|
509
|
+
},
|
|
510
|
+
xAxis: {
|
|
511
|
+
type: "value",
|
|
512
|
+
show: bool(props.withXAxis, true),
|
|
513
|
+
...obj(props.xAxisProps)
|
|
514
|
+
},
|
|
515
|
+
yAxis: {
|
|
516
|
+
type: "value",
|
|
517
|
+
show: bool(props.withYAxis, true),
|
|
518
|
+
...obj(props.yAxisProps)
|
|
519
|
+
},
|
|
520
|
+
series: (series.length ? series : [{
|
|
521
|
+
name: String(props.name ?? "value"),
|
|
522
|
+
color: props.color
|
|
523
|
+
}]).map((item) => ({
|
|
524
|
+
type: "scatter",
|
|
525
|
+
name: item.label ?? item.name,
|
|
526
|
+
data: data.filter((entry) => !entry.name || entry.name === item.name).map((entry) => [
|
|
527
|
+
entry[xKey],
|
|
528
|
+
entry[yKey],
|
|
529
|
+
entry[zKey],
|
|
530
|
+
entry
|
|
531
|
+
]),
|
|
532
|
+
symbolSize: bubble ? (value) => Math.max(4, Math.sqrt(Number(value[2] ?? 1)) * num(props.range, 4)) : num(props.size, 10),
|
|
533
|
+
itemStyle: { color: resolveColor(item.color) }
|
|
534
|
+
}))
|
|
535
|
+
};
|
|
536
|
+
}
|
|
537
|
+
function sparklineOption(props) {
|
|
538
|
+
const data = list(props.data);
|
|
539
|
+
const trend = props.trendColors;
|
|
540
|
+
const color = trend ? resolveColor(data.at(-1) > data[0] ? trend.positive : data.at(-1) < data[0] ? trend.negative : trend.neutral) : resolveColor(props.color);
|
|
541
|
+
return {
|
|
542
|
+
grid: {
|
|
543
|
+
left: 0,
|
|
544
|
+
right: 0,
|
|
545
|
+
top: 1,
|
|
546
|
+
bottom: 1
|
|
547
|
+
},
|
|
548
|
+
xAxis: {
|
|
549
|
+
type: "category",
|
|
550
|
+
show: false
|
|
551
|
+
},
|
|
552
|
+
yAxis: {
|
|
553
|
+
type: "value",
|
|
554
|
+
show: false,
|
|
555
|
+
scale: true
|
|
556
|
+
},
|
|
557
|
+
series: [{
|
|
558
|
+
type: "line",
|
|
559
|
+
data,
|
|
560
|
+
showSymbol: false,
|
|
561
|
+
connectNulls: bool(props.connectNulls, true),
|
|
562
|
+
smooth: props.curveType !== "linear",
|
|
563
|
+
lineStyle: {
|
|
564
|
+
color,
|
|
565
|
+
width: num(props.strokeWidth, 2)
|
|
566
|
+
},
|
|
567
|
+
areaStyle: bool(props.withGradient, true) ? {
|
|
568
|
+
color,
|
|
569
|
+
opacity: num(props.fillOpacity, .6)
|
|
570
|
+
} : void 0
|
|
571
|
+
}]
|
|
572
|
+
};
|
|
573
|
+
}
|
|
574
|
+
function radarOption(props) {
|
|
575
|
+
const data = list(props.data);
|
|
576
|
+
const series = list(props.series);
|
|
577
|
+
const key = String(props.dataKey ?? "name");
|
|
578
|
+
const max = num(props.maxValue, Math.max(1, ...data.flatMap((row) => series.map((s) => Number(row[s.name] ?? 0)))));
|
|
579
|
+
return {
|
|
580
|
+
legend: { show: bool(props.withLegend, false) },
|
|
581
|
+
tooltip: { show: bool(props.withTooltip, true) },
|
|
582
|
+
radar: {
|
|
583
|
+
indicator: data.map((row) => ({
|
|
584
|
+
name: String(row[key]),
|
|
585
|
+
max
|
|
586
|
+
})),
|
|
587
|
+
shape: props.shape === "circle" ? "circle" : "polygon"
|
|
588
|
+
},
|
|
589
|
+
series: [{
|
|
590
|
+
type: "radar",
|
|
591
|
+
data: series.map((s) => ({
|
|
592
|
+
name: s.label ?? s.name,
|
|
593
|
+
value: data.map((row) => Number(row[s.name] ?? 0)),
|
|
594
|
+
lineStyle: { color: resolveColor(s.color) },
|
|
595
|
+
itemStyle: { color: resolveColor(s.color) },
|
|
596
|
+
areaStyle: bool(props.withPolarGrid, false) ? {} : void 0
|
|
597
|
+
}))
|
|
598
|
+
}]
|
|
599
|
+
};
|
|
600
|
+
}
|
|
601
|
+
function simpleOption(type, props) {
|
|
602
|
+
const data = list(props.data);
|
|
603
|
+
if (type === "sankey") return {
|
|
604
|
+
tooltip: { show: bool(props.withTooltip, true) },
|
|
605
|
+
series: [{
|
|
606
|
+
type,
|
|
607
|
+
data: list(props.nodes ?? data),
|
|
608
|
+
links: list(props.links),
|
|
609
|
+
emphasis: { focus: "adjacency" },
|
|
610
|
+
...obj(props.sankeyProps)
|
|
611
|
+
}]
|
|
612
|
+
};
|
|
613
|
+
return {
|
|
614
|
+
tooltip: { show: bool(props.withTooltip, true) },
|
|
615
|
+
legend: { show: bool(props.withLegend, false) },
|
|
616
|
+
series: [{
|
|
617
|
+
type,
|
|
618
|
+
data: data.map((item) => ({
|
|
619
|
+
...item,
|
|
620
|
+
itemStyle: { color: resolveColor(item.color) }
|
|
621
|
+
})),
|
|
622
|
+
...obj(props[`${type}Props`])
|
|
623
|
+
}]
|
|
624
|
+
};
|
|
625
|
+
}
|
|
626
|
+
function radialBarOption(props) {
|
|
627
|
+
const data = list(props.data);
|
|
628
|
+
return {
|
|
629
|
+
legend: { show: bool(props.withLegend, false) },
|
|
630
|
+
tooltip: { show: bool(props.withTooltip, true) },
|
|
631
|
+
polar: {},
|
|
632
|
+
angleAxis: {
|
|
633
|
+
max: num(props.maxValue, 100),
|
|
634
|
+
show: false
|
|
635
|
+
},
|
|
636
|
+
radiusAxis: {
|
|
637
|
+
type: "category",
|
|
638
|
+
data: data.map((i) => i.name),
|
|
639
|
+
show: bool(props.withLabels, true)
|
|
640
|
+
},
|
|
641
|
+
series: [{
|
|
642
|
+
type: "bar",
|
|
643
|
+
coordinateSystem: "polar",
|
|
644
|
+
roundCap: true,
|
|
645
|
+
data: data.map((i) => ({
|
|
646
|
+
value: i.value,
|
|
647
|
+
itemStyle: { color: resolveColor(i.color) }
|
|
648
|
+
}))
|
|
649
|
+
}]
|
|
650
|
+
};
|
|
651
|
+
}
|
|
652
|
+
function heatmapOption(props) {
|
|
653
|
+
const input = props.data && typeof props.data === "object" ? props.data : {};
|
|
654
|
+
const data = Object.entries(input).map(([date, value]) => [date, value]);
|
|
655
|
+
const values = Object.values(input);
|
|
656
|
+
const date = (value, fallback) => value instanceof Date ? value.toISOString().slice(0, 10) : typeof value === "string" ? value : fallback;
|
|
657
|
+
const start = date(props.startDate, String(data[0]?.[0] ?? (/* @__PURE__ */ new Date()).toISOString().slice(0, 10)));
|
|
658
|
+
const end = date(props.endDate, String(data.at(-1)?.[0] ?? start));
|
|
659
|
+
return {
|
|
660
|
+
tooltip: { show: bool(props.withTooltip, false) },
|
|
661
|
+
visualMap: {
|
|
662
|
+
show: bool(props.withLegend, false),
|
|
663
|
+
min: props.domain?.[0] ?? Math.min(0, ...values),
|
|
664
|
+
max: props.domain?.[1] ?? Math.max(1, ...values),
|
|
665
|
+
inRange: { color: list(props.colors).length ? list(props.colors).map((color) => resolveColor(color)) : ["#ebfbee", "#2f9e44"] },
|
|
666
|
+
orient: "horizontal",
|
|
667
|
+
left: "center",
|
|
668
|
+
bottom: 0
|
|
669
|
+
},
|
|
670
|
+
calendar: {
|
|
671
|
+
range: [start, end],
|
|
672
|
+
cellSize: num(props.rectSize, 10) + num(props.gap, 1),
|
|
673
|
+
dayLabel: {
|
|
674
|
+
show: bool(props.withWeekdayLabels, false),
|
|
675
|
+
firstDay: num(props.firstDayOfWeek, 1)
|
|
676
|
+
},
|
|
677
|
+
monthLabel: { show: bool(props.withMonthLabels, false) },
|
|
678
|
+
itemStyle: {
|
|
679
|
+
borderWidth: num(props.gap, 1),
|
|
680
|
+
borderColor: "transparent",
|
|
681
|
+
borderRadius: num(props.rectRadius, 2)
|
|
682
|
+
}
|
|
683
|
+
},
|
|
684
|
+
series: [{
|
|
685
|
+
type: "heatmap",
|
|
686
|
+
coordinateSystem: "calendar",
|
|
687
|
+
data
|
|
688
|
+
}]
|
|
689
|
+
};
|
|
690
|
+
}
|
|
691
|
+
//#endregion
|
|
692
|
+
//#region src/charts.ts
|
|
693
|
+
var AreaChart = createChartComponent("AreaChart", (p) => cartesianOption(p, "area"));
|
|
694
|
+
var BarChart = createChartComponent("BarChart", (p) => cartesianOption(p, "bar"));
|
|
695
|
+
var LineChart = createChartComponent("LineChart", (p) => cartesianOption(p, "line"));
|
|
696
|
+
var CompositeChart = createChartComponent("CompositeChart", (p) => cartesianOption(p, "composite"));
|
|
697
|
+
var PieChart = createChartComponent("PieChart", (p) => radialOption(p));
|
|
698
|
+
var DonutChart = createChartComponent("DonutChart", (p) => radialOption(p, true));
|
|
699
|
+
var ScatterChart = createChartComponent("ScatterChart", (p) => scatterOption(p));
|
|
700
|
+
var BubbleChart = createChartComponent("BubbleChart", (p) => scatterOption(p, true));
|
|
701
|
+
var RadarChart = createChartComponent("RadarChart", radarOption);
|
|
702
|
+
var RadialBarChart = createChartComponent("RadialBarChart", radialBarOption);
|
|
703
|
+
var FunnelChart = createChartComponent("FunnelChart", (p) => simpleOption("funnel", p));
|
|
704
|
+
var Treemap = createChartComponent("Treemap", (p) => simpleOption("treemap", p));
|
|
705
|
+
var SankeyChart = createChartComponent("SankeyChart", (p) => simpleOption("sankey", p));
|
|
706
|
+
var Sparkline = createChartComponent("Sparkline", sparklineOption);
|
|
707
|
+
var Heatmap = createChartComponent("Heatmap", heatmapOption);
|
|
708
|
+
var BarsList = createChartComponent("BarsList", (p) => cartesianOption({
|
|
709
|
+
...p,
|
|
710
|
+
dataKey: "name",
|
|
711
|
+
series: [{
|
|
712
|
+
name: "value",
|
|
713
|
+
color: p.barColor
|
|
714
|
+
}],
|
|
715
|
+
orientation: "vertical",
|
|
716
|
+
withXAxis: false,
|
|
717
|
+
withYAxis: true,
|
|
718
|
+
withTooltip: false,
|
|
719
|
+
maxBarWidth: p.barHeight
|
|
720
|
+
}, "bar"));
|
|
721
|
+
//#endregion
|
|
722
|
+
//#region src/ChartTooltip/ChartTooltip.ts
|
|
723
|
+
var ChartTooltip = (0, vue.defineComponent)({
|
|
724
|
+
name: "MantineChartTooltip",
|
|
725
|
+
props: {
|
|
726
|
+
label: null,
|
|
727
|
+
payload: Array,
|
|
728
|
+
unit: String,
|
|
729
|
+
type: {
|
|
730
|
+
type: String,
|
|
731
|
+
default: "area"
|
|
732
|
+
},
|
|
733
|
+
segmentId: String,
|
|
734
|
+
series: Array,
|
|
735
|
+
valueFormatter: Function,
|
|
736
|
+
showColor: {
|
|
737
|
+
type: Boolean,
|
|
738
|
+
default: true
|
|
739
|
+
}
|
|
740
|
+
},
|
|
741
|
+
setup(props) {
|
|
742
|
+
const labels = (0, vue.computed)(() => Object.fromEntries((props.series ?? []).map((item) => [item.name, item.label ?? item.name])));
|
|
743
|
+
return () => {
|
|
744
|
+
const payload = props.segmentId ? props.payload?.filter((item) => item.name === props.segmentId || item.dataKey === props.segmentId) : props.payload;
|
|
745
|
+
if (!payload?.length) return null;
|
|
746
|
+
return (0, vue.h)("div", {
|
|
747
|
+
class: "mantine-ChartTooltip-tooltip",
|
|
748
|
+
"data-type": props.type
|
|
749
|
+
}, [props.label != null ? (0, vue.h)("div", { class: "mantine-ChartTooltip-tooltipLabel" }, [props.label]) : null, (0, vue.h)("div", { class: "mantine-ChartTooltip-tooltipBody" }, payload.map((item) => (0, vue.h)("div", { class: "mantine-ChartTooltip-tooltipItem" }, [(0, vue.h)("div", { class: "mantine-ChartTooltip-tooltipItemBody" }, [props.showColor ? (0, vue.h)("span", {
|
|
750
|
+
class: "mantine-ChartTooltip-tooltipItemColor",
|
|
751
|
+
style: { background: resolveColor(item.color) }
|
|
752
|
+
}) : null, (0, vue.h)("span", { class: "mantine-ChartTooltip-tooltipItemName" }, labels.value[item.name ?? ""] ?? item.name)]), (0, vue.h)("span", { class: "mantine-ChartTooltip-tooltipItemData" }, `${props.valueFormatter ? props.valueFormatter(Number(item.value)) : item.value ?? ""}${props.unit ?? item.unit ?? ""}`)])))]);
|
|
753
|
+
};
|
|
754
|
+
}
|
|
755
|
+
});
|
|
756
|
+
//#endregion
|
|
757
|
+
//#region src/ChartLegend/ChartLegend.ts
|
|
758
|
+
var ChartLegend = (0, vue.defineComponent)({
|
|
759
|
+
name: "MantineChartLegend",
|
|
760
|
+
props: {
|
|
761
|
+
payload: Array,
|
|
762
|
+
onHighlight: {
|
|
763
|
+
type: Function,
|
|
764
|
+
required: true
|
|
765
|
+
},
|
|
766
|
+
legendPosition: {
|
|
767
|
+
type: String,
|
|
768
|
+
required: true
|
|
769
|
+
},
|
|
770
|
+
series: Array,
|
|
771
|
+
showColor: {
|
|
772
|
+
type: Boolean,
|
|
773
|
+
default: true
|
|
774
|
+
},
|
|
775
|
+
centered: Boolean
|
|
776
|
+
},
|
|
777
|
+
setup(props) {
|
|
778
|
+
return () => (0, vue.h)("div", {
|
|
779
|
+
class: "mantine-ChartLegend-legend",
|
|
780
|
+
"data-position": props.legendPosition,
|
|
781
|
+
"data-centered": props.centered || void 0,
|
|
782
|
+
onMouseleave: () => props.onHighlight(null)
|
|
783
|
+
}, props.payload?.map((item) => {
|
|
784
|
+
const key = item.dataKey ?? item.name ?? "";
|
|
785
|
+
const label = props.series?.find((s) => s.name === key)?.label ?? key;
|
|
786
|
+
return (0, vue.h)("div", {
|
|
787
|
+
class: "mantine-ChartLegend-legendItem",
|
|
788
|
+
onMouseenter: () => props.onHighlight(key)
|
|
789
|
+
}, [props.showColor ? (0, vue.h)("span", {
|
|
790
|
+
class: "mantine-ChartLegend-legendItemColor",
|
|
791
|
+
style: { background: resolveColor(item.color) }
|
|
792
|
+
}) : null, (0, vue.h)("span", { class: "mantine-ChartLegend-legendItemName" }, label)]);
|
|
793
|
+
}));
|
|
794
|
+
}
|
|
795
|
+
});
|
|
796
|
+
//#endregion
|
|
797
|
+
//#region src/utils/get-series-labels/get-series-labels.ts
|
|
798
|
+
function getSeriesLabels(series) {
|
|
799
|
+
return Object.fromEntries((series ?? []).map((item) => [item.name, item.label ?? item.name]));
|
|
800
|
+
}
|
|
801
|
+
//#endregion
|
|
802
|
+
exports.AreaChart = AreaChart;
|
|
803
|
+
exports.BarChart = BarChart;
|
|
804
|
+
exports.BarsList = BarsList;
|
|
805
|
+
exports.BubbleChart = BubbleChart;
|
|
806
|
+
exports.ChartLegend = ChartLegend;
|
|
807
|
+
exports.ChartTooltip = ChartTooltip;
|
|
808
|
+
exports.CompositeChart = CompositeChart;
|
|
809
|
+
exports.DonutChart = DonutChart;
|
|
810
|
+
exports.FunnelChart = FunnelChart;
|
|
811
|
+
exports.Heatmap = Heatmap;
|
|
812
|
+
exports.LineChart = LineChart;
|
|
813
|
+
exports.PieChart = PieChart;
|
|
814
|
+
exports.RadarChart = RadarChart;
|
|
815
|
+
exports.RadialBarChart = RadialBarChart;
|
|
816
|
+
exports.SankeyChart = SankeyChart;
|
|
817
|
+
exports.ScatterChart = ScatterChart;
|
|
818
|
+
exports.Sparkline = Sparkline;
|
|
819
|
+
exports.Treemap = Treemap;
|
|
820
|
+
exports.getSeriesLabels = getSeriesLabels;
|
|
821
|
+
|
|
822
|
+
//# sourceMappingURL=index.cjs.map
|