You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I spent a few hours on this and finally ended up using this hack because I couldn't figure out how to properly extend the Bar chart in a way that allows it to accept 'bar' | 'line' data and options. The resulting chart does work as expected, but I'm not happy with the hack. Shirley, there has to be a better way...
<template><bar-chart :data="mixedChartData" :options="mixedChartOptions"></bar-chart></template><scriptlang="ts">import{BarController,BarElement,CategoryScale,ChartasChartJS,ChartData,ChartOptions,LinearScale,LineController,LineElement,PointElement,Title,Tooltip,}from'chart.js';import{computed,defineComponent,PropType}from'vue';import{BarasBarChart}from'vue-chartjs';ChartJS.register(BarController,BarElement,CategoryScale,LinearScale,LineController,LineElement,PointElement,Title,Tooltip);exportdefaultdefineComponent({name: 'BarAndLineChart',components: {
BarChart,},props: {chartData: {type: ObjectasPropType<ChartData<'bar'|'line'>>,required: true,},chartOptions: {type: ObjectasPropType<ChartOptions<'bar'|'line'>>,required: true,},},setup(props){constmixedChartData=computed(()=>{// HACK ALERT! masquerading as ChartData<'bar'> so that the typed Bar chart doesn't freak outreturnprops.chartDataasChartData<'bar'>;});constmixedChartOptions=computed(()=>{// HACK ALERT! masquerading as ChartOptions<'bar'> so that the typed Bar chart doesn't freak outreturnprops.chartOptionsasChartOptions<'bar'>;});return{
mixedChartData,
mixedChartOptions,};},});</script>
Would you like to work on this feature?
What problem are you trying to solve?
There is no documentation on mixchart, for example when we want several line charts and one bar chart.
Describe the solution you'd like
I'd like an example to show how it's possible, as it's possible in chartJS, the basic library.
Describe alternatives you've considered
No response
Documentation, Adoption, Migration Strategy
No response
The text was updated successfully, but these errors were encountered: