@funcd-dev/ui 0.6.0 → 0.7.0
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/index.es.js +1087 -985
- package/dist/index.umd.js +2 -2
- package/dist/reactive-chart/reactive-charts/reactive-bar-chart/reactive-bar-chart.util.d.ts +26 -0
- package/dist/reactive-chart/reactive-charts/reactive-bar-chart/types.d.ts +22 -0
- package/dist/reactive-chart/reactive-charts/reactive-pie-chart/types.d.ts +7 -0
- package/dist/reactive-chart/reactive-charts/types/reactive-chart-base.d.ts +9 -0
- package/dist/reactive-chart/reactive-charts/utils/chart-option.util.d.ts +22 -0
- package/package.json +1 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { JSONData } from '@/types';
|
|
2
|
+
import { IChartSeries } from '../types';
|
|
3
|
+
export interface IChartPivotSeries extends IChartSeries {
|
|
4
|
+
/** One [x value, sum] pair per category; the sum is null without a value */
|
|
5
|
+
data: [string | number, number | null][];
|
|
6
|
+
/** First row of each category, as it is in `data` */
|
|
7
|
+
rows: JSONData[];
|
|
8
|
+
}
|
|
9
|
+
interface IChartPivotParams {
|
|
10
|
+
/** The chart's rows, as they are in `data` */
|
|
11
|
+
rows: JSONData[];
|
|
12
|
+
/** The same rows, flattened */
|
|
13
|
+
flatRows: JSONData[];
|
|
14
|
+
xKey: string;
|
|
15
|
+
series: IChartSeries[];
|
|
16
|
+
splitBy?: string;
|
|
17
|
+
xValues?: (string | number)[];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Sums the rows' values per x value and series, for `splitBy` and `xValues`.
|
|
21
|
+
* Every series gets one pair per category, in the same order, so the
|
|
22
|
+
* category axis collects the categories in that order and a listed x value
|
|
23
|
+
* without a row keeps its slot.
|
|
24
|
+
*/
|
|
25
|
+
export declare const getChartPivot: (params: IChartPivotParams) => IChartPivotSeries[];
|
|
26
|
+
export {};
|
|
@@ -8,4 +8,26 @@ export type BarChartCustomProps<TRow extends JSONData = JSONData> = {
|
|
|
8
8
|
stacked?: boolean;
|
|
9
9
|
/** Draws the bars from left to right */
|
|
10
10
|
horizontal?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Row key whose values each draw one series, for rows in long form (one
|
|
13
|
+
* row per x value and split value). `series` then holds exactly one entry:
|
|
14
|
+
* its `key` holds the values and its `format` applies to every series;
|
|
15
|
+
* otherwise the chart shows an error card. The series follow the order in
|
|
16
|
+
* which their values first appear and take the theme's colors in that
|
|
17
|
+
* order, so `series[0].color` is ignored. Rows whose split value is empty
|
|
18
|
+
* (null, undefined or '') draw the series named after `series[0].name`,
|
|
19
|
+
* and rows with the same x value and split value add up to one bar. Rows
|
|
20
|
+
* without an x value are left out. With `stacked`, the series stack. The
|
|
21
|
+
* legend shows when there is more than one series. `onChartClick` gets the
|
|
22
|
+
* first row of `data` with the bar's x value and split value.
|
|
23
|
+
*/
|
|
24
|
+
splitBy?: NestedKeyOf<TRow>;
|
|
25
|
+
/**
|
|
26
|
+
* The x values of the axis, in order, drawn as categories even when they
|
|
27
|
+
* are dates. A listed value without a row keeps its slot and draws no bar,
|
|
28
|
+
* and a row whose x value isn't listed is left out. Values match by their
|
|
29
|
+
* text, so `1` matches `'1'`, and rows with the same x value add up to one
|
|
30
|
+
* bar.
|
|
31
|
+
*/
|
|
32
|
+
xValues?: (string | number)[];
|
|
11
33
|
};
|
|
@@ -9,4 +9,11 @@ export type PieChartCustomProps<TRow extends JSONData = JSONData> = {
|
|
|
9
9
|
donut?: boolean;
|
|
10
10
|
/** Theme palette per slice name, for slices that mean a status; by default the chart theme picks one */
|
|
11
11
|
colors?: Record<string, PyColorsType>;
|
|
12
|
+
/**
|
|
13
|
+
* Number format of the slice values in the tooltip and of the donut's
|
|
14
|
+
* total, in the browser's locale: `{ style: 'currency', currency: 'EUR' }`.
|
|
15
|
+
* A format that `Intl.NumberFormat` rejects shows an error card instead of
|
|
16
|
+
* the chart.
|
|
17
|
+
*/
|
|
18
|
+
format?: Intl.NumberFormatOptions;
|
|
12
19
|
};
|
|
@@ -16,6 +16,15 @@ export interface IChartSeries<TRow extends JSONData = JSONData> {
|
|
|
16
16
|
name: string;
|
|
17
17
|
/** Theme palette of the series; by default the chart theme picks one */
|
|
18
18
|
color?: PyColorsType;
|
|
19
|
+
/**
|
|
20
|
+
* Number format of the values in the tooltip and on the value axis, in the
|
|
21
|
+
* browser's locale: `{ style: 'currency', currency: 'EUR' }`, or
|
|
22
|
+
* `{ style: 'unit', unit: 'percent' }` for values from 0 to 100. The value
|
|
23
|
+
* axis takes the first series' format, in compact notation (€1.5K) unless
|
|
24
|
+
* the format sets its own `notation`. A format that `Intl.NumberFormat`
|
|
25
|
+
* rejects shows an error card instead of the chart.
|
|
26
|
+
*/
|
|
27
|
+
format?: Intl.NumberFormatOptions;
|
|
19
28
|
}
|
|
20
29
|
export type CommonChartProps<TChartProps extends JSONData> = {
|
|
21
30
|
hidden?: boolean;
|
|
@@ -7,3 +7,25 @@ export declare const getChartAxisType: (rows: JSONData[], key: string) => ChartA
|
|
|
7
7
|
* item by item, so an override can change one series and keep the others.
|
|
8
8
|
*/
|
|
9
9
|
export declare const mergeChartOptions: <TOption extends JSONData>(option: TOption, override?: JSONData) => TOption;
|
|
10
|
+
/**
|
|
11
|
+
* A chart value as a number, read the way ECharts reads data values: a
|
|
12
|
+
* numeric string such as a SQL decimal is a number, and an empty value is NaN
|
|
13
|
+
*/
|
|
14
|
+
export declare const getChartNumber: (value: unknown) => number;
|
|
15
|
+
/**
|
|
16
|
+
* Formats chart values with `format`, in the browser's locale. A value that
|
|
17
|
+
* isn't a number shows as a dash, as in ECharts' own tooltip.
|
|
18
|
+
*/
|
|
19
|
+
export declare const getValueFormatter: (format?: Intl.NumberFormatOptions) => (value: unknown) => string;
|
|
20
|
+
/**
|
|
21
|
+
* Value axis labels in a series' `format`, compact like the labels without
|
|
22
|
+
* a format (€1.5K) unless the format sets its own `notation`
|
|
23
|
+
*/
|
|
24
|
+
export declare const getValueAxisLabel: (format: Intl.NumberFormatOptions) => {
|
|
25
|
+
formatter: (value: unknown) => string;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Message of the error card for the first format that `Intl.NumberFormat`
|
|
29
|
+
* rejects, such as a currency code that isn't three letters
|
|
30
|
+
*/
|
|
31
|
+
export declare const getFormatError: (formats: (Intl.NumberFormatOptions | undefined)[]) => string | undefined;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@funcd-dev/ui",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"description": "React components for funcd: Mantine-based layouts, reactive forms, reactive charts and a flow editor",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.7.0",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|