Giter VIP home page Giter VIP logo

Comments (8)

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

Maybe you don't need the .d.ts file.
Can you try like below code?

import React, { useEffect, useState } from 'react';
import { Chart } from 'react-chartjs-2';
import ChartjsPluginStacked100 from "chartjs-plugin-stacked100";

Chart.register(ChartjsPluginStacked100); // ★add this line

const ConnectedTime = () => {
  return <>
      {
	<div>
	    <Chart // ★change component name
	      type="bar"
	      data={{}}
	      options={{}} />
	</div>
      }
  </>
}

from chartjs-plugin-stacked100.

ucorpintegration avatar ucorpintegration commented on May 22, 2024

Hello @y-takey ,

This is now the code:

import React, { useEffect, useState } from 'react';
import { Chart } from 'react-chartjs-2';
import ChartjsPluginStacked100 from 'chartjs-plugin-stacked100';
Chart.register(ChartjsPluginStacked100); //

const ConnectedTime = () => {
  // https://designcode.io/react-hooks-handbook-usestate-hook
  // https://designcode.io/react-hooks-handbook-fetch-data-from-an-api
  useEffect(() => {   }, []);
  return <>
      {
        <div>
            <Chart                // IDE Warning at this line
              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 }
                }
              }} />
        </div>
      }
  </>
}
export default ConnectedTime

I still get:

Could not find a declaration file for module 'chartjs-plugin-stacked100'. '/home/mihamina/.../node_modules/chartjs-plugin-stacked100/build/index.js' implicitly has an 'any' type.

Plus, my IDE warns me about "Chart" could not be used as a JSX component.

from chartjs-plugin-stacked100.

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

Hello @ucorpintegration , thanks for the reply :)

Do you use typescript?

from chartjs-plugin-stacked100.

ucorpintegration avatar ucorpintegration commented on May 22, 2024

@y-takey , Yes I do. Is this the reason of the failure?

from chartjs-plugin-stacked100.

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

No, maybe i failured compile the plugin.
Could you try below code?

import React, { useEffect, useState } from 'react';
import { Bar } from 'react-chartjs-2';
import ChartjsPluginStacked100 from 'chartjs-plugin-stacked100';

const ConnectedTime = () => {
  // https://designcode.io/react-hooks-handbook-usestate-hook
  // https://designcode.io/react-hooks-handbook-fetch-data-from-an-api
  useEffect(() => {   }, []);
  return <>
      {
        <div>
            <Bar   // CHANGE
              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)" }]        
              }}
              plugins={[ChartjsPluginStacked100]}  // ADD
              options={{ 
                indexAxis: "y",
                plugins: {
                  stacked100: { enable: true }
                }
              }} />
        </div>
      }
  </>
}

from chartjs-plugin-stacked100.

rakotomandimby avatar rakotomandimby commented on May 22, 2024

Hello @y-takey , here is a PR in order to make it work ;-)

from chartjs-plugin-stacked100.

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

Hello @rakotomandimby , thanks your PR :)
merged the PR for now.

from chartjs-plugin-stacked100.

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

I published declaration files for typescript in version 1.0.4, so you don't need your declaration file now.

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.