From 4159f5661639f781a7d9bc5a7a24158d4850737a Mon Sep 17 00:00:00 2001 From: zernonia Date: Fri, 26 Apr 2024 00:35:26 +0800 Subject: [PATCH] chore: add feature --- apps/www/src/content/docs/charts/guide.md | 33 +++++++++++++++++++ .../default/ui/chart-area/AreaChart.vue | 17 ++++++++-- .../default/ui/chart-bar/BarChart.vue | 8 +++-- .../default/ui/chart-donut/DonutChart.vue | 8 +++-- .../default/ui/chart-line/LineChart.vue | 19 ++++++++--- .../default/ui/chart/ChartCrosshair.vue | 6 ++-- .../default/ui/chart/ChartSingleTooltip.vue | 10 ++++-- .../new-york/ui/chart-area/AreaChart.vue | 17 ++++++++-- .../new-york/ui/chart-bar/BarChart.vue | 8 +++-- .../new-york/ui/chart-donut/DonutChart.vue | 11 ++++--- .../new-york/ui/chart-line/LineChart.vue | 22 ++++++++++--- .../new-york/ui/chart/ChartCrosshair.vue | 6 ++-- .../new-york/ui/chart/ChartSingleTooltip.vue | 10 ++++-- 13 files changed, 140 insertions(+), 35 deletions(-) diff --git a/apps/www/src/content/docs/charts/guide.md b/apps/www/src/content/docs/charts/guide.md index 60c202f1..98f90cbd 100644 --- a/apps/www/src/content/docs/charts/guide.md +++ b/apps/www/src/content/docs/charts/guide.md @@ -41,3 +41,36 @@ Add the following tooltip styling to your `tailwind.css` file: ``` + +## Colors + +By default, we construct the primary theme color, and secondary (`--vis-secondary-color`) color with different opacity for the graph. + +However, you can always pass in the desired `color` into each chart. + +```vue + +``` + +## Custom tooltip + +If you want to customize the `Tooltip` for the chart, you can pass `customTooltip` prop with a custom Vue component. +The custom component would receive `title` and `data` props, check out [ChartTooltip.vue component](https://github.com/radix-vue/shadcn-vue/tree/dev/apps/www/src/lib/registry/default/ui/chart/ChartTooltip.vue) for example. + +The expecting prop definition would be + +```ts +defineProps<{ + title?: string + data: { + name: string + color: string + value: any + }[] +}>() +``` diff --git a/apps/www/src/lib/registry/default/ui/chart-area/AreaChart.vue b/apps/www/src/lib/registry/default/ui/chart-area/AreaChart.vue index 723fcd52..6333b286 100644 --- a/apps/www/src/lib/registry/default/ui/chart-area/AreaChart.vue +++ b/apps/www/src/lib/registry/default/ui/chart-area/AreaChart.vue @@ -1,19 +1,28 @@