@apia/charts 2.0.7 → 2.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/dist/charts/chartJsRenderer/ChartComponent.d.ts +22 -0
- package/dist/charts/chartJsRenderer/ChartComponent.d.ts.map +1 -0
- package/dist/charts/chartJsRenderer/ChartComponent.js +244 -0
- package/dist/charts/chartJsRenderer/ChartComponent.js.map +1 -0
- package/dist/charts/types.d.ts +2 -17
- package/dist/index.d.ts +3 -4
- package/dist/index.js +2 -3
- package/dist/index.js.map +1 -1
- package/dist/widgets/WidgetComponent.d.ts +10 -0
- package/dist/widgets/WidgetComponent.d.ts.map +1 -0
- package/dist/widgets/WidgetComponent.js +54 -0
- package/dist/widgets/WidgetComponent.js.map +1 -0
- package/dist/widgets/counter/Counter.js +8 -8
- package/dist/widgets/counter/Counter.js.map +1 -1
- package/dist/widgets/custom/useCustomWidget.js +3 -3
- package/dist/widgets/custom/useCustomWidget.js.map +1 -1
- package/dist/widgets/custom/util.js.map +1 -1
- package/dist/widgets/oxford/Oxford.js +3 -1
- package/dist/widgets/oxford/Oxford.js.map +1 -1
- package/dist/widgets/ring/Ring.js +4 -4
- package/dist/widgets/ring/Ring.js.map +1 -1
- package/dist/widgets/scale/Scale.js.map +1 -1
- package/dist/widgets/speedMeter/SpeedMeter.js +3 -1
- package/dist/widgets/speedMeter/SpeedMeter.js.map +1 -1
- package/dist/widgets/tLight/TLight.js +4 -4
- package/dist/widgets/tLight/TLight.js.map +1 -1
- package/dist/widgets/thermometer/Thermometer.js +7 -5
- package/dist/widgets/thermometer/Thermometer.js.map +1 -1
- package/dist/widgets/thermometer/util.js +4 -1
- package/dist/widgets/thermometer/util.js.map +1 -1
- package/dist/widgets/types.d.ts +66 -1
- package/package.json +8 -6
- package/dist/charts/ChartContext.js +0 -6
- package/dist/charts/ChartContext.js.map +0 -1
- package/dist/charts/ChartRenderer.d.ts +0 -17
- package/dist/charts/ChartRenderer.d.ts.map +0 -1
- package/dist/charts/ChartRenderer.js +0 -175
- package/dist/charts/ChartRenderer.js.map +0 -1
- package/dist/charts/horizontalBars/Bar.js +0 -228
- package/dist/charts/horizontalBars/Bar.js.map +0 -1
- package/dist/charts/horizontalBars/HorizontalBars.js +0 -374
- package/dist/charts/horizontalBars/HorizontalBars.js.map +0 -1
- package/dist/charts/linear/LineChart.js +0 -469
- package/dist/charts/linear/LineChart.js.map +0 -1
- package/dist/charts/linear/Node.js +0 -56
- package/dist/charts/linear/Node.js.map +0 -1
- package/dist/charts/pie/Pie.js +0 -183
- package/dist/charts/pie/Pie.js.map +0 -1
- package/dist/charts/pie/Slice.js +0 -96
- package/dist/charts/pie/Slice.js.map +0 -1
- package/dist/charts/pie/usePieAnimation.js +0 -123
- package/dist/charts/pie/usePieAnimation.js.map +0 -1
- package/dist/charts/util/ChartSelector.js +0 -36
- package/dist/charts/util/ChartSelector.js.map +0 -1
- package/dist/charts/util/ColoredLegendItem.js +0 -46
- package/dist/charts/util/ColoredLegendItem.js.map +0 -1
- package/dist/charts/util/EmptyGrid.d.ts +0 -8
- package/dist/charts/util/EmptyGrid.d.ts.map +0 -1
- package/dist/charts/util/EmptyGrid.js +0 -51
- package/dist/charts/util/EmptyGrid.js.map +0 -1
- package/dist/charts/util/LegendContainer.js +0 -54
- package/dist/charts/util/LegendContainer.js.map +0 -1
- package/dist/charts/util/NumberedLegendItem.js +0 -45
- package/dist/charts/util/NumberedLegendItem.js.map +0 -1
- package/dist/charts/util/getBarColor.js +0 -29
- package/dist/charts/util/getBarColor.js.map +0 -1
- package/dist/charts/util/parseMargin.js +0 -11
- package/dist/charts/util/parseMargin.js.map +0 -1
- package/dist/charts/util/useChartStyles.js +0 -35
- package/dist/charts/util/useChartStyles.js.map +0 -1
- package/dist/charts/verticalBars/Bar.js +0 -241
- package/dist/charts/verticalBars/Bar.js.map +0 -1
- package/dist/charts/verticalBars/VerticalBars.js +0 -394
- package/dist/charts/verticalBars/VerticalBars.js.map +0 -1
- package/dist/charts/waterfallBars/WaterfallBar.js +0 -84
- package/dist/charts/waterfallBars/WaterfallBar.js.map +0 -1
- package/dist/charts/waterfallBars/WaterfallBars.js +0 -247
- package/dist/charts/waterfallBars/WaterfallBars.js.map +0 -1
- package/dist/widgets/WidgetContainer.d.ts +0 -10
- package/dist/widgets/WidgetContainer.d.ts.map +0 -1
- package/dist/widgets/WidgetContainer.js +0 -68
- package/dist/widgets/WidgetContainer.js.map +0 -1
|
@@ -1,247 +0,0 @@
|
|
|
1
|
-
import { jsxs, Fragment, jsx } from '@apia/theme/jsx-runtime';
|
|
2
|
-
import { Box, Heading } from '@apia/theme';
|
|
3
|
-
import { arrayOrArray, usePanAndZoom, getLabel } from '@apia/util';
|
|
4
|
-
import { useState, useMemo, useLayoutEffect } from 'react';
|
|
5
|
-
import { scaleBand, scaleLinear } from '@visx/scale';
|
|
6
|
-
import { extent } from 'd3-array';
|
|
7
|
-
import { parseMargin } from '../util/parseMargin.js';
|
|
8
|
-
import { Group } from '@visx/group';
|
|
9
|
-
import { GridRows } from '@visx/grid';
|
|
10
|
-
import { AxisLeft, AxisBottom } from '@visx/axis';
|
|
11
|
-
import uniqueId from 'lodash-es/uniqueId';
|
|
12
|
-
import ChartSelector from '../util/ChartSelector.js';
|
|
13
|
-
import { WaterfallBar } from './WaterfallBar.js';
|
|
14
|
-
|
|
15
|
-
const calculateWaterfallSteps = ({
|
|
16
|
-
data,
|
|
17
|
-
xAccessor,
|
|
18
|
-
yAccessor,
|
|
19
|
-
showFinal,
|
|
20
|
-
colors
|
|
21
|
-
}) => {
|
|
22
|
-
let cumulativeTotal = 0;
|
|
23
|
-
const steps = data.map((datum) => {
|
|
24
|
-
const xValue = xAccessor(datum);
|
|
25
|
-
const yValue = yAccessor(datum);
|
|
26
|
-
const prevTotal = cumulativeTotal;
|
|
27
|
-
cumulativeTotal += Number(yValue);
|
|
28
|
-
return {
|
|
29
|
-
x: xValue,
|
|
30
|
-
y: yValue,
|
|
31
|
-
start: prevTotal,
|
|
32
|
-
end: cumulativeTotal,
|
|
33
|
-
color: Number(yValue) > 0 ? colors.positive : colors.negative
|
|
34
|
-
};
|
|
35
|
-
});
|
|
36
|
-
if (showFinal) {
|
|
37
|
-
steps.push({
|
|
38
|
-
x: "Total",
|
|
39
|
-
y: cumulativeTotal,
|
|
40
|
-
start: 0,
|
|
41
|
-
end: cumulativeTotal,
|
|
42
|
-
color: colors.total
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
return steps;
|
|
46
|
-
};
|
|
47
|
-
function adjustDimensions({
|
|
48
|
-
width,
|
|
49
|
-
height,
|
|
50
|
-
maxWidth
|
|
51
|
-
}) {
|
|
52
|
-
if (width <= maxWidth) {
|
|
53
|
-
return { width, height };
|
|
54
|
-
}
|
|
55
|
-
const ratio = width / height;
|
|
56
|
-
const newWidth = maxWidth;
|
|
57
|
-
const newHeight = Math.floor(newWidth / ratio);
|
|
58
|
-
return { width: newWidth, height: newHeight };
|
|
59
|
-
}
|
|
60
|
-
const WaterfallBars = ({
|
|
61
|
-
margin = { top: 20, left: 100, bottom: 150, right: 70 },
|
|
62
|
-
chart: {
|
|
63
|
-
waterfallColors = {
|
|
64
|
-
positive: "#49b86f",
|
|
65
|
-
negative: "#c92e5b",
|
|
66
|
-
total: "#434857",
|
|
67
|
-
stepConnector: "#888d94"
|
|
68
|
-
},
|
|
69
|
-
...chart
|
|
70
|
-
},
|
|
71
|
-
className,
|
|
72
|
-
chartId,
|
|
73
|
-
allowZoom
|
|
74
|
-
}) => {
|
|
75
|
-
console.log({ margin });
|
|
76
|
-
const effectiveMargin = parseMargin(margin);
|
|
77
|
-
if (!chart.showAxisYTitle && effectiveMargin.left > 50) {
|
|
78
|
-
effectiveMargin.left = 50;
|
|
79
|
-
}
|
|
80
|
-
let innerWidth = chart.ratio.width + (-effectiveMargin.left - effectiveMargin.right) / 2;
|
|
81
|
-
let innerHeight = chart.ratio.height + (-effectiveMargin.top - effectiveMargin.bottom) / 2;
|
|
82
|
-
if (innerWidth > chart.ratio.maxWidth) {
|
|
83
|
-
const newValues = adjustDimensions({
|
|
84
|
-
height: innerHeight,
|
|
85
|
-
width: innerWidth,
|
|
86
|
-
maxWidth: chart.ratio.maxWidth
|
|
87
|
-
});
|
|
88
|
-
innerWidth = newValues.width;
|
|
89
|
-
innerHeight = newValues.height;
|
|
90
|
-
}
|
|
91
|
-
const getXValue = (d) => d.key;
|
|
92
|
-
const getYValue = (d) => d.value;
|
|
93
|
-
const charts = arrayOrArray(chart.dataSets?.data).filter((piece) => !!piece.sets).map((piece) => {
|
|
94
|
-
return {
|
|
95
|
-
...piece,
|
|
96
|
-
coordinate: piece.sets
|
|
97
|
-
};
|
|
98
|
-
});
|
|
99
|
-
const [currentPie, setCurrentPie] = useState("0");
|
|
100
|
-
const chartNames = charts.map((piece) => {
|
|
101
|
-
return piece.name;
|
|
102
|
-
});
|
|
103
|
-
const steps = useMemo(
|
|
104
|
-
() => calculateWaterfallSteps({
|
|
105
|
-
data: arrayOrArray(chart.dataSets.data)[currentPie].sets,
|
|
106
|
-
xAccessor: getXValue,
|
|
107
|
-
yAccessor: getYValue,
|
|
108
|
-
showFinal: chart.showTotal ?? true,
|
|
109
|
-
colors: waterfallColors
|
|
110
|
-
}),
|
|
111
|
-
[chart.dataSets.data, chart.showTotal, currentPie, waterfallColors]
|
|
112
|
-
);
|
|
113
|
-
const padding = 0.2;
|
|
114
|
-
const xScale = scaleBand({
|
|
115
|
-
domain: steps.map((step) => step.x),
|
|
116
|
-
padding,
|
|
117
|
-
range: [0, innerWidth]
|
|
118
|
-
});
|
|
119
|
-
const yDomain = useMemo(() => {
|
|
120
|
-
const values = steps.flatMap((step) => [step.start, step.end]);
|
|
121
|
-
const [min, max] = extent(values);
|
|
122
|
-
return min != null && max != null ? [min - 5, max + 5] : void 0;
|
|
123
|
-
}, [steps]);
|
|
124
|
-
const yScale = scaleLinear({
|
|
125
|
-
domain: yDomain,
|
|
126
|
-
nice: true,
|
|
127
|
-
range: [innerHeight, 0]
|
|
128
|
-
});
|
|
129
|
-
const id = useMemo(() => `WaterfallBars${uniqueId()}`, []);
|
|
130
|
-
useLayoutEffect(() => {
|
|
131
|
-
document.querySelectorAll(`#${id} .tickLabel`).forEach((current) => {
|
|
132
|
-
const width = current.getBoundingClientRect().width;
|
|
133
|
-
current.style.transformOrigin = current.getAttribute("x") + "px 14px";
|
|
134
|
-
current.style.transform = `rotate(25deg) translateX(${width / 2}px)`;
|
|
135
|
-
});
|
|
136
|
-
});
|
|
137
|
-
const { boxRef, elementRef } = usePanAndZoom(
|
|
138
|
-
void 0,
|
|
139
|
-
!allowZoom
|
|
140
|
-
);
|
|
141
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
142
|
-
/* @__PURE__ */ jsx(
|
|
143
|
-
Box,
|
|
144
|
-
{
|
|
145
|
-
id,
|
|
146
|
-
className: `${className ? className : ""} chartBox chartContainer`,
|
|
147
|
-
ref: boxRef,
|
|
148
|
-
children: /* @__PURE__ */ jsx(
|
|
149
|
-
"svg",
|
|
150
|
-
{
|
|
151
|
-
height: chart.ratio.height,
|
|
152
|
-
width: chart.ratio.width,
|
|
153
|
-
ref: elementRef,
|
|
154
|
-
children: /* @__PURE__ */ jsxs(Group, { left: effectiveMargin.left, top: effectiveMargin.top, children: [
|
|
155
|
-
/* @__PURE__ */ jsx(GridRows, { scale: yScale, width: innerWidth, strokeDasharray: "5" }),
|
|
156
|
-
steps.map((step, index) => {
|
|
157
|
-
const x = xScale(step.x);
|
|
158
|
-
const y = yScale(Math.max(step.start, step.end));
|
|
159
|
-
if (x == null || y == null) {
|
|
160
|
-
return null;
|
|
161
|
-
}
|
|
162
|
-
const barHeight = Math.abs(yScale(step.start) - yScale(step.end));
|
|
163
|
-
const isLast = index === steps.length - 1;
|
|
164
|
-
const linePadding = 2;
|
|
165
|
-
const x1 = x + xScale.bandwidth() + linePadding;
|
|
166
|
-
const x2 = x + xScale.bandwidth() / (1 - padding) - linePadding;
|
|
167
|
-
const lineY = step.end < step.start ? y + barHeight : y;
|
|
168
|
-
const labelOffset = 10;
|
|
169
|
-
const labelY = yScale(step.end) + (step.y < 0 ? labelOffset : -labelOffset);
|
|
170
|
-
let currentYValue = 0;
|
|
171
|
-
steps.filter((_, i) => {
|
|
172
|
-
if ((chart.showTotal ?? true) && !steps[i + 1]) {
|
|
173
|
-
return false;
|
|
174
|
-
}
|
|
175
|
-
return i <= index;
|
|
176
|
-
}).forEach((step2) => {
|
|
177
|
-
currentYValue += Number(step2.y);
|
|
178
|
-
});
|
|
179
|
-
return /* @__PURE__ */ jsx(
|
|
180
|
-
WaterfallBar,
|
|
181
|
-
{
|
|
182
|
-
chart,
|
|
183
|
-
columnName: chartNames[currentPie],
|
|
184
|
-
fill: step.color,
|
|
185
|
-
height: barHeight,
|
|
186
|
-
isLast,
|
|
187
|
-
lineY,
|
|
188
|
-
step,
|
|
189
|
-
stroke: waterfallColors.stepConnector,
|
|
190
|
-
strokeDashArray: 2,
|
|
191
|
-
textContent: chart.showTotal ?? true ? step.y : currentYValue,
|
|
192
|
-
textX: x + xScale.bandwidth() / 2,
|
|
193
|
-
textY: labelY + 5,
|
|
194
|
-
width: xScale.bandwidth(),
|
|
195
|
-
x,
|
|
196
|
-
y,
|
|
197
|
-
x1,
|
|
198
|
-
x2
|
|
199
|
-
},
|
|
200
|
-
index
|
|
201
|
-
);
|
|
202
|
-
}),
|
|
203
|
-
/* @__PURE__ */ jsx(
|
|
204
|
-
AxisLeft,
|
|
205
|
-
{
|
|
206
|
-
label: "",
|
|
207
|
-
scale: yScale,
|
|
208
|
-
hideTicks: true,
|
|
209
|
-
tickLabelProps: () => ({
|
|
210
|
-
textAnchor: "end",
|
|
211
|
-
verticalAnchor: "middle",
|
|
212
|
-
display: chart.showAxisYTitle ? "auto" : "none"
|
|
213
|
-
})
|
|
214
|
-
}
|
|
215
|
-
),
|
|
216
|
-
/* @__PURE__ */ jsx(
|
|
217
|
-
AxisBottom,
|
|
218
|
-
{
|
|
219
|
-
scale: xScale,
|
|
220
|
-
top: innerHeight,
|
|
221
|
-
tickLabelProps: { display: "none" },
|
|
222
|
-
tickLineProps: { display: "none" }
|
|
223
|
-
}
|
|
224
|
-
)
|
|
225
|
-
] })
|
|
226
|
-
}
|
|
227
|
-
)
|
|
228
|
-
}
|
|
229
|
-
),
|
|
230
|
-
/* @__PURE__ */ jsx(Box, { className: "chartLegend__Wrapper", children: !chart.hideSelector && charts.length > 1 && /* @__PURE__ */ jsxs(Box, { className: "chart__combo__wrapper", children: [
|
|
231
|
-
/* @__PURE__ */ jsx(Heading, { as: "h6", children: getLabel("lblChartSel").text }),
|
|
232
|
-
/* @__PURE__ */ jsx(
|
|
233
|
-
ChartSelector,
|
|
234
|
-
{
|
|
235
|
-
chartId,
|
|
236
|
-
pieces: chartNames,
|
|
237
|
-
className: "chartSelectorCombo",
|
|
238
|
-
current: currentPie,
|
|
239
|
-
setCurrent: setCurrentPie
|
|
240
|
-
}
|
|
241
|
-
)
|
|
242
|
-
] }) })
|
|
243
|
-
] });
|
|
244
|
-
};
|
|
245
|
-
|
|
246
|
-
export { WaterfallBars };
|
|
247
|
-
//# sourceMappingURL=WaterfallBars.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WaterfallBars.js","sources":["../../../src/charts/waterfallBars/WaterfallBars.tsx"],"sourcesContent":["import { Box, Heading } from '@apia/theme';\nimport { TChartRendererProps } from '../types';\nimport { arrayOrArray, getLabel, usePanAndZoom } from '@apia/util';\nimport React, { useMemo, useLayoutEffect, useState } from 'react';\nimport { scaleBand, scaleLinear } from '@visx/scale';\nimport { extent } from 'd3-array';\nimport { parseMargin } from '../util/parseMargin';\nimport { Group } from '@visx/group';\nimport { GridRows } from '@visx/grid';\nimport { AxisBottom, AxisLeft } from '@visx/axis';\nimport uniqueId from 'lodash-es/uniqueId';\nimport ChartSelector from '../util/ChartSelector';\nimport { WaterfallBar } from './WaterfallBar';\n// import { LegendContainer } from '../util/LegendContainer';\n\nexport interface IParsedColumn {\n columnName: string;\n [key: string]: string;\n}\n\ntype TDatum = { key: string; value: string };\n\nconst calculateWaterfallSteps = ({\n data,\n xAccessor,\n yAccessor,\n showFinal,\n colors,\n}: {\n data: TDatum[];\n xAccessor: (d: TDatum) => string;\n yAccessor: (d: TDatum) => string;\n showFinal: boolean;\n colors: {\n positive: string;\n negative: string;\n total: string;\n stepConnector: string;\n };\n}) => {\n // Holds cumulative value\n let cumulativeTotal = 0;\n\n // Calculate bars for each data point\n const steps = data.map((datum) => {\n const xValue = xAccessor(datum);\n const yValue = yAccessor(datum);\n\n const prevTotal = cumulativeTotal;\n cumulativeTotal += Number(yValue);\n\n return {\n x: xValue,\n y: yValue,\n start: prevTotal,\n end: cumulativeTotal,\n color: Number(yValue) > 0 ? colors.positive : colors.negative,\n };\n });\n\n // Add final Total bar\n if (showFinal) {\n steps.push({\n x: 'Total',\n y: cumulativeTotal as unknown as string,\n start: 0,\n end: cumulativeTotal,\n color: colors.total,\n });\n }\n\n return steps;\n};\nfunction adjustDimensions({\n width,\n height,\n maxWidth,\n}: {\n width: number;\n height: number;\n maxWidth: number;\n}) {\n if (width <= maxWidth) {\n return { width, height };\n }\n\n const ratio = width / height;\n const newWidth = maxWidth;\n const newHeight = Math.floor(newWidth / ratio);\n\n return { width: newWidth, height: newHeight };\n}\nexport const WaterfallBars = ({\n margin = { top: 20, left: 100, bottom: 150, right: 70 },\n chart: {\n waterfallColors = {\n positive: '#49b86f',\n negative: '#c92e5b',\n total: '#434857',\n stepConnector: '#888d94',\n },\n ...chart\n },\n className,\n chartId,\n allowZoom,\n}: TChartRendererProps) => {\n console.log({ margin });\n\n const effectiveMargin = parseMargin(margin);\n\n if (!chart.showAxisYTitle && effectiveMargin.left > 50) {\n effectiveMargin.left = 50;\n }\n let innerWidth =\n chart.ratio.width + (-effectiveMargin.left - effectiveMargin.right) / 2;\n let innerHeight =\n chart.ratio.height + (-effectiveMargin.top - effectiveMargin.bottom) / 2;\n if (innerWidth > chart.ratio.maxWidth) {\n const newValues = adjustDimensions({\n height: innerHeight,\n width: innerWidth,\n maxWidth: chart.ratio.maxWidth,\n });\n innerWidth = newValues.width;\n innerHeight = newValues.height;\n }\n\n const getXValue = (d: TDatum) => d.key;\n const getYValue = (d: TDatum) => d.value;\n\n const charts = arrayOrArray(chart.dataSets?.data)\n .filter((piece) => !!piece.sets)\n .map((piece) => {\n return {\n ...piece,\n coordinate: piece.sets,\n };\n });\n const [currentPie, setCurrentPie] = useState('0');\n const chartNames = charts.map((piece) => {\n return piece.name;\n });\n const steps = useMemo(\n () =>\n calculateWaterfallSteps({\n data: arrayOrArray(chart.dataSets.data)[currentPie as unknown as number]\n .sets as TDatum[],\n xAccessor: getXValue,\n yAccessor: getYValue,\n showFinal: chart.showTotal ?? true,\n colors: waterfallColors,\n }),\n [chart.dataSets.data, chart.showTotal, currentPie, waterfallColors],\n );\n\n // Build scales\n const padding = 0.2;\n\n const xScale = scaleBand({\n domain: steps.map((step) => step.x),\n padding,\n range: [0, innerWidth],\n });\n\n const yDomain = useMemo(() => {\n const values = steps.flatMap((step) => [step.start, step.end]);\n const [min, max] = extent<number>(values);\n return min != null && max != null ? [min - 5, max + 5] : undefined;\n }, [steps]);\n\n const yScale = scaleLinear({\n domain: yDomain,\n nice: true,\n range: [innerHeight, 0],\n });\n\n const id = useMemo(() => `WaterfallBars${uniqueId()}`, []);\n useLayoutEffect(() => {\n document\n .querySelectorAll<HTMLElement>(`#${id} .tickLabel`)\n .forEach((current) => {\n const width = current.getBoundingClientRect().width;\n // eslint-disable-next-line no-param-reassign\n current.style.transformOrigin =\n (current.getAttribute('x') as string) + 'px 14px';\n // eslint-disable-next-line no-param-reassign\n current.style.transform = `rotate(25deg) translateX(${width / 2}px)`;\n });\n });\n\n const { boxRef, elementRef } = usePanAndZoom<HTMLElement, SVGSVGElement>(\n undefined,\n !allowZoom ?? true,\n );\n return (\n <>\n <Box\n id={id}\n className={`${className ? className : ''} chartBox chartContainer`}\n ref={boxRef}\n >\n <svg\n height={chart.ratio.height}\n width={chart.ratio.width}\n ref={elementRef}\n >\n <Group left={effectiveMargin.left} top={effectiveMargin.top}>\n <GridRows scale={yScale} width={innerWidth} strokeDasharray=\"5\" />\n {steps.map((step, index) => {\n const x = xScale(step.x);\n const y = yScale(Math.max(step.start, step.end));\n\n if (x == null || y == null) {\n return null;\n }\n\n const barHeight = Math.abs(yScale(step.start) - yScale(step.end));\n\n const isLast = index === steps.length - 1;\n const linePadding = 2;\n const x1 = x + xScale.bandwidth() + linePadding;\n const x2 = x + xScale.bandwidth() / (1 - padding) - linePadding;\n const lineY = step.end < step.start ? y + barHeight : y;\n\n const labelOffset = 10;\n const labelY =\n yScale(step.end) +\n ((step.y as unknown as number) < 0\n ? labelOffset\n : -labelOffset);\n\n let currentYValue = 0;\n steps\n .filter((_, i) => {\n if ((chart.showTotal ?? true) && !steps[i + 1]) {\n return false;\n }\n return i <= index;\n })\n .forEach((step) => {\n currentYValue += Number(step.y);\n });\n\n return (\n <WaterfallBar\n chart={chart}\n columnName={chartNames[currentPie as unknown as number]}\n fill={step.color}\n height={barHeight}\n isLast={isLast}\n key={index}\n lineY={lineY}\n step={step}\n stroke={waterfallColors.stepConnector}\n strokeDashArray={2}\n textContent={\n chart.showTotal ?? true\n ? step.y\n : (currentYValue as unknown as string)\n }\n textX={x + xScale.bandwidth() / 2}\n textY={labelY + 5}\n width={xScale.bandwidth()}\n x={x}\n y={y}\n x1={x1}\n x2={x2}\n />\n );\n })}\n <AxisLeft\n label={''}\n scale={yScale}\n hideTicks\n tickLabelProps={() => ({\n textAnchor: 'end',\n verticalAnchor: 'middle',\n display: chart.showAxisYTitle ? 'auto' : 'none',\n })}\n />\n <AxisBottom\n scale={xScale}\n top={innerHeight}\n tickLabelProps={{ display: 'none' }}\n tickLineProps={{ display: 'none' }}\n />\n </Group>\n </svg>\n </Box>\n <Box className=\"chartLegend__Wrapper\">\n {!chart.hideSelector && charts.length > 1 && (\n <Box className=\"chart__combo__wrapper\">\n {/* TODO LABEL */}\n <Heading as={'h6'}>{getLabel('lblChartSel').text}</Heading>\n <ChartSelector\n chartId={chartId}\n pieces={chartNames}\n className=\"chartSelectorCombo\"\n current={currentPie}\n setCurrent={setCurrentPie}\n />\n </Box>\n )}\n {/* {chart.showLegend && (\n <Box className=\"chart__legend__wrapper\"> */}\n {/* TODO LABEL */}\n {/* <Heading as={'h6'}>Legend</Heading>\n <LegendContainer\n id={chartId}\n avoidEvent\n references={[\n {\n title: arrayOrArray(chart.dataSets.data)[\n currentPie as unknown as number\n ].name,\n color: 'transparent',\n },\n ]}\n />\n </Box>\n )} */}\n </Box>\n </>\n );\n};\n"],"names":["step"],"mappings":";;;;;;;;;;;;;;AAsBA,MAAM,0BAA0B,CAAC;AAAA,EAC/B,IAAA;AAAA,EACA,SAAA;AAAA,EACA,SAAA;AAAA,EACA,SAAA;AAAA,EACA,MAAA;AACF,CAWM,KAAA;AAEJ,EAAA,IAAI,eAAkB,GAAA,CAAA,CAAA;AAGtB,EAAA,MAAM,KAAQ,GAAA,IAAA,CAAK,GAAI,CAAA,CAAC,KAAU,KAAA;AAChC,IAAM,MAAA,MAAA,GAAS,UAAU,KAAK,CAAA,CAAA;AAC9B,IAAM,MAAA,MAAA,GAAS,UAAU,KAAK,CAAA,CAAA;AAE9B,IAAA,MAAM,SAAY,GAAA,eAAA,CAAA;AAClB,IAAA,eAAA,IAAmB,OAAO,MAAM,CAAA,CAAA;AAEhC,IAAO,OAAA;AAAA,MACL,CAAG,EAAA,MAAA;AAAA,MACH,CAAG,EAAA,MAAA;AAAA,MACH,KAAO,EAAA,SAAA;AAAA,MACP,GAAK,EAAA,eAAA;AAAA,MACL,OAAO,MAAO,CAAA,MAAM,IAAI,CAAI,GAAA,MAAA,CAAO,WAAW,MAAO,CAAA,QAAA;AAAA,KACvD,CAAA;AAAA,GACD,CAAA,CAAA;AAGD,EAAA,IAAI,SAAW,EAAA;AACb,IAAA,KAAA,CAAM,IAAK,CAAA;AAAA,M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,UACR,SAAU,EAAA,oBAAA;AAAA,UACV,OAAS,EAAA,UAAA;AAAA,UACT,UAAY,EAAA,aAAA;AAAA,SAAA;AAAA,OACd;AAAA,KAAA,EACF,CAoBJ,EAAA,CAAA;AAAA,GACF,EAAA,CAAA,CAAA;AAEJ;;;;"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { TWidgetData } from './types.js';
|
|
3
|
-
|
|
4
|
-
declare const WidgetContainer: ({ data, id, }: {
|
|
5
|
-
data: TWidgetData;
|
|
6
|
-
id: string;
|
|
7
|
-
}) => React.JSX.Element;
|
|
8
|
-
|
|
9
|
-
export { WidgetContainer };
|
|
10
|
-
//# sourceMappingURL=WidgetContainer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WidgetContainer.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { jsx } from '@apia/theme/jsx-runtime';
|
|
2
|
-
import { Scale } from './scale/Scale.js';
|
|
3
|
-
import { SpeedMeter } from './speedMeter/SpeedMeter.js';
|
|
4
|
-
import { TLight } from './tLight/TLight.js';
|
|
5
|
-
import { Oxford } from './oxford/Oxford.js';
|
|
6
|
-
import { Counter } from './counter/Counter.js';
|
|
7
|
-
import { Ring } from './ring/Ring.js';
|
|
8
|
-
import { Thermometer } from './thermometer/Thermometer.js';
|
|
9
|
-
import { arrayOrArray, getIndex } from '@apia/util';
|
|
10
|
-
import tinycolor from 'tinycolor2';
|
|
11
|
-
|
|
12
|
-
const WidgetContainer = ({
|
|
13
|
-
data,
|
|
14
|
-
id
|
|
15
|
-
}) => {
|
|
16
|
-
const realData = {
|
|
17
|
-
...data
|
|
18
|
-
};
|
|
19
|
-
const valueRanges = Array.from(
|
|
20
|
-
new Set(
|
|
21
|
-
arrayOrArray(realData.zones.Zone).map((zone) => {
|
|
22
|
-
return [Number(zone.minimum), Number(zone.maximum)];
|
|
23
|
-
}).flat().sort((a, b) => a - b)
|
|
24
|
-
)
|
|
25
|
-
);
|
|
26
|
-
const colorRanges = arrayOrArray(realData.zones.Zone).map((zone) => {
|
|
27
|
-
return tinycolor(zone.color).setAlpha(1 - (255 - zone.transparency) / 255).toPercentageRgbString();
|
|
28
|
-
}).flat();
|
|
29
|
-
const CurrentWidget = getIndex(
|
|
30
|
-
[SpeedMeter, Oxford, Counter, TLight, Thermometer, Scale, Ring],
|
|
31
|
-
[
|
|
32
|
-
realData.widKpiType === "1",
|
|
33
|
-
realData.widKpiType === "2",
|
|
34
|
-
realData.widKpiType === "3",
|
|
35
|
-
realData.widKpiType === "4",
|
|
36
|
-
realData.widKpiType === "5",
|
|
37
|
-
realData.widKpiType === "6",
|
|
38
|
-
realData.widKpiType === "7"
|
|
39
|
-
],
|
|
40
|
-
0
|
|
41
|
-
);
|
|
42
|
-
return /* @__PURE__ */ jsx(
|
|
43
|
-
CurrentWidget,
|
|
44
|
-
{
|
|
45
|
-
addBorder: realData.border,
|
|
46
|
-
backgroundColor: realData.backgroundColor,
|
|
47
|
-
colorRanges,
|
|
48
|
-
currentValue: Number(realData.currentValue),
|
|
49
|
-
decimals: realData.valueDecimals,
|
|
50
|
-
currentValueColor: realData.valueColor,
|
|
51
|
-
currentValueFontSize: realData.valueFontSize,
|
|
52
|
-
forceProp: realData.forceProp,
|
|
53
|
-
height: realData.height,
|
|
54
|
-
panelId: id,
|
|
55
|
-
maxValue: realData.maxValue,
|
|
56
|
-
minValue: realData.minValue,
|
|
57
|
-
pointerColor: realData.pointerColor,
|
|
58
|
-
ringEmptyColor: realData.noValueColor,
|
|
59
|
-
ringWidth: realData.ringAnchor,
|
|
60
|
-
scaleValuesSize: realData.scaleFontSize,
|
|
61
|
-
valueRanges,
|
|
62
|
-
width: realData.width
|
|
63
|
-
}
|
|
64
|
-
);
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
export { WidgetContainer };
|
|
68
|
-
//# sourceMappingURL=WidgetContainer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WidgetContainer.js","sources":["../../src/widgets/WidgetContainer.tsx"],"sourcesContent":["import { Scale } from './scale/Scale';\nimport { SpeedMeter } from './speedMeter/SpeedMeter';\nimport { TLight } from './tLight/TLight';\nimport { Oxford } from './oxford/Oxford';\nimport { Counter } from './counter/Counter';\nimport { Ring } from './ring/Ring';\nimport { Thermometer } from './thermometer/Thermometer';\n// import { Custom } from './custom/Custom';\nimport { TWidgetData } from './types';\nimport { arrayOrArray, getIndex } from '@apia/util';\nimport tinycolor from 'tinycolor2';\n\nexport const WidgetContainer = ({\n data,\n id,\n}: {\n data: TWidgetData;\n id: string;\n}) => {\n // const mockData: TWidgetData = {\n // border: true,\n // backgroundColor: 'white',\n // currentValue: 1010,\n // height: 400,\n // width: 400,\n // maxValue: 1050,\n // minValue: 1000,\n // noValueColor: '',\n // pointerColor: 'blue',\n // ringAnchor: 5,\n // scaleFontSize: 20,\n // valueColor: 'darkblue',\n // valueDecimals: 1,\n // valueFontSize: 50,\n // valueType: '',\n // widKpiType: 0,\n // zones: {\n // Zone: [\n // {\n // color: 'blue',\n // maximum: 1020,\n // minimum: 1000,\n // transparency: 230,\n // },\n // {\n // color: 'purple',\n // maximum: 1040,\n // minimum: 1020,\n // transparency: 150,\n // },\n // {\n // color: 'red',\n // maximum: 1050,\n // minimum: 1040,\n // transparency: 255,\n // },\n // ],\n // },\n // };\n\n const realData: TWidgetData = {\n ...data,\n };\n\n const valueRanges = Array.from(\n new Set(\n arrayOrArray(realData.zones.Zone)\n .map((zone) => {\n return [Number(zone.minimum), Number(zone.maximum)];\n })\n .flat()\n .sort((a, b) => a - b),\n ),\n );\n\n const colorRanges = arrayOrArray(realData.zones.Zone)\n .map((zone) => {\n return tinycolor(zone.color)\n .setAlpha(1 - (255 - zone.transparency) / 255)\n .toPercentageRgbString();\n })\n .flat();\n\n const CurrentWidget = getIndex(\n [SpeedMeter, Oxford, Counter, TLight, Thermometer, Scale, Ring],\n [\n realData.widKpiType === '1',\n realData.widKpiType === '2',\n realData.widKpiType === '3',\n realData.widKpiType === '4',\n realData.widKpiType === '5',\n realData.widKpiType === '6',\n realData.widKpiType === '7',\n ],\n 0,\n );\n\n return (\n <CurrentWidget\n addBorder={realData.border}\n backgroundColor={realData.backgroundColor}\n colorRanges={colorRanges}\n currentValue={Number(realData.currentValue)}\n decimals={realData.valueDecimals}\n currentValueColor={realData.valueColor}\n currentValueFontSize={realData.valueFontSize}\n forceProp={realData.forceProp}\n height={realData.height}\n panelId={id}\n maxValue={realData.maxValue}\n minValue={realData.minValue}\n pointerColor={realData.pointerColor}\n ringEmptyColor={realData.noValueColor}\n ringWidth={realData.ringAnchor}\n scaleValuesSize={realData.scaleFontSize}\n valueRanges={valueRanges}\n width={realData.width}\n />\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;AAYO,MAAM,kBAAkB,CAAC;AAAA,EAC9B,IAAA;AAAA,EACA,EAAA;AACF,CAGM,KAAA;AA0CJ,EAAA,MAAM,QAAwB,GAAA;AAAA,IAC5B,GAAG,IAAA;AAAA,GACL,CAAA;AAEA,EAAA,MAAM,cAAc,KAAM,CAAA,IAAA;AAAA,IACxB,IAAI,GAAA;AAAA,MACF,aAAa,QAAS,CAAA,KAAA,CAAM,IAAI,CAC7B,CAAA,GAAA,CAAI,CAAC,IAAS,KAAA;AACb,QAAO,OAAA,CAAC,OAAO,IAAK,CAAA,OAAO,GAAG,MAAO,CAAA,IAAA,CAAK,OAAO,CAAC,CAAA,CAAA;AAAA,OACnD,EACA,IAAK,EAAA,CACL,KAAK,CAAC,CAAA,EAAG,CAAM,KAAA,CAAA,GAAI,CAAC,CAAA;AAAA,KACzB;AAAA,GACF,CAAA;AAEA,EAAM,MAAA,WAAA,GAAc,aAAa,QAAS,CAAA,KAAA,CAAM,IAAI,CACjD,CAAA,GAAA,CAAI,CAAC,IAAS,KAAA;AACb,IAAO,OAAA,SAAA,CAAU,IAAK,CA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