-
-
Notifications
You must be signed in to change notification settings - Fork 837
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
Mixed chart types support #1048
Comments
Bumping this. |
Such a brilliant answer! This example have to be included in documentation 🙏🏻 |
In case someone is stuck with typescript error: you need to uncomment the "other" type declaration so if you are using only leave the "line" type for combining bar and line charts
|
Thanks to the people above for figuring this out! However, type support is still needed and @raam86 's suggestion didn't work for me. Here is my implementation where I have to use Note: This also happens to be an example of using multiple axes <template>
<Bar :data="chartData" :options="options" />
</template>
<script setup lang="ts">
import { computed, ref } from "vue";
import { Bar } from "vue-chartjs";
const options = ref<any>({
scales: {
ybar: {
type: "linear",
position: "left",
},
yline: {
type: "linear",
position: "right",
},
},
});
const datasets = computed(() => {
let toPlot= [];
// This is the bar graph
toPlot.push({
label: <bar label>,
data: <bar data>,
yAxisID: "ybar",
});
// This is the line graph
toPlot.push({
type: "line",
label: <line label>,
data: <line data>,
yAxisID: "yline",
});
return toPlot;
});
// HERE I need to use `any` to be able to pass into the Bar :data prop
const chartData = computed<any>(() => {
return { labels: <my labels>, datasets: datasets.value };
});
</script> |
Would you like to work on this feature?
What problem are you trying to solve?
I have a type issue when I try to mix chart types
Describe the solution you'd like
I would like a specific , preferably typed way, of mixing chart types.
As shown in official documentation of ChartJS: https://www.chartjs.org/docs/latest/charts/mixed.html
Describe alternatives you've considered
Access the underlying chart JS instance and manually add my own data
Documentation, Adoption, Migration Strategy
The text was updated successfully, but these errors were encountered: