@bridge-ui/vue 0.17.3 → 0.19.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/ai/skills/bridge-ui-components/SKILL.md +36 -35
- package/ai/skills/bridge-ui-setup/SKILL.md +1 -1
- package/dist/Components/CalendarMonth/composables/useCalendarMonth.d.ts +1 -1
- package/dist/Components/ChartAxis/ChartAxis.vue_vue_type_script_setup_true_lang.js +1 -0
- package/dist/Components/ChartAxis/chartAxis.types.d.ts +17 -7
- package/dist/Components/ChartAxis/composables/useChartAxis.d.ts +2 -2
- package/dist/Components/ChartAxis/composables/useChartAxis.js +15 -10
- package/dist/Components/ChartBar/ChartBar.js +5 -0
- package/dist/Components/ChartBar/ChartBar.vue.d.ts +16 -0
- package/dist/Components/ChartBar/ChartBar.vue_vue_type_script_setup_true_lang.js +64 -0
- package/dist/Components/ChartBar/chartBar.types.d.ts +66 -0
- package/dist/Components/ChartBar/composables/useChartBar.d.ts +26 -0
- package/dist/Components/ChartBar/composables/useChartBar.js +13 -0
- package/dist/Components/ChartBar/index.d.ts +4 -0
- package/dist/Components/ChartBar/index.js +4 -0
- package/dist/Components/ChartBarSeries/ChartBarSeries.js +5 -0
- package/dist/Components/ChartBarSeries/ChartBarSeries.vue.d.ts +6 -0
- package/dist/Components/ChartBarSeries/ChartBarSeries.vue_vue_type_script_setup_true_lang.js +28 -0
- package/dist/Components/ChartBarSeries/chartBarSeries.types.d.ts +67 -0
- package/dist/Components/ChartBarSeries/composables/useChartBarSeries.d.ts +5 -0
- package/dist/Components/ChartBarSeries/composables/useChartBarSeries.js +23 -0
- package/dist/Components/ChartBarSeries/index.d.ts +4 -0
- package/dist/Components/ChartBarSeries/index.js +3 -0
- package/dist/Components/ChartFunnel/ChartFunnel.js +5 -0
- package/dist/Components/ChartFunnel/ChartFunnel.vue.d.ts +16 -0
- package/dist/Components/ChartFunnel/ChartFunnel.vue_vue_type_script_setup_true_lang.js +59 -0
- package/dist/Components/ChartFunnel/chartFunnel.types.d.ts +54 -0
- package/dist/Components/ChartFunnel/composables/useChartFunnel.d.ts +29 -0
- package/dist/Components/ChartFunnel/composables/useChartFunnel.js +68 -0
- package/dist/Components/ChartFunnel/index.d.ts +4 -0
- package/dist/Components/ChartFunnel/index.js +4 -0
- package/dist/Components/ChartLegend/ChartLegend.vue.d.ts +2 -0
- package/dist/Components/ChartLegend/ChartLegend.vue_vue_type_script_setup_true_lang.js +33 -13
- package/dist/Components/ChartLegend/chartLegend.types.d.ts +41 -5
- package/dist/Components/ChartLegend/composables/useChartLegend.d.ts +9 -5
- package/dist/Components/ChartLegend/composables/useChartLegend.js +88 -54
- package/dist/Components/ChartLine/ChartLine.js +5 -0
- package/dist/Components/ChartLine/ChartLine.vue.d.ts +20 -0
- package/dist/Components/ChartLine/ChartLine.vue_vue_type_script_setup_true_lang.js +77 -0
- package/dist/Components/ChartLine/chartLine.types.d.ts +79 -0
- package/dist/Components/ChartLine/composables/useChartLine.d.ts +26 -0
- package/dist/Components/ChartLine/composables/useChartLine.js +13 -0
- package/dist/Components/ChartLine/index.d.ts +4 -0
- package/dist/Components/ChartLine/index.js +4 -0
- package/dist/Components/ChartLineSeries/ChartLineSeries.js +5 -0
- package/dist/Components/ChartLineSeries/ChartLineSeries.vue.d.ts +10 -0
- package/dist/Components/ChartLineSeries/ChartLineSeries.vue_vue_type_script_setup_true_lang.js +45 -0
- package/dist/Components/ChartLineSeries/chartLineSeries.types.d.ts +96 -0
- package/dist/Components/ChartLineSeries/composables/useChartLineSeries.d.ts +5 -0
- package/dist/Components/ChartLineSeries/composables/useChartLineSeries.js +28 -0
- package/dist/Components/ChartLineSeries/index.d.ts +4 -0
- package/dist/Components/ChartLineSeries/index.js +3 -0
- package/dist/Components/ChartPie/ChartPie.js +5 -0
- package/dist/Components/ChartPie/ChartPie.vue.d.ts +15 -0
- package/dist/Components/ChartPie/ChartPie.vue_vue_type_script_setup_true_lang.js +76 -0
- package/dist/Components/ChartPie/chartPie.types.d.ts +92 -0
- package/dist/Components/ChartPie/composables/useChartPie.d.ts +30 -0
- package/dist/Components/ChartPie/composables/useChartPie.js +81 -0
- package/dist/Components/ChartPie/index.d.ts +4 -0
- package/dist/Components/ChartPie/index.js +4 -0
- package/dist/Components/ChartScatter/ChartScatter.js +5 -0
- package/dist/Components/{Chart/Chart.vue.d.ts → ChartScatter/ChartScatter.vue.d.ts} +3 -2
- package/dist/Components/ChartScatter/ChartScatter.vue_vue_type_script_setup_true_lang.js +49 -0
- package/dist/Components/ChartScatter/chartScatter.types.d.ts +23 -0
- package/dist/Components/ChartScatter/composables/useChartScatter.d.ts +29 -0
- package/dist/Components/ChartScatter/composables/useChartScatter.js +108 -0
- package/dist/Components/ChartScatter/index.d.ts +4 -0
- package/dist/Components/ChartScatter/index.js +4 -0
- package/dist/Components/ChartScatterSeries/ChartScatterSeries.js +5 -0
- package/dist/Components/ChartScatterSeries/ChartScatterSeries.vue.d.ts +4 -0
- package/dist/Components/ChartScatterSeries/ChartScatterSeries.vue_vue_type_script_setup_true_lang.js +22 -0
- package/dist/Components/ChartScatterSeries/chartScatterSeries.types.d.ts +45 -0
- package/dist/Components/ChartScatterSeries/composables/useChartScatterSeries.d.ts +4 -0
- package/dist/Components/ChartScatterSeries/composables/useChartScatterSeries.js +19 -0
- package/dist/Components/ChartScatterSeries/index.d.ts +4 -0
- package/dist/Components/ChartScatterSeries/index.js +3 -0
- package/dist/Components/ChartTooltip/ChartTooltip.vue_vue_type_script_setup_true_lang.js +22 -10
- package/dist/Components/ChartTooltip/chartTooltip.types.d.ts +28 -9
- package/dist/Components/ChartTooltip/composables/useChartTooltip.d.ts +4 -1
- package/dist/Components/ChartTooltip/composables/useChartTooltip.js +81 -63
- package/dist/Components/Heading/Heading.js +5 -0
- package/dist/Components/Heading/Heading.vue.d.ts +11 -0
- package/dist/Components/Heading/Heading.vue_vue_type_script_setup_true_lang.js +29 -0
- package/dist/Components/Heading/composables/useHeading.d.ts +10 -0
- package/dist/Components/Heading/composables/useHeading.js +56 -0
- package/dist/Components/Heading/heading.types.d.ts +56 -0
- package/dist/Components/Heading/index.d.ts +3 -0
- package/dist/Components/Heading/index.js +3 -0
- package/dist/Components/ResizablePanel/composables/useResizablePanel.d.ts +1 -1
- package/dist/Components/Spinner/composables/useSpinner.d.ts +1 -1
- package/dist/Components/Text/Text.js +5 -0
- package/dist/Components/Text/Text.vue.d.ts +11 -0
- package/dist/Components/Text/Text.vue_vue_type_script_setup_true_lang.js +33 -0
- package/dist/Components/Text/composables/useText.d.ts +9 -0
- package/dist/Components/Text/composables/useText.js +56 -0
- package/dist/Components/Text/index.d.ts +3 -0
- package/dist/Components/Text/index.js +3 -0
- package/dist/Components/Text/text.types.d.ts +76 -0
- package/dist/Utils/Charts/ChartFrame.js +5 -0
- package/dist/Utils/Charts/ChartFrame.vue.d.ts +24 -0
- package/dist/Utils/Charts/ChartFrame.vue_vue_type_script_setup_true_lang.js +41 -0
- package/dist/{Components/Chart → Utils/Charts}/chart.types.d.ts +33 -18
- package/dist/Utils/Charts/chartInjectionKey.d.ts +151 -0
- package/dist/{Components/Chart → Utils/Charts}/chartInjectionKey.js +2 -2
- package/dist/Utils/Charts/echarts/bar.d.ts +6 -0
- package/dist/Utils/Charts/echarts/bar.js +23 -0
- package/dist/Utils/Charts/echarts/cartesian.d.ts +15 -0
- package/dist/Utils/Charts/echarts/cartesian.js +290 -0
- package/dist/Utils/Charts/echarts/funnel.d.ts +15 -0
- package/dist/Utils/Charts/echarts/funnel.js +79 -0
- package/dist/Utils/Charts/echarts/line.d.ts +5 -0
- package/dist/Utils/Charts/echarts/line.js +20 -0
- package/dist/Utils/Charts/echarts/part.d.ts +19 -0
- package/dist/Utils/Charts/echarts/part.js +45 -0
- package/dist/Utils/Charts/echarts/pie.d.ts +14 -0
- package/dist/Utils/Charts/echarts/pie.js +76 -0
- package/dist/Utils/Charts/echarts/plot.d.ts +44 -0
- package/dist/Utils/Charts/echarts/plot.js +52 -0
- package/dist/Utils/Charts/echarts/scatter.d.ts +14 -0
- package/dist/Utils/Charts/echarts/scatter.js +161 -0
- package/dist/Utils/Charts/index.d.ts +6 -0
- package/dist/Utils/Charts/index.js +6 -0
- package/dist/Utils/Charts/useChartCartesian.d.ts +59 -0
- package/dist/Utils/Charts/useChartCartesian.js +169 -0
- package/dist/Utils/Charts/useChartPart.d.ts +45 -0
- package/dist/Utils/Charts/useChartPart.js +97 -0
- package/dist/Utils/Charts/useChartRegistry.d.ts +13 -0
- package/dist/Utils/Charts/useChartRegistry.js +40 -0
- package/dist/Utils/Charts/useChartRoot.d.ts +156 -0
- package/dist/Utils/Charts/useChartRoot.js +342 -0
- package/dist/Utils/Charts/useChartSeries.d.ts +10 -0
- package/dist/Utils/Charts/useChartSeries.js +22 -0
- package/dist/augments.d.ts +33 -7
- package/dist/index.d.ts +4 -0
- package/dist/index.js +90 -86
- package/docs/README.md +8 -1
- package/docs/components/BridgeUIProvider.md +1 -1
- package/docs/components/Card.md +15 -0
- package/docs/components/Chart.md +118 -151
- package/docs/components/ChartBar.md +190 -0
- package/docs/components/ChartFunnel.md +62 -0
- package/docs/components/ChartLine.md +192 -0
- package/docs/components/ChartPie.md +138 -0
- package/docs/components/ChartScatter.md +102 -0
- package/docs/components/Heading.md +85 -0
- package/docs/components/Text.md +118 -0
- package/package.json +2 -2
- package/dist/Components/Chart/Chart.js +0 -5
- package/dist/Components/Chart/Chart.vue_vue_type_script_setup_true_lang.js +0 -52
- package/dist/Components/Chart/chartInjectionKey.d.ts +0 -94
- package/dist/Components/Chart/composables/useChart.d.ts +0 -40
- package/dist/Components/Chart/composables/useChart.js +0 -346
- package/dist/Components/Chart/echartsChart.d.ts +0 -14
- package/dist/Components/Chart/echartsChart.js +0 -199
- package/dist/Components/Chart/index.d.ts +0 -4
- package/dist/Components/Chart/index.js +0 -4
- package/dist/Components/ChartSeries/ChartSeries.js +0 -5
- package/dist/Components/ChartSeries/ChartSeries.vue.d.ts +0 -4
- package/dist/Components/ChartSeries/ChartSeries.vue_vue_type_script_setup_true_lang.js +0 -24
- package/dist/Components/ChartSeries/chartSeries.types.d.ts +0 -37
- package/dist/Components/ChartSeries/composables/useChartSeries.d.ts +0 -10
- package/dist/Components/ChartSeries/composables/useChartSeries.js +0 -29
- package/dist/Components/ChartSeries/index.d.ts +0 -3
- package/dist/Components/ChartSeries/index.js +0 -3
package/docs/components/Chart.md
CHANGED
|
@@ -1,174 +1,156 @@
|
|
|
1
1
|
# Chart
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Charts for dashboards and reports. Pick the root for the shape of your data; every root shares the same legend, tooltip, tokens, dark mode, and a11y (summary, keyboard navigation, data table). The plot engine is ECharts.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
| Root | Use for | Data |
|
|
6
|
+
| ----------------------------------- | -------------------------------------------------------------- | ----------------------------------------- |
|
|
7
|
+
| [`ChartLine`](./ChartLine.md) | Trends, areas, stacked areas, steps, sparklines | `ChartLineSeries`, one value per category |
|
|
8
|
+
| [`ChartBar`](./ChartBar.md) | Comparisons, rankings (horizontal), stacked totals, bar + line | `ChartBarSeries` (+ `ChartLineSeries`) |
|
|
9
|
+
| [`ChartScatter`](./ChartScatter.md) | Correlation between two numbers, bubbles | `ChartScatterSeries`, `[x, y]` points |
|
|
10
|
+
| [`ChartPie`](./ChartPie.md) | Share of a whole (pie, donut) | `data` on the root |
|
|
11
|
+
| [`ChartFunnel`](./ChartFunnel.md) | Conversion through ordered stages | `data` on the root |
|
|
12
|
+
|
|
13
|
+
Shared parts:
|
|
14
|
+
|
|
15
|
+
| Part | Line | Bar | Scatter | Pie | Funnel |
|
|
16
|
+
| -------------- | ---- | --- | ------- | --- | ------ |
|
|
17
|
+
| `ChartLegend` | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
18
|
+
| `ChartTooltip` | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
19
|
+
| `ChartAxis` | ✅ | ✅ | ✅ | — | — |
|
|
6
20
|
|
|
7
21
|
## Import
|
|
8
22
|
|
|
9
23
|
```ts
|
|
10
|
-
import { Chart } from "@bridge-ui/vue/Components/Chart";
|
|
11
24
|
import { ChartAxis } from "@bridge-ui/vue/Components/ChartAxis";
|
|
12
25
|
import { ChartLegend } from "@bridge-ui/vue/Components/ChartLegend";
|
|
13
|
-
import { ChartSeries } from "@bridge-ui/vue/Components/ChartSeries";
|
|
14
26
|
import { ChartTooltip } from "@bridge-ui/vue/Components/ChartTooltip";
|
|
15
27
|
```
|
|
16
28
|
|
|
17
|
-
Install `echarts` next to `@bridge-ui/vue` when you use
|
|
29
|
+
Install `echarts` next to `@bridge-ui/vue` when you use a chart. Each root imports only its own series (line, bar, scatter, pie, or funnel) and the SVG renderer. Charts stay off the `@bridge-ui/vue` root so apps that never chart do not load `echarts`.
|
|
18
30
|
|
|
19
31
|
## Examples
|
|
20
32
|
|
|
21
|
-
###
|
|
33
|
+
### Axes
|
|
34
|
+
|
|
35
|
+
`position="x"` is the horizontal axis and `position="y"` the vertical one. On a horizontal `ChartBar` the categories sit on `y` and the values on `x`.
|
|
22
36
|
|
|
23
37
|
```vue
|
|
24
|
-
<
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
</Chart>
|
|
34
|
-
</template>
|
|
38
|
+
<ChartLine :categories="months">
|
|
39
|
+
<ChartLineSeries name="Revenue" :data="revenue" />
|
|
40
|
+
<ChartAxis
|
|
41
|
+
position="x"
|
|
42
|
+
label="Month"
|
|
43
|
+
:format-category="(month) => month.toUpperCase()"
|
|
44
|
+
/>
|
|
45
|
+
<ChartAxis :min="0" position="y" :format-tick="(value) => `$${value}`" />
|
|
46
|
+
</ChartLine>
|
|
35
47
|
```
|
|
36
48
|
|
|
37
|
-
|
|
49
|
+
`format-category` formats category labels (`string`). `format-tick` formats numbers: the value on a value axis, or the timestamp (ms) on a time axis. Grid lines are on for the value axis and off for the category axis by default.
|
|
38
50
|
|
|
39
|
-
|
|
40
|
-
<Chart :height="320" :categories="months">
|
|
41
|
-
<ChartSeries type="bar" name="Online" :data="online" />
|
|
42
|
-
<ChartSeries type="bar" name="Retail" :data="retail" />
|
|
43
|
-
<ChartLegend align="start" position="top" />
|
|
44
|
-
<ChartTooltip />
|
|
45
|
-
</Chart>
|
|
46
|
-
```
|
|
51
|
+
### Legend
|
|
47
52
|
|
|
48
|
-
|
|
53
|
+
Legend entries are toggle buttons: click to hide or show a series or slice, hover or focus to emphasize it.
|
|
49
54
|
|
|
50
55
|
```vue
|
|
51
|
-
<
|
|
52
|
-
|
|
53
|
-
<ChartTooltip />
|
|
54
|
-
</Chart>
|
|
56
|
+
<ChartLegend :interactive="false" />
|
|
57
|
+
<ChartLegend align="end" position="top" />
|
|
55
58
|
```
|
|
56
59
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
Bars and lines share the value axis.
|
|
60
|
+
`left` and `right` stack the entries beside the plot. With slices (pie, funnel), `show-value` and `show-percent` add value and share columns.
|
|
60
61
|
|
|
61
62
|
```vue
|
|
62
|
-
<
|
|
63
|
-
<
|
|
64
|
-
|
|
65
|
-
<ChartLegend />
|
|
66
|
-
<ChartTooltip />
|
|
67
|
-
</Chart>
|
|
63
|
+
<ChartPie :data="tags" variant="donut">
|
|
64
|
+
<ChartLegend show-percent position="right" />
|
|
65
|
+
</ChartPie>
|
|
68
66
|
```
|
|
69
67
|
|
|
70
|
-
###
|
|
71
|
-
|
|
72
|
-
`null` values leave a gap in lines and areas and are skipped in the tooltip.
|
|
68
|
+
### Tooltip
|
|
73
69
|
|
|
74
70
|
```vue
|
|
75
|
-
<
|
|
71
|
+
<ChartTooltip :format-value="(value) => currency.format(value)" />
|
|
76
72
|
```
|
|
77
73
|
|
|
78
|
-
### Axes
|
|
79
|
-
|
|
80
74
|
```vue
|
|
81
|
-
<
|
|
82
|
-
<
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
</
|
|
75
|
+
<ChartTooltip>
|
|
76
|
+
<template #content="{ title, items }">
|
|
77
|
+
<span>{{ title }}: {{ items.length }} series</span>
|
|
78
|
+
</template>
|
|
79
|
+
</ChartTooltip>
|
|
86
80
|
```
|
|
87
81
|
|
|
88
|
-
|
|
82
|
+
The tooltip title is the category (line, bar) or the series name (scatter). Slices show one row with the value and the share; format the share with `format-percent`.
|
|
89
83
|
|
|
90
84
|
### Colors
|
|
91
85
|
|
|
92
|
-
Series take palette colors in order. Override the palette on
|
|
86
|
+
Series and slices take palette colors in order. Override the palette on the root, or pass a token key or any CSS color.
|
|
93
87
|
|
|
94
88
|
```vue
|
|
95
|
-
<
|
|
96
|
-
<
|
|
97
|
-
<
|
|
98
|
-
</
|
|
89
|
+
<ChartLine :categories="months" :palette="['info', 'warning']">
|
|
90
|
+
<ChartLineSeries name="Plan" :data="plan" />
|
|
91
|
+
<ChartLineSeries name="Actual" :data="actual" color="#8b5cf6" />
|
|
92
|
+
</ChartLine>
|
|
99
93
|
```
|
|
100
94
|
|
|
101
95
|
Token keys (`primary`, `info`, `success`, `warning`, `error`, `secondary`, `dark`, `black`) follow light and dark mode automatically.
|
|
102
96
|
|
|
103
|
-
|
|
97
|
+
Colors can also follow the data:
|
|
104
98
|
|
|
105
|
-
|
|
99
|
+
- `color-ranges` on `ChartLineSeries`, `ChartBarSeries`, and `ChartScatterSeries` recolors points, bars, or stretches of a line by value ([ChartLine](./ChartLine.md#color-by-value), [ChartBar](./ChartBar.md#color-by-value), [ChartScatter](./ChartScatter.md#color-by-range)).
|
|
100
|
+
- `category-colors` on `ChartBar` gives each category its own color, and `tone="muted"` lightens a series ([ChartBar](./ChartBar.md#category-colors)).
|
|
106
101
|
|
|
107
|
-
|
|
108
|
-
<ChartLegend :interactive="false" />
|
|
109
|
-
<ChartLegend align="end" position="top" />
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
### Tooltip
|
|
113
|
-
|
|
114
|
-
```vue
|
|
115
|
-
<ChartTooltip :format-value="(value) => currency.format(value)" />
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
```vue
|
|
119
|
-
<ChartTooltip>
|
|
120
|
-
<template #content="{ category, items }">
|
|
121
|
-
<span>{{ category }}: {{ items.length }} series</span>
|
|
122
|
-
</template>
|
|
123
|
-
</ChartTooltip>
|
|
124
|
-
```
|
|
102
|
+
Color is never the only cue: range labels show in the tooltip, the data table, and the keyboard announcements.
|
|
125
103
|
|
|
126
104
|
### Loading and empty
|
|
127
105
|
|
|
128
106
|
While `loading` is true, the plot stays visible behind a translucent overlay with a spinner, and the root gets `aria-busy`. Use the `loading` slot to replace the spinner.
|
|
129
107
|
|
|
130
108
|
```vue
|
|
131
|
-
<
|
|
132
|
-
<
|
|
133
|
-
</
|
|
109
|
+
<ChartBar :loading="isLoading" :categories="months">
|
|
110
|
+
<ChartBarSeries name="Orders" :data="orders" />
|
|
111
|
+
</ChartBar>
|
|
134
112
|
```
|
|
135
113
|
|
|
136
114
|
```vue
|
|
137
|
-
<
|
|
138
|
-
<template #empty>No
|
|
139
|
-
</
|
|
115
|
+
<ChartPie :data="[]">
|
|
116
|
+
<template #empty>No outflows this month</template>
|
|
117
|
+
</ChartPie>
|
|
140
118
|
```
|
|
141
119
|
|
|
142
120
|
### Summary
|
|
143
121
|
|
|
144
|
-
|
|
122
|
+
Each root generates a text summary for screen readers. Pass `summary` to describe the takeaway instead.
|
|
145
123
|
|
|
146
124
|
```vue
|
|
147
|
-
<
|
|
148
|
-
<
|
|
149
|
-
</
|
|
125
|
+
<ChartLine :categories="months" summary="Revenue doubled from January to June.">
|
|
126
|
+
<ChartLineSeries name="Revenue" :data="revenue" />
|
|
127
|
+
</ChartLine>
|
|
150
128
|
```
|
|
151
129
|
|
|
152
130
|
### Registry defaults
|
|
153
131
|
|
|
132
|
+
Each root has its own registry entry (`ChartLine`, `ChartBar`, `ChartScatter`, `ChartPie`, `ChartFunnel`).
|
|
133
|
+
|
|
154
134
|
```vue
|
|
155
135
|
<BridgeUIProvider
|
|
156
136
|
:components="{
|
|
157
|
-
ChartSeries: { defaultProps: { curve: 'smooth' } },
|
|
158
137
|
ChartLegend: { defaultProps: { position: 'top' } },
|
|
159
|
-
|
|
138
|
+
ChartLine: { defaultProps: { curve: 'smooth', height: 320 } },
|
|
139
|
+
ChartBar: { defaultProps: { palette: ['primary', 'success'] } },
|
|
160
140
|
}"
|
|
161
141
|
>
|
|
162
142
|
<App />
|
|
163
143
|
</BridgeUIProvider>
|
|
164
144
|
```
|
|
165
145
|
|
|
166
|
-
Theme tokens (`
|
|
146
|
+
Theme tokens (`tokens.theme`) set the grid, axis, and label colors as Tailwind text-color classes:
|
|
167
147
|
|
|
168
148
|
```vue
|
|
169
149
|
<BridgeUIProvider
|
|
170
150
|
:components="{
|
|
171
|
-
|
|
151
|
+
ChartLine: {
|
|
152
|
+
tokens: { theme: { grid: 'text-dark-100 dark:text-dark-800' } },
|
|
153
|
+
},
|
|
172
154
|
}"
|
|
173
155
|
>
|
|
174
156
|
<App />
|
|
@@ -178,77 +160,62 @@ Theme tokens (`Chart.tokens.theme`) set the grid, axis, and label colors as Tail
|
|
|
178
160
|
## Accessibility
|
|
179
161
|
|
|
180
162
|
- The root is a `figure`; the plot is a focusable `img` labelled by `summary` (or the generated summary).
|
|
181
|
-
- Arrow keys move between categories, `Home` / `End` jump to the edges, `Escape` clears. The tooltip follows the keyboard, and the values are announced through a live region.
|
|
163
|
+
- Arrow keys move between items (categories, points, slices, or stages), `Home` / `End` jump to the edges, `Escape` clears. The tooltip follows the keyboard, and the values are announced through a live region.
|
|
182
164
|
- A data table with every value is always rendered, visually hidden.
|
|
183
165
|
- The tooltip is decorative (`aria-hidden`); the same information is in the table and announcements.
|
|
184
166
|
- Engine animation is off under `prefers-reduced-motion`.
|
|
185
167
|
|
|
186
|
-
## Props (
|
|
187
|
-
|
|
188
|
-
| Prop
|
|
189
|
-
|
|
|
190
|
-
| `animation`
|
|
191
|
-
| `
|
|
192
|
-
| `
|
|
193
|
-
| `
|
|
194
|
-
| `
|
|
195
|
-
| `
|
|
196
|
-
| `
|
|
197
|
-
| `
|
|
198
|
-
| `
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
### Slots (`Chart`)
|
|
202
|
-
|
|
203
|
-
| Slot | Description |
|
|
204
|
-
| --------- | ---------------------------------------------------------- |
|
|
205
|
-
| `default` | `ChartSeries`, `ChartAxis`, `ChartLegend`, `ChartTooltip`. |
|
|
206
|
-
| `empty` | Content shown when there is nothing to plot. |
|
|
207
|
-
| `loading` | Content shown while `loading` is true. |
|
|
208
|
-
|
|
209
|
-
## Props (`ChartSeries`)
|
|
210
|
-
|
|
211
|
-
| Prop | Type | Default | Description |
|
|
212
|
-
| ------- | --------------------------- | ---------- | ---------------------------------------- |
|
|
213
|
-
| `color` | `ChartSeriesColor` | palette | Token key or CSS color. |
|
|
214
|
-
| `curve` | `"linear" \| "smooth"` | `"linear"` | Line interpolation for `line` / `area`. |
|
|
215
|
-
| `data` | `(number \| null)[]` | required | One value per category; `null` is a gap. |
|
|
216
|
-
| `name` | `string` | required | Legend, tooltip, and table label. |
|
|
217
|
-
| `type` | `"line" \| "bar" \| "area"` | `"line"` | Series family. |
|
|
168
|
+
## Props (every root)
|
|
169
|
+
|
|
170
|
+
| Prop | Type | Default | Description |
|
|
171
|
+
| -------------- | ------------------- | ------------------------ | ------------------------------------------------------ |
|
|
172
|
+
| `animation` | `boolean` | `true` | Engine transitions (always off for reduced motion). |
|
|
173
|
+
| `classes` | `ChartClasses` | — | `root`, `plot`, `center`, `loading`, `empty`, `table`. |
|
|
174
|
+
| `height` | `number \| string` | `280` | Plot height. |
|
|
175
|
+
| `loading` | `boolean` | `false` | Shows the spinner overlay. |
|
|
176
|
+
| `palette` | `ChartColorValue[]` | primary, info, success … | Colors in order. |
|
|
177
|
+
| `size` | `ChartSize` | `"md"` | Density of labels, legend, and tooltip. |
|
|
178
|
+
| `summary` | `string` | generated | Accessible description of the plot. |
|
|
179
|
+
| `width` | `number \| string` | `"100%"` | Root width. |
|
|
180
|
+
| `custom-props` | `ChartCustomProps` | — | Extra props for `root` and `plot`. |
|
|
181
|
+
|
|
182
|
+
Slots: `default` (series, `ChartAxis`, `ChartLegend`, `ChartTooltip`), `empty`, `loading`.
|
|
218
183
|
|
|
219
184
|
## Props (`ChartAxis`)
|
|
220
185
|
|
|
221
|
-
| Prop
|
|
222
|
-
|
|
|
223
|
-
| `
|
|
224
|
-
| `
|
|
225
|
-
| `
|
|
226
|
-
| `
|
|
227
|
-
| `
|
|
228
|
-
| `
|
|
229
|
-
| `
|
|
230
|
-
| `
|
|
186
|
+
| Prop | Type | Default | Description |
|
|
187
|
+
| ----------------- | ------------------------------ | --------------------------- | ----------------------------------- |
|
|
188
|
+
| `position` | `"x" \| "y"` | required | Horizontal (`x`) or vertical (`y`). |
|
|
189
|
+
| `label` | `string` | — | Axis title. |
|
|
190
|
+
| `grid` | `boolean` | value axis on, category off | Grid lines. |
|
|
191
|
+
| `hidden` | `boolean` | `false` | Hides the axis line and labels. |
|
|
192
|
+
| `min` | `number` | — | Lower bound (value or time axis). |
|
|
193
|
+
| `max` | `number` | — | Upper bound (value or time axis). |
|
|
194
|
+
| `tick-count` | `number` | — | Preferred number of ticks. |
|
|
195
|
+
| `format-tick` | `(value: number) => string` | — | Value or time (ms) tick formatter. |
|
|
196
|
+
| `format-category` | `(category: string) => string` | — | Category tick formatter. |
|
|
231
197
|
|
|
232
198
|
## Props (`ChartLegend`)
|
|
233
199
|
|
|
234
|
-
| Prop
|
|
235
|
-
|
|
|
236
|
-
| `align`
|
|
237
|
-
| `
|
|
238
|
-
| `interactive`
|
|
239
|
-
| `
|
|
240
|
-
| `
|
|
200
|
+
| Prop | Type | Default | Description |
|
|
201
|
+
| ---------------- | ---------------------------------------- | ---------- | ------------------------------------------------------ |
|
|
202
|
+
| `align` | `"start" \| "center" \| "end"` | `"center"` | Entry alignment. |
|
|
203
|
+
| `position` | `"top" \| "bottom" \| "left" \| "right"` | `"bottom"` | Where the legend sits. |
|
|
204
|
+
| `interactive` | `boolean` | `true` | Entries toggle and emphasize items. |
|
|
205
|
+
| `show-value` | `boolean` | `false` | Value column (pie, funnel). |
|
|
206
|
+
| `show-percent` | `boolean` | `false` | Share column (pie, funnel). |
|
|
207
|
+
| `format-value` | `(value: number) => string` | — | Value column formatter. |
|
|
208
|
+
| `format-percent` | `(percent: number) => string` | — | Share column formatter. |
|
|
209
|
+
| `classes` | `ChartLegendClasses` | — | `root`, `item`, `swatch`, `label`, `value`, `percent`. |
|
|
210
|
+
| `custom-props` | `ChartLegendCustomProps` | — | Extra props for `root` and `item`. |
|
|
241
211
|
|
|
242
212
|
## Props (`ChartTooltip`)
|
|
243
213
|
|
|
244
|
-
| Prop
|
|
245
|
-
|
|
|
246
|
-
| `
|
|
247
|
-
| `
|
|
248
|
-
| `
|
|
249
|
-
|
|
250
|
-
### Slots (`ChartTooltip`)
|
|
214
|
+
| Prop | Type | Default | Description |
|
|
215
|
+
| ---------------- | --------------------------- | ------- | ----------------------------------------------------------------------- |
|
|
216
|
+
| `format-value` | `(value, item) => string` | — | Value formatter. |
|
|
217
|
+
| `format-percent` | `(percent, item) => string` | — | Share formatter (pie, funnel). |
|
|
218
|
+
| `classes` | `ChartTooltipClasses` | — | `root`, `title`, `item`, `swatch`, `label`, `value`, `percent`, `note`. |
|
|
219
|
+
| `custom-props` | `ChartTooltipCustomProps` | — | Extra props for `root`. |
|
|
251
220
|
|
|
252
|
-
|
|
253
|
-
| --------- | ---------------------------- | ---------------------------- |
|
|
254
|
-
| `content` | `{ category, index, items }` | Replaces the title and rows. |
|
|
221
|
+
Slot: `content` (`{ index, title, color, items }`) replaces the title and rows.
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
# ChartBar
|
|
2
|
+
|
|
3
|
+
Bar charts: comparisons, rankings, stacked totals, negative values, and time axes. Compose with `ChartBarSeries`, `ChartAxis`, `ChartLegend`, and `ChartTooltip`. Shared parts, colors, and a11y are in [Chart](./Chart.md).
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { ChartBar } from "@bridge-ui/vue/Components/ChartBar";
|
|
9
|
+
import { ChartBarSeries } from "@bridge-ui/vue/Components/ChartBarSeries";
|
|
10
|
+
import { ChartLineSeries } from "@bridge-ui/vue/Components/ChartLineSeries";
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Examples
|
|
14
|
+
|
|
15
|
+
### Usage
|
|
16
|
+
|
|
17
|
+
```vue
|
|
18
|
+
<ChartBar :height="320" :categories="months">
|
|
19
|
+
<ChartBarSeries name="Online" :data="online" />
|
|
20
|
+
<ChartBarSeries name="Retail" :data="retail" />
|
|
21
|
+
<ChartLegend align="start" position="top" />
|
|
22
|
+
<ChartTooltip />
|
|
23
|
+
</ChartBar>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Horizontal
|
|
27
|
+
|
|
28
|
+
`orientation="horizontal"` lists the categories top to bottom on the `y` axis. Value formatting moves to `x`.
|
|
29
|
+
|
|
30
|
+
```vue
|
|
31
|
+
<ChartBar :categories="tags" orientation="horizontal">
|
|
32
|
+
<ChartBarSeries :data="spent" name="October" />
|
|
33
|
+
<ChartAxis position="x" :format-tick="(value) => currency.format(value)" />
|
|
34
|
+
</ChartBar>
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Stacked
|
|
38
|
+
|
|
39
|
+
Series with the same `stack` key stack. Only the outermost bar of each stack is rounded.
|
|
40
|
+
|
|
41
|
+
```vue
|
|
42
|
+
<ChartBar labels stack="total" :categories="months">
|
|
43
|
+
<ChartBarSeries name="Online" :data="online" />
|
|
44
|
+
<ChartBarSeries name="Retail" :data="retail" />
|
|
45
|
+
<ChartLegend />
|
|
46
|
+
</ChartBar>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Inside labels that do not fit their segment are hidden.
|
|
50
|
+
|
|
51
|
+
### Bar + line
|
|
52
|
+
|
|
53
|
+
`ChartLineSeries` inside `ChartBar` draws a line over the bars on the same value axis, with the points centered on each category. Line options (`dashed`, `show-points`, `curve`, `area`, `reference`) work as in `ChartLine`.
|
|
54
|
+
|
|
55
|
+
```vue
|
|
56
|
+
<ChartBar :categories="months">
|
|
57
|
+
<ChartBarSeries name="Orders" :data="orders" />
|
|
58
|
+
<ChartLineSeries dashed name="Returns" :data="returns" />
|
|
59
|
+
<ChartLegend />
|
|
60
|
+
<ChartTooltip />
|
|
61
|
+
</ChartBar>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
The `ChartBar` `stack` applies to bars only: a line stays on its own values (a target, an average) unless you give it a `stack`.
|
|
65
|
+
|
|
66
|
+
`ChartBar` loads the ECharts line series too, so bar + line charts need no extra import.
|
|
67
|
+
|
|
68
|
+
### Category colors
|
|
69
|
+
|
|
70
|
+
`category-colors` gives each category its own bar color. Every bar series in a category shares that color; `tone="muted"` tells a comparison series apart with a lighter shade of the same color.
|
|
71
|
+
|
|
72
|
+
```vue
|
|
73
|
+
<script setup lang="ts">
|
|
74
|
+
const tagColors = {
|
|
75
|
+
housing: "primary",
|
|
76
|
+
groceries: "success",
|
|
77
|
+
transport: "warning",
|
|
78
|
+
delivery: "#8b5cf6",
|
|
79
|
+
};
|
|
80
|
+
</script>
|
|
81
|
+
|
|
82
|
+
<template>
|
|
83
|
+
<ChartBar :categories="tags" :category-colors="tagColors">
|
|
84
|
+
<ChartBarSeries name="October" :data="october" />
|
|
85
|
+
<ChartBarSeries tone="muted" :data="average" name="6-month average" />
|
|
86
|
+
<ChartLegend />
|
|
87
|
+
<ChartTooltip />
|
|
88
|
+
</ChartBar>
|
|
89
|
+
</template>
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
`category-colors` takes a record keyed by category label, an array in category order, or `true` (the bare `category-colors` attribute) to use the palette in category order. Categories without a color take the palette entry at their index.
|
|
93
|
+
|
|
94
|
+
With category colors the legend shows each series in a neutral color (muted series in a lighter shade), and the tooltip shows the bar colors. `ChartLineSeries` inside keep their own color.
|
|
95
|
+
|
|
96
|
+
`tone="muted"` also works without `category-colors`: it lightens the series color (a previous period next to the current one). Muted shades mix toward the background behind the chart, so they follow light and dark mode.
|
|
97
|
+
|
|
98
|
+
### Color by value
|
|
99
|
+
|
|
100
|
+
`color-ranges` recolors single bars by value. A value in `[min, max)` takes the range color; bars outside every range keep the series color. Range labels show in the tooltip, the data table, and the keyboard announcements.
|
|
101
|
+
|
|
102
|
+
```vue
|
|
103
|
+
<ChartBar :categories="months">
|
|
104
|
+
<ChartBarSeries
|
|
105
|
+
name="Spent"
|
|
106
|
+
:data="spent"
|
|
107
|
+
:color-ranges="[
|
|
108
|
+
{ max: 1000, color: 'success', label: 'On budget' },
|
|
109
|
+
{ min: 1000, color: 'error', label: 'Over budget' },
|
|
110
|
+
]"
|
|
111
|
+
/>
|
|
112
|
+
</ChartBar>
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
With `color-by="category"`, `min` and `max` are category indices (both included) instead of values. Ranges win over `category-colors`.
|
|
116
|
+
|
|
117
|
+
### Negative values
|
|
118
|
+
|
|
119
|
+
Bars round the end that points away from zero.
|
|
120
|
+
|
|
121
|
+
```vue
|
|
122
|
+
<ChartBar :categories="months">
|
|
123
|
+
<ChartBarSeries name="Balance" :data="[1200, -400, 800, -150]" />
|
|
124
|
+
</ChartBar>
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Reference lines
|
|
128
|
+
|
|
129
|
+
```vue
|
|
130
|
+
<ChartBar :categories="months">
|
|
131
|
+
<ChartBarSeries name="Orders" :data="orders" :reference="{ type: 'average' }" />
|
|
132
|
+
</ChartBar>
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Value labels
|
|
136
|
+
|
|
137
|
+
```vue
|
|
138
|
+
<ChartBar labels :categories="months" :format-label="(value) => `${value}%`">
|
|
139
|
+
<ChartBarSeries name="Share" :data="share" />
|
|
140
|
+
</ChartBar>
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Time axis
|
|
144
|
+
|
|
145
|
+
Dates as `categories` place bars by time. See [ChartLine](./ChartLine.md#time-axis).
|
|
146
|
+
|
|
147
|
+
```vue
|
|
148
|
+
<ChartBar :categories="days">
|
|
149
|
+
<ChartBarSeries name="Spent" :data="spentPerDay" />
|
|
150
|
+
</ChartBar>
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Square corners
|
|
154
|
+
|
|
155
|
+
```vue
|
|
156
|
+
<ChartBar :radius="0" :categories="months">
|
|
157
|
+
<ChartBarSeries name="Orders" :data="orders" />
|
|
158
|
+
</ChartBar>
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## Props (`ChartBar`)
|
|
162
|
+
|
|
163
|
+
Shared root props (`height`, `palette`, `loading`, `summary`, …) are listed in [Chart](./Chart.md#props-every-root).
|
|
164
|
+
|
|
165
|
+
| Prop | Type | Default | Description |
|
|
166
|
+
| ----------------- | ----------------------------------------------------------------- | ------------ | ------------------------------------------------------------------------------------ |
|
|
167
|
+
| `categories` | `string[] \| Date[]` | required | Category labels, or dates for a time axis. |
|
|
168
|
+
| `category-colors` | `boolean \| ChartColorValue[] \| Record<string, ChartColorValue>` | — | Bar color per category (record by label, array by index, or `true` for the palette). |
|
|
169
|
+
| `orientation` | `"vertical" \| "horizontal"` | `"vertical"` | `horizontal` puts categories on `y`. |
|
|
170
|
+
| `stack` | `string` | — | Stack every bar series under this key. |
|
|
171
|
+
| `labels` | `boolean` | `false` | Value labels on every series. |
|
|
172
|
+
| `radius` | `number` | `4` | Corner radius (px) on the value end. |
|
|
173
|
+
| `format-date` | `(date: Date) => string` | — | Date labels in the tooltip, table, and summary. |
|
|
174
|
+
| `format-label` | `(value: number) => string` | — | Value labels and reference line labels. |
|
|
175
|
+
|
|
176
|
+
## Props (`ChartBarSeries`)
|
|
177
|
+
|
|
178
|
+
Unset options fall back to the `ChartBar` props.
|
|
179
|
+
|
|
180
|
+
| Prop | Type | Default | Description |
|
|
181
|
+
| -------------- | ------------------------------------ | --------- | -------------------------------------------------------------------------------------- |
|
|
182
|
+
| `name` | `string` | required | Legend, tooltip, and table name. |
|
|
183
|
+
| `data` | `(number \| null)[]` | required | One value per category. |
|
|
184
|
+
| `color` | `ChartColorValue` | palette | Token key or CSS color. |
|
|
185
|
+
| `stack` | `string` | root | Stack key. |
|
|
186
|
+
| `labels` | `boolean` | root | Value labels. |
|
|
187
|
+
| `reference` | `ChartReference \| ChartReference[]` | — | `{ type: "average" \| "min" \| "max" }` or `{ value }`, each with an optional `label`. |
|
|
188
|
+
| `tone` | `"solid" \| "muted"` | `"solid"` | `muted` mixes the bar colors toward the background. |
|
|
189
|
+
| `color-ranges` | `ChartColorRangeOption[]` | — | `{ min?, max?, color, label? }`: bars with a value in `[min, max)` take `color`. |
|
|
190
|
+
| `color-by` | `"value" \| "category"` | `"value"` | `category` matches `color-ranges` against category indices (both ends included). |
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# ChartFunnel
|
|
2
|
+
|
|
3
|
+
Funnel charts: conversion through ordered stages. Stages come from `data`; compose with `ChartLegend` and `ChartTooltip`. Shared parts, colors, and a11y are in [Chart](./Chart.md).
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { ChartFunnel } from "@bridge-ui/vue/Components/ChartFunnel";
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Examples
|
|
12
|
+
|
|
13
|
+
### Usage
|
|
14
|
+
|
|
15
|
+
```vue
|
|
16
|
+
<ChartFunnel
|
|
17
|
+
:data="[
|
|
18
|
+
{ label: 'Visited', value: 1200 },
|
|
19
|
+
{ label: 'Signed up', value: 420 },
|
|
20
|
+
{ label: 'Paid', value: 96 },
|
|
21
|
+
]"
|
|
22
|
+
>
|
|
23
|
+
<ChartTooltip />
|
|
24
|
+
</ChartFunnel>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Stages are sorted from the largest by default. Shares compare each stage to the largest one, whatever the order: with `sort="none"`, a stage after a smaller one can show a higher share.
|
|
28
|
+
|
|
29
|
+
### Order
|
|
30
|
+
|
|
31
|
+
```vue
|
|
32
|
+
<ChartFunnel sort="none" :data="steps" />
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Labels and legend
|
|
36
|
+
|
|
37
|
+
Stage labels are on and sit inside the shape by default. `label-position="outside"` moves them next to it, `:labels="false"` hides them, and `label-content` picks the text.
|
|
38
|
+
|
|
39
|
+
```vue
|
|
40
|
+
<ChartFunnel :data="steps" label-content="percent" label-position="outside">
|
|
41
|
+
<ChartLegend show-value show-percent />
|
|
42
|
+
</ChartFunnel>
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Alignment
|
|
46
|
+
|
|
47
|
+
```vue
|
|
48
|
+
<ChartFunnel align="left" :data="steps" />
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Props (`ChartFunnel`)
|
|
52
|
+
|
|
53
|
+
Shared root props (`height`, `palette`, `loading`, `summary`, …) are listed in [Chart](./Chart.md#props-every-root).
|
|
54
|
+
|
|
55
|
+
| Prop | Type | Default | Description |
|
|
56
|
+
| ---------------- | ------------------------------------------------------ | -------------- | --------------------------- |
|
|
57
|
+
| `data` | `{ label, value, color? }[]` | required | Stages. |
|
|
58
|
+
| `sort` | `"descending" \| "ascending" \| "none"` | `"descending"` | Stage order, top to bottom. |
|
|
59
|
+
| `align` | `"center" \| "left" \| "right"` | `"center"` | Shape alignment. |
|
|
60
|
+
| `labels` | `boolean` | `true` | Stage labels on the plot. |
|
|
61
|
+
| `label-position` | `"inside" \| "outside"` | `"inside"` | Where plot labels sit. |
|
|
62
|
+
| `label-content` | `"label" \| "value" \| "percent" \| (stage) => string` | `"label"` | What plot labels show. |
|