-
-
Notifications
You must be signed in to change notification settings - Fork 838
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MixChart in documentation #1013
Comments
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 <template>
<bar-chart :data="mixedChartData" :options="mixedChartOptions"></bar-chart>
</template>
<script lang="ts">
import {
BarController,
BarElement,
CategoryScale,
Chart as ChartJS,
ChartData,
ChartOptions,
LinearScale,
LineController,
LineElement,
PointElement,
Title,
Tooltip,
} from 'chart.js';
import { computed, defineComponent, PropType } from 'vue';
import { Bar as BarChart } from 'vue-chartjs';
ChartJS.register(
BarController,
BarElement,
CategoryScale,
LinearScale,
LineController,
LineElement,
PointElement,
Title,
Tooltip
);
export default defineComponent({
name: 'BarAndLineChart',
components: {
BarChart,
},
props: {
chartData: {
type: Object as PropType<ChartData<'bar' | 'line'>>,
required: true,
},
chartOptions: {
type: Object as PropType<ChartOptions<'bar' | 'line'>>,
required: true,
},
},
setup(props) {
const mixedChartData = computed(() => {
// HACK ALERT! masquerading as ChartData<'bar'> so that the typed Bar chart doesn't freak out
return props.chartData as ChartData<'bar'>;
});
const mixedChartOptions = computed(() => {
// HACK ALERT! masquerading as ChartOptions<'bar'> so that the typed Bar chart doesn't freak out
return props.chartOptions as ChartOptions<'bar'>;
});
return {
mixedChartData,
mixedChartOptions,
};
},
});
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: