question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Multiple charts on one page

See original GitHub issue

Expected Behavior

Interacting with a chart will only affect that specific chart

Actual Behavior

Interacting with a chart affects all charts on a page

yacht-chart-filtering

Environment

  • vue.js version: vue@2.6.11
  • vue-chart.js version: vue-chartjs@3.5.0
  • chart.js version: chart.js@2.9.3
  • npm version: 6.14.7

Here is the code for my chart component:

<script>
import { mixins, Bar } from "vue-chartjs"; // We specify what type of chart we want from vue-chartjs and the mixins module
const { reactiveProp } = mixins;
export default {
  extends: Bar, //We are extending the base chart class as mentioned above
  mixins: [reactiveProp],
  props: {
    chartdata: {
      type: Object,
      default: null,
    },
  },
  data() {
    return {
      options: {
        responsive: true,
        animation: {
          duration: 0,
        },
        scales: {
          yAxes: [
            {
              ticks: {
                beginAtZero: true,
                stepSize: 1,
                min: 0,
                max: 100,
                maxTicksLimit: 5
              },
            },
          ],
        },
      },
    };
  },
 mounted() {
    this.renderChart(this.chartData, this.options);
  },
};
</script>

Here is the code for the page I’m rendering them on: https://github.com/SelfhostedPro/Yacht/blob/master/frontend/src/views/Home.vue (I would paste it but it’s quite long)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
croftmancommented, Aug 16, 2021

Did you try to add a unique ID on the chart? You can use the chartId prop, by default multiple charts on the same page have same id

1reaction
aperturelesscommented, Sep 22, 2020

Well, its hard to reproduce. Multiple charts can be controlled tho: https://codesandbox.io/s/boring-thompson-ddl5g?file=/src/App.vue

Read more comments on GitHub >

github_iconTop Results From Across the Web

Multiple charts in one page with chart.js - Stack Overflow
When I only have one chart, nothing's gone wrong, but when I try to add one more chart, my charts become so large...
Read more >
How to display multiple charts in one chart sheet? - ExtendOffice
You can move and display multiple charts in one chart sheet with following steps: 1. Create a chart sheet that you want to...
Read more >
Draw Multiple Charts | Google Developers
This page shows how to draw multiple charts on one web page. Draw Multiple Charts on One Page. If you want to draw...
Read more >
Render Multiple Charts in a Page - CanvasJS.com
Step1: Position the chart container wherever the chart is supposed to be rendered in the page, with separate chart-container id for each chart....
Read more >
Create and use Multiple charts in one page with chart.js
Create and use Multiple charts in one page with chart.js - Javascript Chart.js · Description · Demo Code · Related Tutorials.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found