Giter VIP home page Giter VIP logo

Comments (8)

y-takey avatar y-takey commented on May 22, 2024 5

Hi @benmccann , Thank you for telling me about chart.js@3 🎉
I would like to update this plugin in the near future!

from chartjs-plugin-stacked100.

jagdaleganesh avatar jagdaleganesh commented on May 22, 2024 1

Hi , I would like to use this plugin. How I can use with latest ChartJS version. I need to register the plugin first before use.
Please let me know how I can use the it with latest chartjs version.
In case this plugin is not yet updated, is there any workaround to use with latest chartjs version.

@y-takey , I am waiting for your reply.

Thanks,

from chartjs-plugin-stacked100.

y-takey avatar y-takey commented on May 22, 2024 1

published [email protected] supported Chart.js@3 :)
It has breaking change. you need register the plugin manualy.

import { Chart } from "chart.js";
import ChartjsPluginStacked100 from "chartjs-plugin-stacked100";

Chart.register(ChartjsPluginStacked100);

from chartjs-plugin-stacked100.

y-takey avatar y-takey commented on May 22, 2024

Hi @jagdaleganesh , thanks for the request :)
It is WIP now, so please wait a little more.

from chartjs-plugin-stacked100.

jagdaleganesh avatar jagdaleganesh commented on May 22, 2024

Thank you

from chartjs-plugin-stacked100.

mkismy avatar mkismy commented on May 22, 2024

Using the example on readme via CDN, it does not work as expected and become a normal bar chart.

<div style="width: 700px; height: 300px">
  <canvas id="my-chart"></canvas>
</div>

<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chartjs-plugin-stacked100"></script>
<script type="text/javascript">
Chart.register(ChartjsPluginStacked100);

new Chart(document.getElementById("my-chart"), {
  type: "bar",
  data: {
    labels: ["Foo", "Bar"],
    datasets: [
      { label: "bad", data: [5, 25], backgroundColor: "rgba(244, 143, 177, 0.6)" },
      { label: "better", data: [15, 10], backgroundColor: "rgba(255, 235, 59, 0.6)" },
      { label: "good", data: [10, 8], backgroundColor: "rgba(100, 181, 246, 0.6)" }
    ]
  },
  options: {
    indexAxis: "y",
    plugins: {
      stacked100: { enable: true }
    }
  }
});
</script>

image

When adding stacked option, the bar stacks but doesn't become a 100% stacked bar.

  options: {
    indexAxis: "y",
    scales: {
      x: { stacked: true },
      y: { stacked: true },
    },
    plugins: {
      stacked100: { enable: true }
    }
  }

image

@y-takey Can you check if there are anything wrong with the code above?

from chartjs-plugin-stacked100.

y-takey avatar y-takey commented on May 22, 2024

@mkismy Thanks for the issue :)
Sorry, the example was wrong. here is correctly example.

Chart.register(ChartjsPluginStacked100.default);  // HERE!

new Chart(document.getElementById("my-chart"), {
  type: "bar",
  data: {
    labels: ["Foo", "Bar"],
    datasets: [
      { label: "bad", data: [5, 25], backgroundColor: "rgba(244, 143, 177, 0.6)" },
      { label: "better", data: [15, 10], backgroundColor: "rgba(255, 235, 59, 0.6)" },
      { label: "good", data: [10, 8], backgroundColor: "rgba(100, 181, 246, 0.6)" }
    ]
  },
  options: {
    indexAxis: "y",
    plugins: {
      stacked100: { enable: true }
    }
  }
});

I will fix readme later.

from chartjs-plugin-stacked100.

mkismy avatar mkismy commented on May 22, 2024

Thank you 😁

from chartjs-plugin-stacked100.

Related Issues (20)

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.