@operato/chart 10.29.81 → 10.29.84
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/src/report/chart-math.d.ts +34 -0
- package/dist/src/report/chart-math.js +71 -0
- package/dist/src/report/report-charts.d.ts +118 -0
- package/dist/src/report/report-charts.js +573 -0
- package/dist/stories/common.d.ts +8 -0
- package/dist/stories/common.js +78 -0
- package/dist/stories/ox-chart-annotations.stories.d.ts +26 -0
- package/dist/stories/ox-chart-annotations.stories.js +267 -0
- package/dist/stories/ox-input-chart-bar.stories.d.ts +26 -0
- package/dist/stories/ox-input-chart-bar.stories.js +173 -0
- package/dist/stories/ox-input-chart-doughnut.stories.d.ts +28 -0
- package/dist/stories/ox-input-chart-doughnut.stories.js +115 -0
- package/dist/stories/ox-input-chart-hbar.stories.d.ts +26 -0
- package/dist/stories/ox-input-chart-hbar.stories.js +174 -0
- package/dist/stories/ox-input-chart-line.stories.d.ts +26 -0
- package/dist/stories/ox-input-chart-line.stories.js +184 -0
- package/dist/stories/ox-input-chart-pie.stories.d.ts +28 -0
- package/dist/stories/ox-input-chart-pie.stories.js +115 -0
- package/dist/stories/ox-input-chart-polar-area.stories.d.ts +28 -0
- package/dist/stories/ox-input-chart-polar-area.stories.js +115 -0
- package/dist/stories/ox-input-chart-radar.stories.d.ts +28 -0
- package/dist/stories/ox-input-chart-radar.stories.js +126 -0
- package/dist/stories/ox-input-chart-timeseries.stories.d.ts +27 -0
- package/dist/stories/ox-input-chart-timeseries.stories.js +281 -0
- package/package.json +31 -7
- package/CHANGELOG.md +0 -2823
- package/dist/src/chartjs/config-converter.js.map +0 -1
- package/dist/src/chartjs/ox-chart-js.js.map +0 -1
- package/dist/src/editors/configurer.js.map +0 -1
- package/dist/src/editors/index.js.map +0 -1
- package/dist/src/editors/input-chart-abstract.js.map +0 -1
- package/dist/src/editors/input-chart-styles.js.map +0 -1
- package/dist/src/editors/ox-input-chart-hbar.js.map +0 -1
- package/dist/src/editors/ox-input-chart-mixed.js.map +0 -1
- package/dist/src/editors/ox-input-chart-pie.js.map +0 -1
- package/dist/src/editors/ox-input-chart-radar.js.map +0 -1
- package/dist/src/editors/ox-input-chart-timeseries.js.map +0 -1
- package/dist/src/editors/ox-property-editor-chart.js.map +0 -1
- package/dist/src/editors/templates/annotations.js.map +0 -1
- package/dist/src/editors/templates/display-value.js.map +0 -1
- package/dist/src/editors/templates/series.js.map +0 -1
- package/dist/src/index.js.map +0 -1
- package/dist/src/progress/ox-progress-circle.js.map +0 -1
- package/dist/src/scichart/ox-scichart.js.map +0 -1
- package/dist/src/scichart/scichart-builder.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The arithmetic of the charts — axis ticks, a pie's slices, stacked bars. Pure: the chart elements
|
|
3
|
+
* draw what these return, and the tests call them bare.
|
|
4
|
+
*/
|
|
5
|
+
/** Round steps for an axis from `min` to `max` — about `count` of them, 1·2·2.5·5 × 10ⁿ apart, zero among them. */
|
|
6
|
+
export declare function niceTicks(min: number, max: number, count?: number): number[];
|
|
7
|
+
export interface Slice {
|
|
8
|
+
key: string;
|
|
9
|
+
label: string;
|
|
10
|
+
value: number;
|
|
11
|
+
/** Share of the whole, 0–100. */
|
|
12
|
+
percent: number;
|
|
13
|
+
/** The slice that holds everything past the largest few. */
|
|
14
|
+
rest?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* A pie's slices: the largest `keep` as they are, the others as one 「rest」 slice. Nothing
|
|
18
|
+
* negative or zero is a slice — a pie shows parts of a whole.
|
|
19
|
+
*/
|
|
20
|
+
export declare function pieSlices(items: readonly {
|
|
21
|
+
key?: string;
|
|
22
|
+
label: string;
|
|
23
|
+
value: number;
|
|
24
|
+
}[], keep?: number, restLabel?: string): Slice[];
|
|
25
|
+
/** The arc of a slice from `start` to `end` (fractions of the turn) on a ring — an SVG path. */
|
|
26
|
+
export declare function arcPath(cx: number, cy: number, outer: number, inner: number, start: number, end: number): string;
|
|
27
|
+
/**
|
|
28
|
+
* Stacked bars: for each category, where each series' piece starts and ends. Positives stack up
|
|
29
|
+
* from zero, negatives down from it, so a loss does not hide under a gain.
|
|
30
|
+
*/
|
|
31
|
+
export declare function stackRanges(series: readonly (readonly number[])[]): {
|
|
32
|
+
from: number;
|
|
33
|
+
to: number;
|
|
34
|
+
}[][];
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The arithmetic of the charts — axis ticks, a pie's slices, stacked bars. Pure: the chart elements
|
|
3
|
+
* draw what these return, and the tests call them bare.
|
|
4
|
+
*/
|
|
5
|
+
/** Round steps for an axis from `min` to `max` — about `count` of them, 1·2·2.5·5 × 10ⁿ apart, zero among them. */
|
|
6
|
+
export function niceTicks(min, max, count = 5) {
|
|
7
|
+
const lo = Math.min(0, min);
|
|
8
|
+
const hi = Math.max(0, max);
|
|
9
|
+
if (lo === hi)
|
|
10
|
+
return [0];
|
|
11
|
+
const raw = (hi - lo) / Math.max(1, count);
|
|
12
|
+
const power = Math.pow(10, Math.floor(Math.log10(raw)));
|
|
13
|
+
const step = [1, 2, 2.5, 5, 10].map(one => one * power).find(one => one >= raw) ?? 10 * power;
|
|
14
|
+
const first = Math.floor(lo / step) * step;
|
|
15
|
+
const last = Math.ceil(hi / step) * step;
|
|
16
|
+
const ticks = [];
|
|
17
|
+
for (let at = first; at <= last + step / 2; at += step)
|
|
18
|
+
ticks.push(Math.round(at / step) * step);
|
|
19
|
+
return ticks;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A pie's slices: the largest `keep` as they are, the others as one 「rest」 slice. Nothing
|
|
23
|
+
* negative or zero is a slice — a pie shows parts of a whole.
|
|
24
|
+
*/
|
|
25
|
+
export function pieSlices(items, keep = 6, restLabel = '') {
|
|
26
|
+
const parts = items.filter(one => one.value > 0).sort((a, b) => b.value - a.value);
|
|
27
|
+
const total = parts.reduce((sum, one) => sum + one.value, 0);
|
|
28
|
+
if (!total)
|
|
29
|
+
return [];
|
|
30
|
+
const shown = parts.length > keep + 1 ? parts.slice(0, keep) : parts;
|
|
31
|
+
const slices = shown.map(one => ({ key: one.key ?? one.label, label: one.label, value: one.value, percent: (one.value / total) * 100 }));
|
|
32
|
+
const rest = parts.slice(shown.length).reduce((sum, one) => sum + one.value, 0);
|
|
33
|
+
if (rest)
|
|
34
|
+
slices.push({ key: '__rest__', label: restLabel, value: rest, percent: (rest / total) * 100, rest: true });
|
|
35
|
+
return slices;
|
|
36
|
+
}
|
|
37
|
+
/** The arc of a slice from `start` to `end` (fractions of the turn) on a ring — an SVG path. */
|
|
38
|
+
export function arcPath(cx, cy, outer, inner, start, end) {
|
|
39
|
+
const full = end - start >= 0.9999;
|
|
40
|
+
const point = (radius, at) => {
|
|
41
|
+
const angle = at * 2 * Math.PI - Math.PI / 2;
|
|
42
|
+
return [cx + radius * Math.cos(angle), cy + radius * Math.sin(angle)].map(one => one.toFixed(2)).join(' ');
|
|
43
|
+
};
|
|
44
|
+
if (full) {
|
|
45
|
+
/* A whole ring — two halves, as one arc cannot close on itself. */
|
|
46
|
+
return `M ${point(outer, 0)} A ${outer} ${outer} 0 1 1 ${point(outer, 0.5)} A ${outer} ${outer} 0 1 1 ${point(outer, 0)} M ${point(inner, 0)} A ${inner} ${inner} 0 1 0 ${point(inner, 0.5)} A ${inner} ${inner} 0 1 0 ${point(inner, 0)} Z`;
|
|
47
|
+
}
|
|
48
|
+
const large = end - start > 0.5 ? 1 : 0;
|
|
49
|
+
return `M ${point(outer, start)} A ${outer} ${outer} 0 ${large} 1 ${point(outer, end)} L ${point(inner, end)} A ${inner} ${inner} 0 ${large} 0 ${point(inner, start)} Z`;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Stacked bars: for each category, where each series' piece starts and ends. Positives stack up
|
|
53
|
+
* from zero, negatives down from it, so a loss does not hide under a gain.
|
|
54
|
+
*/
|
|
55
|
+
export function stackRanges(series) {
|
|
56
|
+
const count = Math.max(0, ...series.map(one => one.length));
|
|
57
|
+
const up = new Array(count).fill(0);
|
|
58
|
+
const down = new Array(count).fill(0);
|
|
59
|
+
return series.map(values => Array.from({ length: count }, (_, at) => {
|
|
60
|
+
const value = values[at] ?? 0;
|
|
61
|
+
if (value >= 0) {
|
|
62
|
+
const range = { from: up[at], to: up[at] + value };
|
|
63
|
+
up[at] += value;
|
|
64
|
+
return range;
|
|
65
|
+
}
|
|
66
|
+
const range = { from: down[at], to: down[at] + value };
|
|
67
|
+
down[at] += value;
|
|
68
|
+
return range;
|
|
69
|
+
}));
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=chart-math.js.map
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { LitElement, nothing, TemplateResult } from 'lit';
|
|
2
|
+
/** 「기타」 — what the largest slices leave over; also the rest bars beside a donut. */
|
|
3
|
+
export declare const REST_COLOR = "#bab0ac";
|
|
4
|
+
export declare const colorAt: (index: number) => string;
|
|
5
|
+
/** Builds the formatter for the numbers one chart draws — see the note above. */
|
|
6
|
+
export type ChartScale = (values: readonly number[]) => (value: number) => string;
|
|
7
|
+
/** Watches its own width so the SVG is drawn at pixel size — text keeps its size at any width. */
|
|
8
|
+
declare class SizedChart extends LitElement {
|
|
9
|
+
width: number;
|
|
10
|
+
private observer?;
|
|
11
|
+
connectedCallback(): void;
|
|
12
|
+
disconnectedCallback(): void;
|
|
13
|
+
}
|
|
14
|
+
export interface ChartSeries {
|
|
15
|
+
name: string;
|
|
16
|
+
values: (number | null)[];
|
|
17
|
+
color?: string;
|
|
18
|
+
/** A bar (the default), or a line over the bars — a balance beside flows. */
|
|
19
|
+
type?: 'bar' | 'line';
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Columns over categories (months, years, departments) — grouped side by side, or stacked; a line
|
|
23
|
+
* series is drawn over them on the same axis. `pick` tells which category was clicked.
|
|
24
|
+
*/
|
|
25
|
+
export declare class OxColumnChart extends SizedChart {
|
|
26
|
+
static styles: import("lit").CSSResult;
|
|
27
|
+
labels: string[];
|
|
28
|
+
series: ChartSeries[];
|
|
29
|
+
stacked: boolean;
|
|
30
|
+
height: number;
|
|
31
|
+
format: (value: number) => string;
|
|
32
|
+
scale: ChartScale | null;
|
|
33
|
+
/** The whole value for a tooltip — `won` beside a money scale, so 「3.6억」 can be read as every won on hover. */
|
|
34
|
+
exact: ((value: number) => string) | null;
|
|
35
|
+
pickable: boolean;
|
|
36
|
+
render(): TemplateResult<1>;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* A ring of shares — parts of one whole, the largest few and 「기타」, with a legend giving each
|
|
40
|
+
* amount and share. `pick` tells which slice was clicked (not the 「기타」 one).
|
|
41
|
+
*/
|
|
42
|
+
export declare class OxDonutChart extends SizedChart {
|
|
43
|
+
static styles: import("lit").CSSResult[];
|
|
44
|
+
items: {
|
|
45
|
+
key?: string;
|
|
46
|
+
label: string;
|
|
47
|
+
value: number;
|
|
48
|
+
}[];
|
|
49
|
+
keep: number;
|
|
50
|
+
size: number;
|
|
51
|
+
/** The name of the slice that folds the rest - the caller's word for it, such as 「기타」. */
|
|
52
|
+
restLabel: string;
|
|
53
|
+
centerLabel: string;
|
|
54
|
+
format: (value: number) => string;
|
|
55
|
+
scale: ChartScale | null;
|
|
56
|
+
/** The whole value for a tooltip — `won` beside a money scale, so 「3.6억」 can be read as every won on hover. */
|
|
57
|
+
exact: ((value: number) => string) | null;
|
|
58
|
+
pickable: boolean;
|
|
59
|
+
render(): TemplateResult<1> | typeof nothing;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* A range over time — the band between a low and a high, the middle as a line: where the balance
|
|
63
|
+
* is likely to be. A dashed line marks zero when the band reaches it.
|
|
64
|
+
*/
|
|
65
|
+
export declare class OxBandChart extends SizedChart {
|
|
66
|
+
static styles: import("lit").CSSResult;
|
|
67
|
+
labels: string[];
|
|
68
|
+
low: number[];
|
|
69
|
+
mid: number[];
|
|
70
|
+
high: number[];
|
|
71
|
+
lowName: string;
|
|
72
|
+
midName: string;
|
|
73
|
+
highName: string;
|
|
74
|
+
height: number;
|
|
75
|
+
format: (value: number) => string;
|
|
76
|
+
scale: ChartScale | null;
|
|
77
|
+
/** The whole value for a tooltip — `won` beside a money scale, so 「3.6억」 can be read as every won on hover. */
|
|
78
|
+
exact: ((value: number) => string) | null;
|
|
79
|
+
render(): TemplateResult<1>;
|
|
80
|
+
}
|
|
81
|
+
/** One part of a whole on a single line - how many stand at a step, say - its colour given by the caller. */
|
|
82
|
+
export interface ShareItem {
|
|
83
|
+
label: string;
|
|
84
|
+
value: number;
|
|
85
|
+
color: string;
|
|
86
|
+
/** What the part holds, shown on hover - the names behind a count. */
|
|
87
|
+
detail?: string;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* A whole as one line of coloured parts, each as wide as its share, the legend under it naming each part with its value.
|
|
91
|
+
* Parts with nothing are left off the line and stay in the legend, so every step is still named.
|
|
92
|
+
*/
|
|
93
|
+
export declare class OxShareLine extends LitElement {
|
|
94
|
+
static styles: import("lit").CSSResult[];
|
|
95
|
+
items: ShareItem[];
|
|
96
|
+
format: (value: number) => string;
|
|
97
|
+
render(): TemplateResult<1>;
|
|
98
|
+
}
|
|
99
|
+
/** One row of a bar list. `rest` marks a row drawn in the rest colour - what is left over, not a part. */
|
|
100
|
+
export interface BarItem {
|
|
101
|
+
label: string;
|
|
102
|
+
value: number;
|
|
103
|
+
/** A word before the label - the kind of what the bar is. */
|
|
104
|
+
tag?: string;
|
|
105
|
+
rest?: boolean;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Horizontal bars, one a row, in the order given - the caller sorts them and puts a rest row where it belongs. Every bar
|
|
109
|
+
* is measured against the largest; the value is written at the row's end.
|
|
110
|
+
*/
|
|
111
|
+
export declare class OxBarList extends LitElement {
|
|
112
|
+
static styles: import("lit").CSSResult[];
|
|
113
|
+
items: BarItem[];
|
|
114
|
+
format: (value: number) => string;
|
|
115
|
+
color: string;
|
|
116
|
+
render(): TemplateResult<1>;
|
|
117
|
+
}
|
|
118
|
+
export {};
|