@pushwoosh/kit-charts 0.0.2 → 0.0.3
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/core/Chart/Axes.js +38 -51
- package/core/Chart/Chart.js +45 -53
- package/core/Chart/Hinted.js +1 -2
- package/core/Chart/Legend.js +14 -15
- package/core/Chart/PlotDecorations.js +5 -5
- package/core/Chart/StackLabels.js +6 -7
- package/core/Chart/Titles.js +14 -17
- package/core/Chart/Tooltip.js +12 -13
- package/core/data/points.js +1 -1
- package/core/geometry/path.js +1 -2
- package/core/layout/legend-layout.js +12 -12
- package/core/layout/measure-text.js +3 -3
- package/core/layout/title-layout.js +9 -15
- package/core/model/build-model.js +44 -69
- package/core/options/normalize.js +1 -2
- package/core/registry/registry.js +1 -1
- package/package.json +2 -2
- package/series/area/area.js +2 -3
- package/series/column/column.js +4 -8
- package/series/heatmap/heatmap.js +5 -8
- package/series/line/line.js +2 -3
- package/series/pie/pie.js +6 -8
- package/series/shared/DataLabels.js +8 -8
- package/series/shared/Markers.js +8 -8
|
@@ -74,18 +74,16 @@ function toCells(ctx) {
|
|
|
74
74
|
}, []);
|
|
75
75
|
}
|
|
76
76
|
const fillOf = (ctx, cell, hovered) => {
|
|
77
|
-
|
|
78
|
-
const scaled = cell.point.value === null ? undefined : (_ctx$scales$color = ctx.scales.color) === null || _ctx$scales$color === void 0 ? void 0 : _ctx$scales$color.map(cell.point.value);
|
|
77
|
+
const scaled = cell.point.value === null ? undefined : ctx.scales.color?.map(cell.point.value);
|
|
79
78
|
const base = cell.point.color ?? scaled ?? ctx.color;
|
|
80
79
|
if (!hovered) {
|
|
81
80
|
return base;
|
|
82
81
|
}
|
|
83
|
-
return brighten(base,
|
|
82
|
+
return brighten(base, ctx.series.states?.hover?.brightness ?? DEFAULT_HOVER_BRIGHTNESS);
|
|
84
83
|
};
|
|
85
84
|
const labelX = (ctx, cell) => {
|
|
86
|
-
|
|
87
|
-
const
|
|
88
|
-
const align = (_ctx$series$dataLabel2 = ctx.series.dataLabels) === null || _ctx$series$dataLabel2 === void 0 ? void 0 : _ctx$series$dataLabel2.align;
|
|
85
|
+
const padding = ctx.series.dataLabels?.padding ?? VALUE_LABEL_GAP;
|
|
86
|
+
const align = ctx.series.dataLabels?.align;
|
|
89
87
|
if (align === 'left') {
|
|
90
88
|
return cell.x + padding;
|
|
91
89
|
}
|
|
@@ -117,12 +115,11 @@ export const heatmap = {
|
|
|
117
115
|
};
|
|
118
116
|
},
|
|
119
117
|
render: ctx => {
|
|
120
|
-
var _ctx$hovered;
|
|
121
118
|
const cells = toCells(ctx);
|
|
122
119
|
if (!cells.length) {
|
|
123
120
|
return null;
|
|
124
121
|
}
|
|
125
|
-
const hoveredIndex =
|
|
122
|
+
const hoveredIndex = ctx.hovered?.pointIndex;
|
|
126
123
|
const borderWidth = ctx.series.borderWidth ?? 0;
|
|
127
124
|
const radius = ctx.series.borderRadius;
|
|
128
125
|
return _jsxs("g", {
|
package/series/line/line.js
CHANGED
|
@@ -11,14 +11,13 @@ export const line = {
|
|
|
11
11
|
},
|
|
12
12
|
extendDomain: (_series, acc) => acc,
|
|
13
13
|
render: ctx => {
|
|
14
|
-
var _ctx$hovered, _ctx$series$marker;
|
|
15
14
|
const slots = projectSeries(ctx);
|
|
16
15
|
const projected = drawable(slots);
|
|
17
16
|
if (!projected.length) {
|
|
18
17
|
return null;
|
|
19
18
|
}
|
|
20
19
|
const color = ctx.color;
|
|
21
|
-
const hoveredIndex =
|
|
20
|
+
const hoveredIndex = ctx.hovered?.pointIndex;
|
|
22
21
|
const hovered = hoveredIndex === undefined ? undefined : projected.find(({
|
|
23
22
|
point
|
|
24
23
|
}) => point.index === hoveredIndex);
|
|
@@ -37,7 +36,7 @@ export const line = {
|
|
|
37
36
|
}), hovered ? _jsx("circle", {
|
|
38
37
|
cx: hovered.px,
|
|
39
38
|
cy: hovered.py,
|
|
40
|
-
r:
|
|
39
|
+
r: ctx.series.marker?.states?.hover?.radius ?? 4,
|
|
41
40
|
fill: color,
|
|
42
41
|
stroke: "#FFFFFF",
|
|
43
42
|
strokeWidth: 2
|
package/series/pie/pie.js
CHANGED
|
@@ -95,11 +95,10 @@ function Labels({
|
|
|
95
95
|
geometry
|
|
96
96
|
}) {
|
|
97
97
|
const labels = ctx.series.dataLabels;
|
|
98
|
-
if (!
|
|
98
|
+
if (!labels?.enabled) {
|
|
99
99
|
return null;
|
|
100
100
|
}
|
|
101
101
|
return slices.filter(slice => !slice.hidden).map(slice => {
|
|
102
|
-
var _labels$style, _labels$style2, _labels$style3, _labels$style4;
|
|
103
102
|
const mid = (slice.from + slice.to) / 2;
|
|
104
103
|
const at = polar(geometry.cx, geometry.cy, geometry.outer + LABEL_OFFSET, mid);
|
|
105
104
|
const text = labels.formatter ? labels.formatter({
|
|
@@ -116,10 +115,10 @@ function Labels({
|
|
|
116
115
|
y: at.y,
|
|
117
116
|
textAnchor: Math.cos(mid) < 0 ? 'end' : 'start',
|
|
118
117
|
dominantBaseline: "middle",
|
|
119
|
-
fill: labels.color ??
|
|
120
|
-
fontFamily:
|
|
121
|
-
fontSize:
|
|
122
|
-
fontWeight:
|
|
118
|
+
fill: labels.color ?? labels.style?.color,
|
|
119
|
+
fontFamily: labels.style?.fontFamily,
|
|
120
|
+
fontSize: labels.style?.fontSize ?? '11px',
|
|
121
|
+
fontWeight: labels.style?.fontWeight,
|
|
123
122
|
children: text
|
|
124
123
|
}, `label-${slice.point.index}`);
|
|
125
124
|
});
|
|
@@ -134,7 +133,6 @@ function Labels({
|
|
|
134
133
|
function Slices({
|
|
135
134
|
ctx
|
|
136
135
|
}) {
|
|
137
|
-
var _ctx$hovered;
|
|
138
136
|
const slices = toSlices(ctx);
|
|
139
137
|
const alive = ctx.points.some(point => !ctx.hiddenPoints.has(point.index));
|
|
140
138
|
const targets = [...slices.flatMap(slice => [slice.from, slice.to]), ctx.hidden || !alive ? 0 : 1];
|
|
@@ -144,7 +142,7 @@ function Slices({
|
|
|
144
142
|
}
|
|
145
143
|
const radiusScale = tweened[tweened.length - 1] ?? 1;
|
|
146
144
|
const geometry = geometryOf(ctx, radiusScale);
|
|
147
|
-
const hovered =
|
|
145
|
+
const hovered = ctx.hovered?.pointIndex;
|
|
148
146
|
const drawn = slices.map((slice, index) => ({
|
|
149
147
|
...slice,
|
|
150
148
|
from: tweened[index * 2] ?? slice.from,
|
|
@@ -13,11 +13,11 @@ export const labelAnchor = align => {
|
|
|
13
13
|
return 'middle';
|
|
14
14
|
};
|
|
15
15
|
const textProps = style => ({
|
|
16
|
-
fontFamily: style
|
|
17
|
-
fontSize: style
|
|
18
|
-
fontWeight: style
|
|
19
|
-
fontStyle: style
|
|
20
|
-
paintOrder:
|
|
16
|
+
fontFamily: style?.fontFamily,
|
|
17
|
+
fontSize: style?.fontSize,
|
|
18
|
+
fontWeight: style?.fontWeight,
|
|
19
|
+
fontStyle: style?.fontStyle,
|
|
20
|
+
paintOrder: style?.textOutline === 'none' ? undefined : 'stroke'
|
|
21
21
|
});
|
|
22
22
|
/** No formatter and no format string: the chart's own number rule prints it. */
|
|
23
23
|
const defaultLabel = (ctx, format, y) => {
|
|
@@ -44,7 +44,7 @@ export function DataLabels({
|
|
|
44
44
|
positionOf
|
|
45
45
|
}) {
|
|
46
46
|
const options = ctx.series.dataLabels;
|
|
47
|
-
if (!
|
|
47
|
+
if (!options?.enabled) {
|
|
48
48
|
return null;
|
|
49
49
|
}
|
|
50
50
|
const turbo = ctx.series.turboThreshold;
|
|
@@ -110,12 +110,12 @@ export function DataLabels({
|
|
|
110
110
|
x: at.x,
|
|
111
111
|
y: y,
|
|
112
112
|
textAnchor: anchor,
|
|
113
|
-
fill: options.color ??
|
|
113
|
+
fill: options.color ?? style?.color ?? DEFAULT_TEXT_COLOR,
|
|
114
114
|
...textProps(style),
|
|
115
115
|
children: lines && lines.length > 1 ? lines.map((text, index) => _jsx("tspan", {
|
|
116
116
|
x: at.x,
|
|
117
117
|
dy: index === 0 ? 0 : textHeight(secondary ?? style),
|
|
118
|
-
fill: index === 0 ? undefined : secondary
|
|
118
|
+
fill: index === 0 ? undefined : secondary?.color,
|
|
119
119
|
...(index === 0 ? {} : textProps(secondary)),
|
|
120
120
|
children: text
|
|
121
121
|
}, `line-${index}`)) : content
|
package/series/shared/Markers.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
const markerRadius = marker =>
|
|
2
|
+
const markerRadius = marker => marker?.radius ?? (marker?.width ? marker.width / 2 : 3);
|
|
3
3
|
export function Markers({
|
|
4
4
|
marker,
|
|
5
5
|
projected,
|
|
6
6
|
color
|
|
7
7
|
}) {
|
|
8
|
-
if (
|
|
8
|
+
if (marker?.enabled === false || marker?.symbol === 'none') {
|
|
9
9
|
return null;
|
|
10
10
|
}
|
|
11
11
|
const radius = markerRadius(marker);
|
|
12
|
-
const fill =
|
|
13
|
-
const square =
|
|
12
|
+
const fill = marker?.fillColor ?? color;
|
|
13
|
+
const square = marker?.symbol === 'square';
|
|
14
14
|
return projected.map(({
|
|
15
15
|
point,
|
|
16
16
|
px,
|
|
@@ -21,14 +21,14 @@ export function Markers({
|
|
|
21
21
|
width: radius * 2,
|
|
22
22
|
height: radius * 2,
|
|
23
23
|
fill: fill,
|
|
24
|
-
stroke: marker
|
|
25
|
-
strokeWidth: marker
|
|
24
|
+
stroke: marker?.lineColor,
|
|
25
|
+
strokeWidth: marker?.lineWidth
|
|
26
26
|
}, `m-${point.index}`) : _jsx("circle", {
|
|
27
27
|
cx: px,
|
|
28
28
|
cy: py,
|
|
29
29
|
r: radius,
|
|
30
30
|
fill: fill,
|
|
31
|
-
stroke: marker
|
|
32
|
-
strokeWidth: marker
|
|
31
|
+
stroke: marker?.lineColor,
|
|
32
|
+
strokeWidth: marker?.lineWidth
|
|
33
33
|
}, `m-${point.index}`));
|
|
34
34
|
}
|