diff --git a/apps/www/src/content/meta/AreaChart.md b/apps/www/src/content/meta/AreaChart.md index 16b4c0560..0e4805a3c 100644 --- a/apps/www/src/content/meta/AreaChart.md +++ b/apps/www/src/content/meta/AreaChart.md @@ -19,6 +19,12 @@ 'type': 'string', 'required': true }, + { + 'name': 'selectedLegend', + 'description': '

Select the categories from your data. Used to preselection the legend.

\n', + 'type': 'string', + 'required': false + }, { 'name': 'colors', 'description': '

Change the default colors.

\n', diff --git a/apps/www/src/content/meta/BarChart.md b/apps/www/src/content/meta/BarChart.md index 4b7f07f36..5f38388bc 100644 --- a/apps/www/src/content/meta/BarChart.md +++ b/apps/www/src/content/meta/BarChart.md @@ -19,6 +19,12 @@ 'type': 'string', 'required': true }, + { + 'name': 'selectedLegend', + 'description': '

Select the categories from your data. Used to preselection the legend.

\n', + 'type': 'string', + 'required': false + }, { 'name': 'colors', 'description': '

Change the default colors.

\n', diff --git a/apps/www/src/content/meta/LineChart.md b/apps/www/src/content/meta/LineChart.md index 7492b007f..5266fd0c9 100644 --- a/apps/www/src/content/meta/LineChart.md +++ b/apps/www/src/content/meta/LineChart.md @@ -19,6 +19,12 @@ 'type': 'string', 'required': true }, + { + 'name': 'selectedLegend', + 'description': '

Select the categories from your data. Used to preselection the legend.

\n', + 'type': 'string', + 'required': false + }, { 'name': 'colors', 'description': '

Change the default colors.

\n', diff --git a/apps/www/src/public/r/styles/default/chart-area.json b/apps/www/src/public/r/styles/default/chart-area.json index bf472643d..9e7070b56 100644 --- a/apps/www/src/public/r/styles/default/chart-area.json +++ b/apps/www/src/public/r/styles/default/chart-area.json @@ -13,13 +13,13 @@ "files": [ { "path": "ui/chart-area/AreaChart.vue", - "content": "\n\n\n", + "content": "\n\n\n", "type": "registry:ui", "target": "" }, { "path": "ui/chart-area/index.ts", - "content": "export { default as AreaChart } from './AreaChart.vue'\n\nimport type { Spacing } from '@unovis/ts'\n\ntype KeyOf> = Extract\n\nexport interface BaseChartProps> {\n /**\n * The source data, in which each entry is a dictionary.\n */\n data: T[]\n /**\n * Select the categories from your data. Used to populate the legend and toolip.\n */\n categories: KeyOf[]\n /**\n * Sets the key to map the data to the axis.\n */\n index: KeyOf\n /**\n * Change the default colors.\n */\n colors?: string[]\n /**\n * Margin of each the container\n */\n margin?: Spacing\n /**\n * Change the opacity of the non-selected field\n * @default 0.2\n */\n filterOpacity?: number\n /**\n * Function to format X label\n */\n xFormatter?: (tick: number | Date, i: number, ticks: number[] | Date[]) => string\n /**\n * Function to format Y label\n */\n yFormatter?: (tick: number | Date, i: number, ticks: number[] | Date[]) => string\n /**\n * Controls the visibility of the X axis.\n * @default true\n */\n showXAxis?: boolean\n /**\n * Controls the visibility of the Y axis.\n * @default true\n */\n showYAxis?: boolean\n /**\n * Controls the visibility of tooltip.\n * @default true\n */\n showTooltip?: boolean\n /**\n * Controls the visibility of legend.\n * @default true\n */\n showLegend?: boolean\n /**\n * Controls the visibility of gridline.\n * @default true\n */\n showGridLine?: boolean\n}\n", + "content": "export { default as AreaChart } from './AreaChart.vue'\n\nimport type { Spacing } from '@unovis/ts'\n\ntype KeyOf> = Extract\n\nexport interface BaseChartProps> {\n /**\n * The source data, in which each entry is a dictionary.\n */\n data: T[]\n /**\n * Select the categories from your data. Used to populate the legend and toolip.\n */\n categories: KeyOf[]\n /**\n * Sets the key to map the data to the axis.\n */\n index: KeyOf\n /**\n * Change the default colors.\n */\n colors?: string[]\n /**\n * Margin of each the container\n */\n margin?: Spacing\n /**\n * Change the opacity of the non-selected field\n * @default 0.2\n */\n filterOpacity?: number\n /**\n * Function to format X label\n */\n xFormatter?: (tick: number | Date, i: number, ticks: number[] | Date[]) => string\n /**\n * Function to format Y label\n */\n yFormatter?: (tick: number | Date, i: number, ticks: number[] | Date[]) => string\n /**\n * Controls the visibility of the X axis.\n * @default true\n */\n showXAxis?: boolean\n /**\n * Controls the visibility of the Y axis.\n * @default true\n */\n showYAxis?: boolean\n /**\n * Controls the visibility of tooltip.\n * @default true\n */\n showTooltip?: boolean\n /**\n * Controls the visibility of legend.\n * @default true\n */\n showLegend?: boolean\n /**\n * Controls the visibility of gridline.\n * @default true\n */\n showGridLine?: boolean\n /**\n * Select the categories from your data. Used to preselection the legend.\n */\n selectedLegend?: KeyOf\n}\n", "type": "registry:ui", "target": "" } diff --git a/apps/www/src/public/r/styles/default/chart-bar.json b/apps/www/src/public/r/styles/default/chart-bar.json index 6dbfd75a4..38740c209 100644 --- a/apps/www/src/public/r/styles/default/chart-bar.json +++ b/apps/www/src/public/r/styles/default/chart-bar.json @@ -12,13 +12,13 @@ "files": [ { "path": "ui/chart-bar/BarChart.vue", - "content": "\n\n\n", + "content": "\n\n\n", "type": "registry:ui", "target": "" }, { "path": "ui/chart-bar/index.ts", - "content": "export { default as BarChart } from './BarChart.vue'\n\nimport type { Spacing } from '@unovis/ts'\n\ntype KeyOf> = Extract\n\nexport interface BaseChartProps> {\n /**\n * The source data, in which each entry is a dictionary.\n */\n data: T[]\n /**\n * Select the categories from your data. Used to populate the legend and toolip.\n */\n categories: KeyOf[]\n /**\n * Sets the key to map the data to the axis.\n */\n index: KeyOf\n /**\n * Change the default colors.\n */\n colors?: string[]\n /**\n * Margin of each the container\n */\n margin?: Spacing\n /**\n * Change the opacity of the non-selected field\n * @default 0.2\n */\n filterOpacity?: number\n /**\n * Function to format X label\n */\n xFormatter?: (tick: number | Date, i: number, ticks: number[] | Date[]) => string\n /**\n * Function to format Y label\n */\n yFormatter?: (tick: number | Date, i: number, ticks: number[] | Date[]) => string\n /**\n * Controls the visibility of the X axis.\n * @default true\n */\n showXAxis?: boolean\n /**\n * Controls the visibility of the Y axis.\n * @default true\n */\n showYAxis?: boolean\n /**\n * Controls the visibility of tooltip.\n * @default true\n */\n showTooltip?: boolean\n /**\n * Controls the visibility of legend.\n * @default true\n */\n showLegend?: boolean\n /**\n * Controls the visibility of gridline.\n * @default true\n */\n showGridLine?: boolean\n}\n", + "content": "export { default as BarChart } from './BarChart.vue'\n\nimport type { Spacing } from '@unovis/ts'\n\ntype KeyOf> = Extract\n\nexport interface BaseChartProps> {\n /**\n * The source data, in which each entry is a dictionary.\n */\n data: T[]\n /**\n * Select the categories from your data. Used to populate the legend and toolip.\n */\n categories: KeyOf[]\n /**\n * Sets the key to map the data to the axis.\n */\n index: KeyOf\n /**\n * Change the default colors.\n */\n colors?: string[]\n /**\n * Margin of each the container\n */\n margin?: Spacing\n /**\n * Change the opacity of the non-selected field\n * @default 0.2\n */\n filterOpacity?: number\n /**\n * Function to format X label\n */\n xFormatter?: (tick: number | Date, i: number, ticks: number[] | Date[]) => string\n /**\n * Function to format Y label\n */\n yFormatter?: (tick: number | Date, i: number, ticks: number[] | Date[]) => string\n /**\n * Controls the visibility of the X axis.\n * @default true\n */\n showXAxis?: boolean\n /**\n * Controls the visibility of the Y axis.\n * @default true\n */\n showYAxis?: boolean\n /**\n * Controls the visibility of tooltip.\n * @default true\n */\n showTooltip?: boolean\n /**\n * Controls the visibility of legend.\n * @default true\n */\n showLegend?: boolean\n /**\n * Controls the visibility of gridline.\n * @default true\n */\n showGridLine?: boolean\n /**\n * Select the categories from your data. Used to preselection the legend.\n */\n selectedLegend?: KeyOf\n}\n", "type": "registry:ui", "target": "" } diff --git a/apps/www/src/public/r/styles/default/chart-line.json b/apps/www/src/public/r/styles/default/chart-line.json index 9ccc83279..349686cbb 100644 --- a/apps/www/src/public/r/styles/default/chart-line.json +++ b/apps/www/src/public/r/styles/default/chart-line.json @@ -12,13 +12,13 @@ "files": [ { "path": "ui/chart-line/LineChart.vue", - "content": "\n\n\n", + "content": "\n\n\n", "type": "registry:ui", "target": "" }, { "path": "ui/chart-line/index.ts", - "content": "export { default as LineChart } from './LineChart.vue'\n\nimport type { Spacing } from '@unovis/ts'\n\ntype KeyOf> = Extract\n\nexport interface BaseChartProps> {\n /**\n * The source data, in which each entry is a dictionary.\n */\n data: T[]\n /**\n * Select the categories from your data. Used to populate the legend and toolip.\n */\n categories: KeyOf[]\n /**\n * Sets the key to map the data to the axis.\n */\n index: KeyOf\n /**\n * Change the default colors.\n */\n colors?: string[]\n /**\n * Margin of each the container\n */\n margin?: Spacing\n /**\n * Change the opacity of the non-selected field\n * @default 0.2\n */\n filterOpacity?: number\n /**\n * Function to format X label\n */\n xFormatter?: (tick: number | Date, i: number, ticks: number[] | Date[]) => string\n /**\n * Function to format Y label\n */\n yFormatter?: (tick: number | Date, i: number, ticks: number[] | Date[]) => string\n /**\n * Controls the visibility of the X axis.\n * @default true\n */\n showXAxis?: boolean\n /**\n * Controls the visibility of the Y axis.\n * @default true\n */\n showYAxis?: boolean\n /**\n * Controls the visibility of tooltip.\n * @default true\n */\n showTooltip?: boolean\n /**\n * Controls the visibility of legend.\n * @default true\n */\n showLegend?: boolean\n /**\n * Controls the visibility of gridline.\n * @default true\n */\n showGridLine?: boolean\n}\n", + "content": "export { default as LineChart } from './LineChart.vue'\n\nimport type { Spacing } from '@unovis/ts'\n\ntype KeyOf> = Extract\n\nexport interface BaseChartProps> {\n /**\n * The source data, in which each entry is a dictionary.\n */\n data: T[]\n /**\n * Select the categories from your data. Used to populate the legend and toolip.\n */\n categories: KeyOf[]\n /**\n * Sets the key to map the data to the axis.\n */\n index: KeyOf\n /**\n * Change the default colors.\n */\n colors?: string[]\n /**\n * Margin of each the container\n */\n margin?: Spacing\n /**\n * Change the opacity of the non-selected field\n * @default 0.2\n */\n filterOpacity?: number\n /**\n * Function to format X label\n */\n xFormatter?: (tick: number | Date, i: number, ticks: number[] | Date[]) => string\n /**\n * Function to format Y label\n */\n yFormatter?: (tick: number | Date, i: number, ticks: number[] | Date[]) => string\n /**\n * Controls the visibility of the X axis.\n * @default true\n */\n showXAxis?: boolean\n /**\n * Controls the visibility of the Y axis.\n * @default true\n */\n showYAxis?: boolean\n /**\n * Controls the visibility of tooltip.\n * @default true\n */\n showTooltip?: boolean\n /**\n * Controls the visibility of legend.\n * @default true\n */\n showLegend?: boolean\n /**\n * Controls the visibility of gridline.\n * @default true\n */\n showGridLine?: boolean\n /**\n * Select the categories from your data. Used to preselection the legend.\n */\n selectedLegend?: KeyOf\n}\n", "type": "registry:ui", "target": "" } diff --git a/apps/www/src/public/r/styles/new-york/chart-area.json b/apps/www/src/public/r/styles/new-york/chart-area.json index 7f1a5ec90..d4a20aac4 100644 --- a/apps/www/src/public/r/styles/new-york/chart-area.json +++ b/apps/www/src/public/r/styles/new-york/chart-area.json @@ -13,13 +13,13 @@ "files": [ { "path": "ui/chart-area/AreaChart.vue", - "content": "\n\n\n", + "content": "\n\n\n", "type": "registry:ui", "target": "" }, { "path": "ui/chart-area/index.ts", - "content": "export { default as AreaChart } from './AreaChart.vue'\n\nimport type { Spacing } from '@unovis/ts'\n\ntype KeyOf> = Extract\n\nexport interface BaseChartProps> {\n /**\n * The source data, in which each entry is a dictionary.\n */\n data: T[]\n /**\n * Select the categories from your data. Used to populate the legend and toolip.\n */\n categories: KeyOf[]\n /**\n * Sets the key to map the data to the axis.\n */\n index: KeyOf\n /**\n * Change the default colors.\n */\n colors?: string[]\n /**\n * Margin of each the container\n */\n margin?: Spacing\n /**\n * Change the opacity of the non-selected field\n * @default 0.2\n */\n filterOpacity?: number\n /**\n * Function to format X label\n */\n xFormatter?: (tick: number | Date, i: number, ticks: number[] | Date[]) => string\n /**\n * Function to format Y label\n */\n yFormatter?: (tick: number | Date, i: number, ticks: number[] | Date[]) => string\n /**\n * Controls the visibility of the X axis.\n * @default true\n */\n showXAxis?: boolean\n /**\n * Controls the visibility of the Y axis.\n * @default true\n */\n showYAxis?: boolean\n /**\n * Controls the visibility of tooltip.\n * @default true\n */\n showTooltip?: boolean\n /**\n * Controls the visibility of legend.\n * @default true\n */\n showLegend?: boolean\n /**\n * Controls the visibility of gridline.\n * @default true\n */\n showGridLine?: boolean\n}\n", + "content": "export { default as AreaChart } from './AreaChart.vue'\n\nimport type { Spacing } from '@unovis/ts'\n\ntype KeyOf> = Extract\n\nexport interface BaseChartProps> {\n /**\n * The source data, in which each entry is a dictionary.\n */\n data: T[]\n /**\n * Select the categories from your data. Used to populate the legend and toolip.\n */\n categories: KeyOf[]\n /**\n * Sets the key to map the data to the axis.\n */\n index: KeyOf\n /**\n * Change the default colors.\n */\n colors?: string[]\n /**\n * Margin of each the container\n */\n margin?: Spacing\n /**\n * Change the opacity of the non-selected field\n * @default 0.2\n */\n filterOpacity?: number\n /**\n * Function to format X label\n */\n xFormatter?: (tick: number | Date, i: number, ticks: number[] | Date[]) => string\n /**\n * Function to format Y label\n */\n yFormatter?: (tick: number | Date, i: number, ticks: number[] | Date[]) => string\n /**\n * Controls the visibility of the X axis.\n * @default true\n */\n showXAxis?: boolean\n /**\n * Controls the visibility of the Y axis.\n * @default true\n */\n showYAxis?: boolean\n /**\n * Controls the visibility of tooltip.\n * @default true\n */\n showTooltip?: boolean\n /**\n * Controls the visibility of legend.\n * @default true\n */\n showLegend?: boolean\n /**\n * Controls the visibility of gridline.\n * @default true\n */\n showGridLine?: boolean\n /**\n * Select the categories from your data. Used to preselection the legend.\n */\n selectedLegend?: KeyOf\n}\n", "type": "registry:ui", "target": "" } diff --git a/apps/www/src/public/r/styles/new-york/chart-bar.json b/apps/www/src/public/r/styles/new-york/chart-bar.json index da2a803a2..ff92d8a05 100644 --- a/apps/www/src/public/r/styles/new-york/chart-bar.json +++ b/apps/www/src/public/r/styles/new-york/chart-bar.json @@ -12,13 +12,13 @@ "files": [ { "path": "ui/chart-bar/BarChart.vue", - "content": "\n\n\n", + "content": "\n\n\n", "type": "registry:ui", "target": "" }, { "path": "ui/chart-bar/index.ts", - "content": "export { default as BarChart } from './BarChart.vue'\n\nimport type { Spacing } from '@unovis/ts'\n\ntype KeyOf> = Extract\n\nexport interface BaseChartProps> {\n /**\n * The source data, in which each entry is a dictionary.\n */\n data: T[]\n /**\n * Select the categories from your data. Used to populate the legend and toolip.\n */\n categories: KeyOf[]\n /**\n * Sets the key to map the data to the axis.\n */\n index: KeyOf\n /**\n * Change the default colors.\n */\n colors?: string[]\n /**\n * Margin of each the container\n */\n margin?: Spacing\n /**\n * Change the opacity of the non-selected field\n * @default 0.2\n */\n filterOpacity?: number\n /**\n * Function to format X label\n */\n xFormatter?: (tick: number | Date, i: number, ticks: number[] | Date[]) => string\n /**\n * Function to format Y label\n */\n yFormatter?: (tick: number | Date, i: number, ticks: number[] | Date[]) => string\n /**\n * Controls the visibility of the X axis.\n * @default true\n */\n showXAxis?: boolean\n /**\n * Controls the visibility of the Y axis.\n * @default true\n */\n showYAxis?: boolean\n /**\n * Controls the visibility of tooltip.\n * @default true\n */\n showTooltip?: boolean\n /**\n * Controls the visibility of legend.\n * @default true\n */\n showLegend?: boolean\n /**\n * Controls the visibility of gridline.\n * @default true\n */\n showGridLine?: boolean\n}\n", + "content": "export { default as BarChart } from './BarChart.vue'\n\nimport type { Spacing } from '@unovis/ts'\n\ntype KeyOf> = Extract\n\nexport interface BaseChartProps> {\n /**\n * The source data, in which each entry is a dictionary.\n */\n data: T[]\n /**\n * Select the categories from your data. Used to populate the legend and toolip.\n */\n categories: KeyOf[]\n /**\n * Sets the key to map the data to the axis.\n */\n index: KeyOf\n /**\n * Change the default colors.\n */\n colors?: string[]\n /**\n * Margin of each the container\n */\n margin?: Spacing\n /**\n * Change the opacity of the non-selected field\n * @default 0.2\n */\n filterOpacity?: number\n /**\n * Function to format X label\n */\n xFormatter?: (tick: number | Date, i: number, ticks: number[] | Date[]) => string\n /**\n * Function to format Y label\n */\n yFormatter?: (tick: number | Date, i: number, ticks: number[] | Date[]) => string\n /**\n * Controls the visibility of the X axis.\n * @default true\n */\n showXAxis?: boolean\n /**\n * Controls the visibility of the Y axis.\n * @default true\n */\n showYAxis?: boolean\n /**\n * Controls the visibility of tooltip.\n * @default true\n */\n showTooltip?: boolean\n /**\n * Controls the visibility of legend.\n * @default true\n */\n showLegend?: boolean\n /**\n * Controls the visibility of gridline.\n * @default true\n */\n showGridLine?: boolean\n /**\n * Select the categories from your data. Used to preselection the legend.\n */\n selectedLegend?: KeyOf\n}\n", "type": "registry:ui", "target": "" } diff --git a/apps/www/src/public/r/styles/new-york/chart-line.json b/apps/www/src/public/r/styles/new-york/chart-line.json index 0d61dcc64..a3dfb815c 100644 --- a/apps/www/src/public/r/styles/new-york/chart-line.json +++ b/apps/www/src/public/r/styles/new-york/chart-line.json @@ -12,13 +12,13 @@ "files": [ { "path": "ui/chart-line/LineChart.vue", - "content": "\n\n\n", + "content": "\n\n\n", "type": "registry:ui", "target": "" }, { "path": "ui/chart-line/index.ts", - "content": "export { default as LineChart } from './LineChart.vue'\n\nimport type { Spacing } from '@unovis/ts'\n\ntype KeyOf> = Extract\n\nexport interface BaseChartProps> {\n /**\n * The source data, in which each entry is a dictionary.\n */\n data: T[]\n /**\n * Select the categories from your data. Used to populate the legend and toolip.\n */\n categories: KeyOf[]\n /**\n * Sets the key to map the data to the axis.\n */\n index: KeyOf\n /**\n * Change the default colors.\n */\n colors?: string[]\n /**\n * Margin of each the container\n */\n margin?: Spacing\n /**\n * Change the opacity of the non-selected field\n * @default 0.2\n */\n filterOpacity?: number\n /**\n * Function to format X label\n */\n xFormatter?: (tick: number | Date, i: number, ticks: number[] | Date[]) => string\n /**\n * Function to format Y label\n */\n yFormatter?: (tick: number | Date, i: number, ticks: number[] | Date[]) => string\n /**\n * Controls the visibility of the X axis.\n * @default true\n */\n showXAxis?: boolean\n /**\n * Controls the visibility of the Y axis.\n * @default true\n */\n showYAxis?: boolean\n /**\n * Controls the visibility of tooltip.\n * @default true\n */\n showTooltip?: boolean\n /**\n * Controls the visibility of legend.\n * @default true\n */\n showLegend?: boolean\n /**\n * Controls the visibility of gridline.\n * @default true\n */\n showGridLine?: boolean\n}\n", + "content": "export { default as LineChart } from './LineChart.vue'\n\nimport type { Spacing } from '@unovis/ts'\n\ntype KeyOf> = Extract\n\nexport interface BaseChartProps> {\n /**\n * The source data, in which each entry is a dictionary.\n */\n data: T[]\n /**\n * Select the categories from your data. Used to populate the legend and toolip.\n */\n categories: KeyOf[]\n /**\n * Sets the key to map the data to the axis.\n */\n index: KeyOf\n /**\n * Change the default colors.\n */\n colors?: string[]\n /**\n * Margin of each the container\n */\n margin?: Spacing\n /**\n * Change the opacity of the non-selected field\n * @default 0.2\n */\n filterOpacity?: number\n /**\n * Function to format X label\n */\n xFormatter?: (tick: number | Date, i: number, ticks: number[] | Date[]) => string\n /**\n * Function to format Y label\n */\n yFormatter?: (tick: number | Date, i: number, ticks: number[] | Date[]) => string\n /**\n * Controls the visibility of the X axis.\n * @default true\n */\n showXAxis?: boolean\n /**\n * Controls the visibility of the Y axis.\n * @default true\n */\n showYAxis?: boolean\n /**\n * Controls the visibility of tooltip.\n * @default true\n */\n showTooltip?: boolean\n /**\n * Controls the visibility of legend.\n * @default true\n */\n showLegend?: boolean\n /**\n * Controls the visibility of gridline.\n * @default true\n */\n showGridLine?: boolean\n /**\n * Select the categories from your data. Used to preselection the legend.\n */\n selectedLegend?: KeyOf\n}\n", "type": "registry:ui", "target": "" } diff --git a/apps/www/src/registry/default/ui/chart-area/AreaChart.vue b/apps/www/src/registry/default/ui/chart-area/AreaChart.vue index bef62ffc3..375c7b2d7 100644 --- a/apps/www/src/registry/default/ui/chart-area/AreaChart.vue +++ b/apps/www/src/registry/default/ui/chart-area/AreaChart.vue @@ -50,7 +50,7 @@ const colors = computed(() => props.colors?.length ? props.colors : defaultColor const legendItems = ref(props.categories.map((category, i) => ({ name: category, color: colors.value[i], - inactive: false, + inactive: props.selectedLegend !== category && props.selectedLegend !== undefined, }))) const isMounted = useMounted() diff --git a/apps/www/src/registry/default/ui/chart-area/index.ts b/apps/www/src/registry/default/ui/chart-area/index.ts index 39ee5fde9..20120dd28 100644 --- a/apps/www/src/registry/default/ui/chart-area/index.ts +++ b/apps/www/src/registry/default/ui/chart-area/index.ts @@ -63,4 +63,8 @@ export interface BaseChartProps> { * @default true */ showGridLine?: boolean + /** + * Select the categories from your data. Used to preselection the legend. + */ + selectedLegend?: KeyOf } diff --git a/apps/www/src/registry/default/ui/chart-bar/BarChart.vue b/apps/www/src/registry/default/ui/chart-bar/BarChart.vue index c123fddfe..40aa7a60a 100644 --- a/apps/www/src/registry/default/ui/chart-bar/BarChart.vue +++ b/apps/www/src/registry/default/ui/chart-bar/BarChart.vue @@ -46,7 +46,7 @@ const colors = computed(() => props.colors?.length ? props.colors : defaultColor const legendItems = ref(props.categories.map((category, i) => ({ name: category, color: colors.value[i], - inactive: false, + inactive: props.selectedLegend !== category && props.selectedLegend !== undefined, }))) const isMounted = useMounted() diff --git a/apps/www/src/registry/default/ui/chart-bar/index.ts b/apps/www/src/registry/default/ui/chart-bar/index.ts index e3107a4d0..d4868d4cc 100644 --- a/apps/www/src/registry/default/ui/chart-bar/index.ts +++ b/apps/www/src/registry/default/ui/chart-bar/index.ts @@ -63,4 +63,8 @@ export interface BaseChartProps> { * @default true */ showGridLine?: boolean + /** + * Select the categories from your data. Used to preselection the legend. + */ + selectedLegend?: KeyOf } diff --git a/apps/www/src/registry/default/ui/chart-line/LineChart.vue b/apps/www/src/registry/default/ui/chart-line/LineChart.vue index 5bc80b9a5..40ac9398e 100644 --- a/apps/www/src/registry/default/ui/chart-line/LineChart.vue +++ b/apps/www/src/registry/default/ui/chart-line/LineChart.vue @@ -41,7 +41,7 @@ const colors = computed(() => props.colors?.length ? props.colors : defaultColor const legendItems = ref(props.categories.map((category, i) => ({ name: category, color: colors.value[i], - inactive: false, + inactive: props.selectedLegend !== category && props.selectedLegend !== undefined, }))) const isMounted = useMounted() diff --git a/apps/www/src/registry/default/ui/chart-line/index.ts b/apps/www/src/registry/default/ui/chart-line/index.ts index bb0a26f2b..2ca7475fd 100644 --- a/apps/www/src/registry/default/ui/chart-line/index.ts +++ b/apps/www/src/registry/default/ui/chart-line/index.ts @@ -63,4 +63,8 @@ export interface BaseChartProps> { * @default true */ showGridLine?: boolean + /** + * Select the categories from your data. Used to preselection the legend. + */ + selectedLegend?: KeyOf } diff --git a/apps/www/src/registry/new-york/ui/chart-area/AreaChart.vue b/apps/www/src/registry/new-york/ui/chart-area/AreaChart.vue index d95932bbe..699297033 100644 --- a/apps/www/src/registry/new-york/ui/chart-area/AreaChart.vue +++ b/apps/www/src/registry/new-york/ui/chart-area/AreaChart.vue @@ -50,7 +50,7 @@ const colors = computed(() => props.colors?.length ? props.colors : defaultColor const legendItems = ref(props.categories.map((category, i) => ({ name: category, color: colors.value[i], - inactive: false, + inactive: props.selectedLegend !== category && props.selectedLegend !== undefined, }))) const isMounted = useMounted() diff --git a/apps/www/src/registry/new-york/ui/chart-area/index.ts b/apps/www/src/registry/new-york/ui/chart-area/index.ts index 39ee5fde9..20120dd28 100644 --- a/apps/www/src/registry/new-york/ui/chart-area/index.ts +++ b/apps/www/src/registry/new-york/ui/chart-area/index.ts @@ -63,4 +63,8 @@ export interface BaseChartProps> { * @default true */ showGridLine?: boolean + /** + * Select the categories from your data. Used to preselection the legend. + */ + selectedLegend?: KeyOf } diff --git a/apps/www/src/registry/new-york/ui/chart-bar/BarChart.vue b/apps/www/src/registry/new-york/ui/chart-bar/BarChart.vue index 692dd73e4..09259b1fc 100644 --- a/apps/www/src/registry/new-york/ui/chart-bar/BarChart.vue +++ b/apps/www/src/registry/new-york/ui/chart-bar/BarChart.vue @@ -46,7 +46,7 @@ const colors = computed(() => props.colors?.length ? props.colors : defaultColor const legendItems = ref(props.categories.map((category, i) => ({ name: category, color: colors.value[i], - inactive: false, + inactive: props.selectedLegend !== category && props.selectedLegend !== undefined, }))) const isMounted = useMounted() diff --git a/apps/www/src/registry/new-york/ui/chart-bar/index.ts b/apps/www/src/registry/new-york/ui/chart-bar/index.ts index e3107a4d0..d4868d4cc 100644 --- a/apps/www/src/registry/new-york/ui/chart-bar/index.ts +++ b/apps/www/src/registry/new-york/ui/chart-bar/index.ts @@ -63,4 +63,8 @@ export interface BaseChartProps> { * @default true */ showGridLine?: boolean + /** + * Select the categories from your data. Used to preselection the legend. + */ + selectedLegend?: KeyOf } diff --git a/apps/www/src/registry/new-york/ui/chart-line/LineChart.vue b/apps/www/src/registry/new-york/ui/chart-line/LineChart.vue index ded986d9b..92b451e83 100644 --- a/apps/www/src/registry/new-york/ui/chart-line/LineChart.vue +++ b/apps/www/src/registry/new-york/ui/chart-line/LineChart.vue @@ -41,7 +41,7 @@ const colors = computed(() => props.colors?.length ? props.colors : defaultColor const legendItems = ref(props.categories.map((category, i) => ({ name: category, color: colors.value[i], - inactive: false, + inactive: props.selectedLegend !== category && props.selectedLegend !== undefined, }))) const isMounted = useMounted() diff --git a/apps/www/src/registry/new-york/ui/chart-line/index.ts b/apps/www/src/registry/new-york/ui/chart-line/index.ts index bb0a26f2b..2ca7475fd 100644 --- a/apps/www/src/registry/new-york/ui/chart-line/index.ts +++ b/apps/www/src/registry/new-york/ui/chart-line/index.ts @@ -63,4 +63,8 @@ export interface BaseChartProps> { * @default true */ showGridLine?: boolean + /** + * Select the categories from your data. Used to preselection the legend. + */ + selectedLegend?: KeyOf }