@rokkit/chart 1.3.15 → 1.4.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/Plot.svelte +25 -9
- package/dist/PlotState.svelte.d.ts +1 -0
- package/dist/PlotState.svelte.js +8 -1
- package/dist/Spark.svelte +165 -0
- package/dist/Spark.svelte.d.ts +31 -0
- package/dist/SparkState.svelte.d.ts +138 -0
- package/dist/SparkState.svelte.js +331 -0
- package/dist/Sparkline.svelte +59 -232
- package/dist/Sparkline.svelte.d.ts +2 -0
- package/dist/charts/RadarChart.svelte +106 -0
- package/dist/charts/RadarChart.svelte.d.ts +43 -0
- package/dist/geoms/Area.svelte +17 -2
- package/dist/geoms/Area.svelte.d.ts +2 -0
- package/dist/geoms/Bar.svelte +2 -9
- package/dist/geoms/Highlight.svelte +2 -7
- package/dist/geoms/Line.svelte +2 -8
- package/dist/geoms/Point.svelte +2 -8
- package/dist/geoms/Radar.svelte +352 -0
- package/dist/geoms/Radar.svelte.d.ts +42 -0
- package/dist/geoms/lib/aesthetics.d.ts +14 -0
- package/dist/geoms/lib/aesthetics.js +21 -0
- package/dist/geoms/lib/areas.d.ts +9 -2
- package/dist/geoms/lib/areas.js +53 -8
- package/dist/geoms/lib/marks/area.d.ts +3 -0
- package/dist/geoms/lib/marks/area.js +11 -2
- package/dist/geoms/lib/marks/radar.d.ts +68 -0
- package/dist/geoms/lib/marks/radar.js +153 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +7 -1
- package/dist/lib/brewing/marks/boxes.js +19 -30
- package/dist/lib/brewing/polar.d.ts +433 -0
- package/dist/lib/brewing/polar.js +584 -0
- package/dist/lib/plot/scales.js +8 -5
- package/dist/lib/preset.d.ts +1 -0
- package/dist/lib/preset.js +2 -1
- package/dist/lib/select.d.ts +3 -3
- package/dist/lib/select.js +1 -1
- package/package.json +1 -1
- package/dist/examples/BarChartExample.svelte +0 -78
- package/dist/examples/BarChartExample.svelte.d.ts +0 -18
- package/dist/lib/brewing/types.d.ts +0 -162
- package/dist/lib/brewing/types.js +0 -73
- package/dist/lib/xscale.d.ts +0 -11
- package/dist/lib/xscale.js +0 -31
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { Plot } from '../index.js'
|
|
3
|
-
import { dataset } from '@rokkit/data'
|
|
4
|
-
|
|
5
|
-
type Row = Record<string, unknown>
|
|
6
|
-
|
|
7
|
-
// Sample data
|
|
8
|
-
const sampleData = [
|
|
9
|
-
{ model: 'Model A', name: 'Product 1', category: 'Electronics', count: 45 },
|
|
10
|
-
{ model: 'Model B', name: 'Product 2', category: 'Clothing', count: 32 },
|
|
11
|
-
{ model: 'Model C', name: 'Product 3', category: 'Electronics', count: 62 },
|
|
12
|
-
{ model: 'Model D', name: 'Product 4', category: 'Home', count: 28 },
|
|
13
|
-
{ model: 'Model E', name: 'Product 5', category: 'Electronics', count: 53 },
|
|
14
|
-
{ model: 'Model F', name: 'Product 6', category: 'Clothing', count: 24 },
|
|
15
|
-
{ model: 'Model G', name: 'Product 7', category: 'Home', count: 35 }
|
|
16
|
-
]
|
|
17
|
-
|
|
18
|
-
// Use the dataset class to process the data
|
|
19
|
-
const data: Row[] = dataset(sampleData)
|
|
20
|
-
.groupBy('category')
|
|
21
|
-
.summarize('name', { count: (values: unknown[]) => values.length })
|
|
22
|
-
.rollup()
|
|
23
|
-
.select()
|
|
24
|
-
|
|
25
|
-
// Chart dimensions
|
|
26
|
-
const width = 600
|
|
27
|
-
const height = 400
|
|
28
|
-
const margin = { top: 20, right: 100, bottom: 60, left: 60 }
|
|
29
|
-
</script>
|
|
30
|
-
|
|
31
|
-
<div class="example">
|
|
32
|
-
<h2>Bar Chart Example</h2>
|
|
33
|
-
|
|
34
|
-
<div class="chart-wrapper">
|
|
35
|
-
<Plot.Root {data} x="category" y="count" color="category" {width} {height} {margin}>
|
|
36
|
-
<Plot.Grid />
|
|
37
|
-
<Plot.Axis type="x" label="Product Category" />
|
|
38
|
-
<Plot.Axis type="y" label="Number of Products" />
|
|
39
|
-
<Plot.Bar x="category" y="count" fill="category" />
|
|
40
|
-
<Plot.Legend labels={{ category: 'Categories' }} />
|
|
41
|
-
</Plot.Root>
|
|
42
|
-
</div>
|
|
43
|
-
|
|
44
|
-
<div class="code-example">
|
|
45
|
-
<h3>Example Code:</h3>
|
|
46
|
-
<pre>
|
|
47
|
-
<!-- <script>
|
|
48
|
-
import { Plot } from '@rokkit/chart';
|
|
49
|
-
import { dataset } from '@rokkit/data';
|
|
50
|
-
|
|
51
|
-
// Sample data
|
|
52
|
-
const sampleData = [
|
|
53
|
-
{ model: 'Model A', name: 'Product 1', category: 'Electronics', count: 45 },
|
|
54
|
-
{ model: 'Model B', name: 'Product 2', category: 'Clothing', count: 32 },
|
|
55
|
-
{ model: 'Model C', name: 'Product 3', category: 'Electronics', count: 62 },
|
|
56
|
-
{ model: 'Model D', name: 'Product 4', category: 'Home', count: 28 },
|
|
57
|
-
{ model: 'Model E', name: 'Product 5', category: 'Electronics', count: 53 },
|
|
58
|
-
{ model: 'Model F', name: 'Product 6', category: 'Clothing', count: 24 },
|
|
59
|
-
{ model: 'Model G', name: 'Product 7', category: 'Home', count: 35 },
|
|
60
|
-
];
|
|
61
|
-
|
|
62
|
-
// Use the dataset class to process the data
|
|
63
|
-
const data = dataset(sampleData)
|
|
64
|
-
.groupBy('category')
|
|
65
|
-
.summarize('name', { count: values => values.length })
|
|
66
|
-
.rollup();
|
|
67
|
-
</script>
|
|
68
|
-
|
|
69
|
-
<Plot.Root {data} width={600} height={400} margin={{ top: 20, right: 100, bottom: 60, left: 60 }} fill="category">
|
|
70
|
-
<Plot.Grid direction="y" lineStyle="dashed" />
|
|
71
|
-
<Plot.Axis type="x" field="category" label="Product Category" />
|
|
72
|
-
<Plot.Axis type="y" field="count" label="Number of Products" />
|
|
73
|
-
<Plot.Bar x="category" y="count" fill="category" onClick={handleBarClick} />
|
|
74
|
-
<Plot.Legend title="Categories" />
|
|
75
|
-
</Plot.Root> -->
|
|
76
|
-
</pre>
|
|
77
|
-
</div>
|
|
78
|
-
</div>
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
2
|
-
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
|
-
$$bindings?: Bindings;
|
|
4
|
-
} & Exports;
|
|
5
|
-
(internal: unknown, props: {
|
|
6
|
-
$$events?: Events;
|
|
7
|
-
$$slots?: Slots;
|
|
8
|
-
}): Exports & {
|
|
9
|
-
$set?: any;
|
|
10
|
-
$on?: any;
|
|
11
|
-
};
|
|
12
|
-
z_$$bindings?: Bindings;
|
|
13
|
-
}
|
|
14
|
-
declare const BarChartExample: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
15
|
-
[evt: string]: CustomEvent<any>;
|
|
16
|
-
}, {}, {}, string>;
|
|
17
|
-
type BarChartExample = InstanceType<typeof BarChartExample>;
|
|
18
|
-
export default BarChartExample;
|
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
export type ChartMargin = {
|
|
2
|
-
/**
|
|
3
|
-
* - Top margin
|
|
4
|
-
*/
|
|
5
|
-
top: number;
|
|
6
|
-
/**
|
|
7
|
-
* - Right margin
|
|
8
|
-
*/
|
|
9
|
-
right: number;
|
|
10
|
-
/**
|
|
11
|
-
* - Bottom margin
|
|
12
|
-
*/
|
|
13
|
-
bottom: number;
|
|
14
|
-
/**
|
|
15
|
-
* - Left margin
|
|
16
|
-
*/
|
|
17
|
-
left: number;
|
|
18
|
-
};
|
|
19
|
-
export type ChartDimensions = {
|
|
20
|
-
/**
|
|
21
|
-
* - Total chart width
|
|
22
|
-
*/
|
|
23
|
-
width: number;
|
|
24
|
-
/**
|
|
25
|
-
* - Total chart height
|
|
26
|
-
*/
|
|
27
|
-
height: number;
|
|
28
|
-
/**
|
|
29
|
-
* - Chart margins
|
|
30
|
-
*/
|
|
31
|
-
margin: ChartMargin;
|
|
32
|
-
/**
|
|
33
|
-
* - Chart width without margins
|
|
34
|
-
*/
|
|
35
|
-
innerWidth: number;
|
|
36
|
-
/**
|
|
37
|
-
* - Chart height without margins
|
|
38
|
-
*/
|
|
39
|
-
innerHeight: number;
|
|
40
|
-
};
|
|
41
|
-
export type ChartScales = {
|
|
42
|
-
/**
|
|
43
|
-
* - X-axis scale function
|
|
44
|
-
*/
|
|
45
|
-
x: Function;
|
|
46
|
-
/**
|
|
47
|
-
* - Y-axis scale function
|
|
48
|
-
*/
|
|
49
|
-
y: Function;
|
|
50
|
-
/**
|
|
51
|
-
* - Color scale function
|
|
52
|
-
*/
|
|
53
|
-
color: Function;
|
|
54
|
-
};
|
|
55
|
-
export type ScaleFields = {
|
|
56
|
-
/**
|
|
57
|
-
* - X-axis field
|
|
58
|
-
*/
|
|
59
|
-
x: string;
|
|
60
|
-
/**
|
|
61
|
-
* - Y-axis field
|
|
62
|
-
*/
|
|
63
|
-
y: string;
|
|
64
|
-
/**
|
|
65
|
-
* - Color field
|
|
66
|
-
*/
|
|
67
|
-
color: string;
|
|
68
|
-
};
|
|
69
|
-
export type TickData = {
|
|
70
|
-
/**
|
|
71
|
-
* - Tick value
|
|
72
|
-
*/
|
|
73
|
-
value: any;
|
|
74
|
-
/**
|
|
75
|
-
* - Tick position in pixels
|
|
76
|
-
*/
|
|
77
|
-
position: number;
|
|
78
|
-
/**
|
|
79
|
-
* - Formatted tick label
|
|
80
|
-
*/
|
|
81
|
-
formattedValue: string;
|
|
82
|
-
};
|
|
83
|
-
export type AxisData = {
|
|
84
|
-
/**
|
|
85
|
-
* - Tick data
|
|
86
|
-
*/
|
|
87
|
-
ticks: TickData[];
|
|
88
|
-
/**
|
|
89
|
-
* - Axis label
|
|
90
|
-
*/
|
|
91
|
-
label: string;
|
|
92
|
-
/**
|
|
93
|
-
* - SVG transform attribute value
|
|
94
|
-
*/
|
|
95
|
-
transform: string;
|
|
96
|
-
/**
|
|
97
|
-
* - SVG transform for the label
|
|
98
|
-
*/
|
|
99
|
-
labelTransform: string;
|
|
100
|
-
};
|
|
101
|
-
export type BarData = {
|
|
102
|
-
/**
|
|
103
|
-
* - Original data point
|
|
104
|
-
*/
|
|
105
|
-
data: Object;
|
|
106
|
-
/**
|
|
107
|
-
* - X position
|
|
108
|
-
*/
|
|
109
|
-
x: number;
|
|
110
|
-
/**
|
|
111
|
-
* - Y position
|
|
112
|
-
*/
|
|
113
|
-
y: number;
|
|
114
|
-
/**
|
|
115
|
-
* - Width of the bar
|
|
116
|
-
*/
|
|
117
|
-
width: number;
|
|
118
|
-
/**
|
|
119
|
-
* - Height of the bar
|
|
120
|
-
*/
|
|
121
|
-
height: number;
|
|
122
|
-
/**
|
|
123
|
-
* - Color of the bar
|
|
124
|
-
*/
|
|
125
|
-
color: string;
|
|
126
|
-
};
|
|
127
|
-
export type LegendItem = {
|
|
128
|
-
/**
|
|
129
|
-
* - Legend item value
|
|
130
|
-
*/
|
|
131
|
-
value: any;
|
|
132
|
-
/**
|
|
133
|
-
* - Item color
|
|
134
|
-
*/
|
|
135
|
-
color: string;
|
|
136
|
-
/**
|
|
137
|
-
* - Y position
|
|
138
|
-
*/
|
|
139
|
-
y: number;
|
|
140
|
-
/**
|
|
141
|
-
* - Shape type ('rect' or 'circle')
|
|
142
|
-
*/
|
|
143
|
-
shape: string;
|
|
144
|
-
/**
|
|
145
|
-
* - Size of the marker
|
|
146
|
-
*/
|
|
147
|
-
markerSize: number;
|
|
148
|
-
};
|
|
149
|
-
export type LegendData = {
|
|
150
|
-
/**
|
|
151
|
-
* - Legend items
|
|
152
|
-
*/
|
|
153
|
-
items: LegendItem[];
|
|
154
|
-
/**
|
|
155
|
-
* - Legend title
|
|
156
|
-
*/
|
|
157
|
-
title: string;
|
|
158
|
-
/**
|
|
159
|
-
* - SVG transform attribute value
|
|
160
|
-
*/
|
|
161
|
-
transform: string;
|
|
162
|
-
};
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @typedef {Object} ChartMargin
|
|
3
|
-
* @property {number} top - Top margin
|
|
4
|
-
* @property {number} right - Right margin
|
|
5
|
-
* @property {number} bottom - Bottom margin
|
|
6
|
-
* @property {number} left - Left margin
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* @typedef {Object} ChartDimensions
|
|
11
|
-
* @property {number} width - Total chart width
|
|
12
|
-
* @property {number} height - Total chart height
|
|
13
|
-
* @property {ChartMargin} margin - Chart margins
|
|
14
|
-
* @property {number} innerWidth - Chart width without margins
|
|
15
|
-
* @property {number} innerHeight - Chart height without margins
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @typedef {Object} ChartScales
|
|
20
|
-
* @property {Function} x - X-axis scale function
|
|
21
|
-
* @property {Function} y - Y-axis scale function
|
|
22
|
-
* @property {Function} color - Color scale function
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* @typedef {Object} ScaleFields
|
|
27
|
-
* @property {string} x - X-axis field
|
|
28
|
-
* @property {string} y - Y-axis field
|
|
29
|
-
* @property {string} color - Color field
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* @typedef {Object} TickData
|
|
34
|
-
* @property {*} value - Tick value
|
|
35
|
-
* @property {number} position - Tick position in pixels
|
|
36
|
-
* @property {string} formattedValue - Formatted tick label
|
|
37
|
-
*/
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* @typedef {Object} AxisData
|
|
41
|
-
* @property {TickData[]} ticks - Tick data
|
|
42
|
-
* @property {string} label - Axis label
|
|
43
|
-
* @property {string} transform - SVG transform attribute value
|
|
44
|
-
* @property {string} labelTransform - SVG transform for the label
|
|
45
|
-
*/
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* @typedef {Object} BarData
|
|
49
|
-
* @property {Object} data - Original data point
|
|
50
|
-
* @property {number} x - X position
|
|
51
|
-
* @property {number} y - Y position
|
|
52
|
-
* @property {number} width - Width of the bar
|
|
53
|
-
* @property {number} height - Height of the bar
|
|
54
|
-
* @property {string} color - Color of the bar
|
|
55
|
-
*/
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* @typedef {Object} LegendItem
|
|
59
|
-
* @property {*} value - Legend item value
|
|
60
|
-
* @property {string} color - Item color
|
|
61
|
-
* @property {number} y - Y position
|
|
62
|
-
* @property {string} shape - Shape type ('rect' or 'circle')
|
|
63
|
-
* @property {number} markerSize - Size of the marker
|
|
64
|
-
*/
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* @typedef {Object} LegendData
|
|
68
|
-
* @property {LegendItem[]} items - Legend items
|
|
69
|
-
* @property {string} title - Legend title
|
|
70
|
-
* @property {string} transform - SVG transform attribute value
|
|
71
|
-
*/
|
|
72
|
-
|
|
73
|
-
export {}
|
package/dist/lib/xscale.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Builds an appropriate D3 x-axis scale based on value types.
|
|
3
|
-
* Returns scaleTime for Date values, scaleLinear for numeric values,
|
|
4
|
-
* or scaleBand for categorical values.
|
|
5
|
-
*
|
|
6
|
-
* @param {Array} xValues
|
|
7
|
-
* @param {Object} dimensions
|
|
8
|
-
* @param {number} padding
|
|
9
|
-
* @returns {import('d3-scale').ScaleContinuousNumeric|import('d3-scale').ScaleBand}
|
|
10
|
-
*/
|
|
11
|
-
export function buildXScale(xValues: any[], dimensions: Object, padding: number): import("d3-scale").ScaleContinuousNumeric<any, any, never> | import("d3-scale").ScaleBand<any>;
|
package/dist/lib/xscale.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { scaleBand, scaleLinear, scaleTime } from 'd3-scale'
|
|
2
|
-
import { min, max } from 'd3-array'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Builds an appropriate D3 x-axis scale based on value types.
|
|
6
|
-
* Returns scaleTime for Date values, scaleLinear for numeric values,
|
|
7
|
-
* or scaleBand for categorical values.
|
|
8
|
-
*
|
|
9
|
-
* @param {Array} xValues
|
|
10
|
-
* @param {Object} dimensions
|
|
11
|
-
* @param {number} padding
|
|
12
|
-
* @returns {import('d3-scale').ScaleContinuousNumeric|import('d3-scale').ScaleBand}
|
|
13
|
-
*/
|
|
14
|
-
export function buildXScale(xValues, dimensions, padding) {
|
|
15
|
-
const xIsDate = xValues.some((v) => v instanceof Date)
|
|
16
|
-
const xIsNumeric = !xIsDate && xValues.every((v) => !isNaN(parseFloat(v)))
|
|
17
|
-
|
|
18
|
-
if (xIsDate) {
|
|
19
|
-
return scaleTime()
|
|
20
|
-
.domain([min(xValues), max(xValues)])
|
|
21
|
-
.range([0, dimensions.innerWidth])
|
|
22
|
-
.nice()
|
|
23
|
-
}
|
|
24
|
-
if (xIsNumeric) {
|
|
25
|
-
return scaleLinear()
|
|
26
|
-
.domain([min([0, ...xValues]), max(xValues)])
|
|
27
|
-
.range([0, dimensions.innerWidth])
|
|
28
|
-
.nice()
|
|
29
|
-
}
|
|
30
|
-
return scaleBand().domain(xValues).range([0, dimensions.innerWidth]).padding(padding)
|
|
31
|
-
}
|