Giter Club home page Giter Club logo

chart-js-fabric's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

chart-js-fabric's Issues

Option for replacing options dynamically

Is it possible to replace option/data dynamically? Right now the options are merged.

If I have an array of data of length 5, setting the data like object.set({ chart: { data: [2] }) will not remove the other 4 entries.

Thanks for the nice package.

Tooltips callbacks doesn't work

Hi, i've tried to set a label using callbacks funcction, but i'm getting errors. Am i doing something wrong or is it an issue with library?

const chart = new fabric.Chart(options as fabric.IChartConfiguration);

  chart.set({
    chart: {
      options: {
        tooltips: {
          callbacks: {
            label: function (tooltipItem, data) {
              let total = 0;
              data.datasets[tooltipItem.datasetIndex].data.forEach((item) => {
                total += Number(item);
              });

              const label = data.datasets[tooltipItem.datasetIndex].label;
              return `${label}: ${tooltipItem.yLabel} of ${total}`;
            },
          },
        },
      },
    },
  });

image

Dynamic update data for chart in canvas

Hello, thank you for your great work.
I am able to connect fabric.js with chart.js by using your library. The chart is rendered pretty smooth.
Now I want to update the chart's data dynamically by user input, but the chart is not re-rendered again.
I have checked the chart's chart property and can see that all the data are updated correctly, but for some reason it is not displayed in the canvas.

Here is the function I am using for update data. Is there anything missed, thank you for your help 😄

updateChartData: function(dataset, labels){
    const canvas = CommonHandlers.getCanvas();
    const currentChart = canvas.getActiveObject();
    if (currentChart) {
      currentChart.set('chart', {
        data: {
          labels: labels,
          datasets: dataset.map(row => ({
            label: '# of Votes',
            data: row.map(item => parseFloat(item.value)),
            backgroundColor: [
              'rgba(255, 99, 132, 0.2)',
              'rgba(54, 162, 235, 0.2)',
              'rgba(255, 206, 86, 0.2)'
            ],
            borderColor: [
              'rgba(255, 99, 132, 1)',
              'rgba(54, 162, 235, 1)',
              'rgba(255, 206, 86, 1)'
            ],
            borderWidth: 1
          })),
        }
      });
    }
    canvas.renderAll();
  }

latest Chart.js version

Hi,

Thanks for the great package.

Can you add latest chart-js version ? I noticed the version is in this library is - "chart.js": "^2.9.3" .

Is there any way i can update the version of chart js used in this package to the current version - "chart.js": "^4.2.1" ?

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.