Using Chart.JS in React.JS - A Complete Tutorial (2020)

Поділитися
Вставка
  • Опубліковано 23 вер 2024

КОМЕНТАРІ • 151

  • @WornOffKeys
    @WornOffKeys  3 роки тому +2

    🔥 Get the code here:
    github.com/AlexzanderFlores/ChartJS-in-React
    🙋‍♂ Need help? Ask in our Discord community:
    wornoffkeys.com/discord

    • @sureshmakwana8709
      @sureshmakwana8709 3 роки тому +1

      7:04 cannot see the bar on web.... Makes me so angry and upset as I've followed all the steps he said
      I think I'll have to find some another video on UA-cam plus very low voice's volume in the video which was very irritating too

    • @ShivamSharma-rq9ne
      @ShivamSharma-rq9ne 2 роки тому

      pin the comment which explains the version error. you instead has this promotional thing as pinned. one disliking the video only cause of your sheer negligence.

    • @ranati2000
      @ranati2000 2 роки тому

      @@sureshmakwana8709 same issue

    • @jublirajshelton
      @jublirajshelton 2 роки тому +3

      Need to use the following code in the latest version.
      import {Chart as ChartJS, BarElement, CategoryScale, LinearScale} from 'chart.js'
      ChartJS.register(
      CategoryScale,
      LinearScale,
      BarElement
      )

  • @SuperSayiyajin
    @SuperSayiyajin 2 роки тому +3

    Thanks. If you have problem about map or category not found. add this line to your bar component
    import { Chart as ChartJS } from 'chart.js/auto'

  • @barncha
    @barncha 3 роки тому +17

    You're a natural at teaching, thank you so much for this tutorial! It was a great help!

    • @WornOffKeys
      @WornOffKeys  3 роки тому +1

      Thank you and glad I could help!

    • @ferdinand4881
      @ferdinand4881 3 роки тому

      @@WornOffKeys hi can you do a tutorial on react-vis?

  • @MikeCerna309
    @MikeCerna309 3 роки тому +6

    Been looking for how to use chartsjs all night long and found your vid...very detailed, and a lot of patience plus good methodology to explain things.
    I learned a lot and got very interested into keep reading the documentation...thank you very much and keep up the good work!
    Regards from Lima, Peru!
    Ps. You just got a new subscriber :)

  • @c4syner
    @c4syner 2 роки тому +7

    For anyone getting errors try this fix:
    npm install react-chartjs-2@2.9.0
    npm install chart.js
    npm install react
    npm instal react-dom
    The various other "fixes" recommended here gave me random dependency errors as well as blank screens.

    • @jennaprice5563
      @jennaprice5563 2 роки тому

      Unfortunately this did not work and threw a ton of errors: Attempted import error: 'chart.js' does not contain a default export (imported as 'Chart')
      Here is my dependency list:
      "dependencies": {
      "@testing-library/jest-dom": "^5.16.5",
      "@testing-library/react": "^13.3.0",
      "@testing-library/user-event": "^13.5.0",
      "chart.js": "^3.9.1",
      "react": "^18.2.0",
      "react-chartjs-2": "^2.9.0",
      "react-dom": "^18.2.0",
      "react-scripts": "5.0.1",
      "web-vitals": "^2.1.4"
      },

    • @yurikkkj3940
      @yurikkkj3940 2 роки тому

      man you literally save my life, i was trying this in like last 2 weeks but with your coment i made what i want, so thx man

  • @afshinmoshrefi
    @afshinmoshrefi 3 роки тому +45

    To make sure tutorial works, you have to force chart.js to install version 2.x - the instructions will default to installing chart.js version 3.x which is not compatible with react-chartjs-2. Following installation worked for me:
    npm install --save react-chartjs-2 chart.js@2.9.4

    • @l3aIIin23
      @l3aIIin23 3 роки тому +1

      Thank you!!!!

    • @ajexzetia3878
      @ajexzetia3878 3 роки тому

      Thank you so much

    • @vetrivel-yx2on
      @vetrivel-yx2on 3 роки тому

      This comment should be pinned
      Thank you

    • @vetrivel-yx2on
      @vetrivel-yx2on 3 роки тому

      How did you find that chart js version is the issue?
      Could you please explain

    • @afshinmoshrefi
      @afshinmoshrefi 3 роки тому +2

      @@vetrivel-yx2on I read about the new release of chart.js 3 and that there were breaking changes specifically it no longer exports the chart class as a default export. That is when I looked into versioning and it turned out to be the issue.

  • @dimabernada1809
    @dimabernada1809 3 роки тому +2

    Excellent tutorial, thank you so much, essentially and very fast, one of the best tutorial I have ever seen

  • @paramshendekar8163
    @paramshendekar8163 2 роки тому +6

    This tutorial works well with previous versions, now the documentation has changed and we need to do things differently than before. If you wish to follow this version, make sure you install the very same version

    • @ritveak
      @ritveak 2 роки тому

      Did you get it running?
      Can you help?

  • @amirjosevelasquezaburdene4318
    @amirjosevelasquezaburdene4318 2 роки тому +1

    Awesome video, thanks!!! Keep going

  • @EminoMeneko
    @EminoMeneko 3 роки тому

    Very cool.
    Well explained and I loved the bit about documentation. Too few people do this.

  • @sonalisahoo5953
    @sonalisahoo5953 3 роки тому

    If your graph doesnt work, you can try out - yarn add react-chartjs-2@2.9.4 , It gives the prompt in terminal that 2.9.4 doesnt match, so then u could choose 2.9.0. And it works!

  • @ranati2000
    @ranati2000 2 роки тому +4

    I am having three kind of different errors in console and the chart isnt showing:
    Errors:
    1) Uncaught Error: "bar" is not a registered element.
    2) Uncaught Error: Canvas is already in use. Chart with ID '0' must be destroyed before the canvas can be reused.
    3) The above error occurred in the component:
    My Code:
    import React from 'react'
    import { Bar } from 'react-chartjs-2'
    export const BarChart = () => {
    return(

    Bar Chart


    )
    }

  • @almirsilva838
    @almirsilva838 10 місяців тому

    Very good! Very useful!

  • @vivekknShots
    @vivekknShots 2 роки тому +3

    TypeError: Cannot read properties of undefined (reading 'map') is anyone getting this error

  • @EnaGena
    @EnaGena 2 роки тому +2

    it doesnt work

  • @ramandamytv1193
    @ramandamytv1193 Рік тому

    thank you so much! awesome tut!!

  • @deepwebtube
    @deepwebtube 3 роки тому

    Thank you sir for this video! Simply invaluable!!!

  • @leo-fv2nv
    @leo-fv2nv 3 роки тому

    Thank you so much 😍 😍 u really saved me.... As beginner it is really helpful.....

  • @robinbreed2439
    @robinbreed2439 Рік тому

    great tutorial!

  • @krishnadhingra2723
    @krishnadhingra2723 2 роки тому

    great video! loved it!

  • @pshr2447
    @pshr2447 3 роки тому

    i love chart js man data is beautiful

  • @graziacassano9263
    @graziacassano9263 3 роки тому

    Damn man! Finally a tutorial very well explained! Thank you so much. Can't wait to watch other videos. Do you have any on node and fs modules?

  • @devtom2060
    @devtom2060 3 роки тому

    Looks simple, thanks!

  • @sergeos5
    @sergeos5 3 роки тому +6

    What do you recommend to look so that the data can be taken from the SQL source?

    • @Eclipse-san
      @Eclipse-san 3 роки тому

      You can make a backend API that uses sequelize to return data.
      And you can then use axios to send a request to your API. Happy coding

    • @sergeos5
      @sergeos5 3 роки тому

      @@Eclipse-san can you help me in that question, my friend?

  • @blackhoody3113
    @blackhoody3113 2 роки тому +1

    Why my chart do not shows in chrome? I wrote code as you did and only got white screen. When trying to show some text like Hell World, it shows as it should. So what might be the problem here?

  • @dalelanto895
    @dalelanto895 3 роки тому +1

    Hi can anyone help me uninstall react-chart-js@3.0.3 because i could not install version 2.9.3, it says could not resolve dependency peer chart.js@"^3.1.0" from react-chartjs-2@3.0.3, thank you in advance

  • @sheikhyabooti8960
    @sheikhyabooti8960 3 роки тому

    clearly the best

  • @afshinmoshrefi
    @afshinmoshrefi 3 роки тому

    Thanks for the tutorial. It is excellent.

  • @dedx4094
    @dedx4094 3 роки тому

    thanks!. really helped me in my project.

  • @hplaptop2286
    @hplaptop2286 2 роки тому +1

    Hello
    If it's possible,could you please put videos in a dropdown box with options like weekly,monthly,yearly?

  • @IVIattyHD
    @IVIattyHD 3 роки тому +1

    great vid thank you!

  • @donatoalvarez3027
    @donatoalvarez3027 3 роки тому

    Just install the v3 chartjs now works.

  • @pratikpowale9657
    @pratikpowale9657 2 роки тому

    Thank u so much brother!

  • @Zahra-uc2xq
    @Zahra-uc2xq Рік тому

    really helpful thank you

  • @Dmitriy_Sentinel
    @Dmitriy_Sentinel 3 роки тому

    My English is poor. But what the author of the video said - I understood absolutely everything))

    • @WornOffKeys
      @WornOffKeys  3 роки тому +2

      Glad to hear that!

    • @Dmitriy_Sentinel
      @Dmitriy_Sentinel 3 роки тому

      @@WornOffKeys Сan you tell me, my page is not refreshed when saving an App.js - Updates occur only when the restart project. As I understand it, it is default in React.js page reload and saving changes?

  • @SuperSayiyajin
    @SuperSayiyajin 2 роки тому +1

    Can we create 3d bar(column) chart with using Chart.js?

  • @Onomandah
    @Onomandah 3 роки тому

    Thank you! We really appreciate it!

    • @WornOffKeys
      @WornOffKeys  3 роки тому

      No problem, glad the video helped!

  • @darshang7133
    @darshang7133 3 роки тому +1

    Hey how do i import CSV file and plot it ?

  • @jayakrishnad7318
    @jayakrishnad7318 3 роки тому

    Very good explanation

  • @naumanshigri
    @naumanshigri 2 роки тому

    oakoran tong hay momo rozi. thank you very much

  • @mohammadjavadaghazadehfard7873
    @mohammadjavadaghazadehfard7873 2 роки тому

    Hi, Thanks 🙏 That's very cool 👌🌹 . please make more videos like this 🙏🙏🌹🌹 . Good luck 🙏

  • @ajexzetia3878
    @ajexzetia3878 3 роки тому

    Thanks bro, your tutorial help me

  • @Nefarious_Production
    @Nefarious_Production 3 роки тому +2

    is it possible for you to make the channel specific commands to you're advanced command handler

    • @WornOffKeys
      @WornOffKeys  3 роки тому

      Yes, this is something I plan on adding to the new revamped command handler once it comes out

  • @ajbleas
    @ajbleas 3 роки тому +2

    NOTE: HAVING ISSUES WITH "DEFAULT"? npm uninstall chart.js and run npm install chart.js@2.9 . THIS FIXED MINE

    • @jackgong7658
      @jackgong7658 3 роки тому

      THANK YOU OMG

    • @ShiyunLian
      @ShiyunLian 3 роки тому

      You save my life

    • @dalelanto895
      @dalelanto895 3 роки тому +2

      could not install --save react-chartjs-2 chart.js@2.9.4 it always says to me peer depency error, and whenever i try to force install it i get this other error : module not found can't resolve chart.js/auto, can anyone help me pls

  • @erickgeneric
    @erickgeneric 3 роки тому

    Amazing. Thank you

  • @petermashine1483
    @petermashine1483 2 роки тому

    i have error : " Uncaught TypeError: Cannot read properties of undefined (reading 'map') " .
    what does it mean?

  • @JassarDev
    @JassarDev 3 роки тому

    Well done 👏 Thank you!

  • @ChrisMochinskiMusic
    @ChrisMochinskiMusic 2 роки тому

    Very interesting - I'm certain my syntax matches but I'm having no luck on the font size around the 17-minutes mark. I'm flying my chart page into a parent page in React. I wonder if perhaps there's a parent font setting that's killing this option? The parent page is kind of convoluted. Thoughts? Thanks!

  • @ItsNoahHi
    @ItsNoahHi 3 роки тому +1

    my chart renders multiple times. does anyone know why by any chance?

  • @PIDOtomasyon
    @PIDOtomasyon 3 роки тому +2

    07:06, I want to use mysql datas for generating charts in HTML page. not PHP. Urgent please. I can show mysql data in html table, but not convert to chart.
    Thank you so much.

    • @WornOffKeys
      @WornOffKeys  3 роки тому +1

      Hey, you will need to use a web server to populate the HTML page with your data from your MySQL server and then send that HTML page to the client. This is done in PHP or Node.JS typically.

    • @PIDOtomasyon
      @PIDOtomasyon 3 роки тому +1

      @@WornOffKeys
      I am using node.js, at app.js I am sending sql datas to second page as:
      (app.js)
      app.get('/chart',(req, res) => {
      let sql = `SELECT * FROM results`;
      let query = connection.query(sql, (err, rows) => {
      if(err) throw err;
      res.render('user_resultChart', {
      title : 'RAPORLAMA',
      users : rows
      });
      });
      });
      I can response at second page as :
      (chart.ejs)









      How can I use in Chart. I want to convert to Chart.
      I need to use HTML page(Because I can't install php server on the PC)
      Thank you.

  • @subhamsaurabh3069
    @subhamsaurabh3069 3 роки тому

    great explanation 👍👍

  • @peaichunong3069
    @peaichunong3069 Рік тому

    Hi, thanks for this tutorial. It is very useful.
    May I know for the dataset, is that possible to have a range as data?
    Like from Jan-Sep, to make it something like a range chart or gantt chart? Is that possible?

  • @nguyenminhkhoa5613
    @nguyenminhkhoa5613 2 роки тому

    Great course, but when I create 2nd and 3nd chart, its dont show "Lable name", its only show "undefined"

  • @siel1374
    @siel1374 2 роки тому +5

    npm uninstall react-chartjs-2 chart.js
    npm install --save react-chartjs-2@2.11.1 chart.js@2.9.4

    • @SydAliHsn
      @SydAliHsn 2 роки тому +1

      THANKS bor loooove youuu

    • @siel1374
      @siel1374 2 роки тому

      @@SydAliHsn ♥️

  • @yateshchhabra6224
    @yateshchhabra6224 3 роки тому

    Hey mate,
    I am trying to make multi line graph using chart.js in which i want to add label above and at the left of the horizontal line in which some text is shown in that

  • @timothyroy20111
    @timothyroy20111 3 роки тому +3

    7:21 For some reason, I see a blank screen. Here's what my code looks like in the BarChart.js:
    import React from "react";
    import { Bar } from "react-chartjs-2";
    const BarChart = () => {
    return (


    Some Dat

    );
    };
    export default BarChart;

    • @LMKz1
      @LMKz1 3 роки тому

      Background color is need

    • @ganeshtarone1936
      @ganeshtarone1936 2 роки тому +2

      Did you got the solution for this?

  • @ibrahimacanada
    @ibrahimacanada 3 роки тому

    Good tutorial !!

  • @manastripathi2407
    @manastripathi2407 3 роки тому

    Amazing. subscribed.

  • @유수정-v5q
    @유수정-v5q 3 роки тому

    Thank you soooo much!

  • @sureshmakwana8709
    @sureshmakwana8709 3 роки тому +2

    7:04 cannot see the bar on web.... Makes me so angry and upset as I've followed all the steps he said
    I think I'll have to find some another video on UA-cam plus very low voice's volume in the video which was very irritating too

    • @soumyagarg4768
      @soumyagarg4768 3 роки тому +2

      Try doing
      yarn add react-chartjs-2@2.9.4 , then select 2.9.0 from the options.
      npm i chart.js

  • @devcj8962
    @devcj8962 Рік тому

    How could you make it responsive for mobile?

  • @chaitanyadani4273
    @chaitanyadani4273 2 роки тому

    I am having issues with the bar chart. It is saying cannot read properties of undefined.(reading map).

  • @GauChymTo
    @GauChymTo 2 роки тому

    year. I want to get into making soft on desktop because it offers more features but I have just been preferring the softow of mobile apps

  • @yuecheng3508
    @yuecheng3508 3 роки тому +1

    how do you know the name is ''react-chartjs-2''? I cannot import it

    • @hamidnaeimi2828
      @hamidnaeimi2828 3 роки тому +1

      npm install --save react-chartjs-2 chart.js

    • @yuecheng3508
      @yuecheng3508 3 роки тому +1

      @@hamidnaeimi2828 thanks!!

  • @arshadrauff4549
    @arshadrauff4549 3 роки тому

    Thanks!!

  • @venkatram3225
    @venkatram3225 3 роки тому

    HI,How to use container in the same program.Could you please produce a code

  • @chandraroy8254
    @chandraroy8254 2 роки тому

    This solved the same issue for me...
    import { Chart } from 'chart.js'
    Chart.defaults.plugins.legend.display = false

  • @prakashd842
    @prakashd842 3 роки тому

    Excellent

  • @diegocueva4141
    @diegocueva4141 3 роки тому

    PLease, I get linear graphic and not curved, do you know why?

  • @weblord2174
    @weblord2174 2 роки тому

    I'm following these tutorial and I have everything working until I start adding the elements from Chart JS 2. They are simply not displaying.

  • @gingerrcat
    @gingerrcat 2 роки тому

    Hi, how do you do this with data from api? :)

  • @rezaz7167
    @rezaz7167 3 роки тому

    5:04 what kind of extension does this code beautify-er? (adding space around 'Bar')

    • @WornOffKeys
      @WornOffKeys  3 роки тому

      That is the VSCode extension "Prettier"

  • @ferdinand4881
    @ferdinand4881 3 роки тому

    Hi can you do a tutorial on react-vis?

  • @vikrantgupta7896
    @vikrantgupta7896 3 роки тому

    Perfect

  • @mariuszyszczarz5305
    @mariuszyszczarz5305 3 роки тому

    Thanks!

  • @charlesobasi1991
    @charlesobasi1991 2 роки тому

    Can you create a histogram with chartjs?

  • @mehdisheikh627
    @mehdisheikh627 2 роки тому

    thanks for veryyyy good comtent
    😘😘😘😘😊😊😊😊😉😉😉😉✌✌✌✌

  • @viniciusfrasson4628
    @viniciusfrasson4628 3 роки тому

    How to fixed this -> Cannot read property ‘Defaults’ of undefined , I m using function components In reactJs

  • @chrollo8483
    @chrollo8483 2 роки тому

    can you make a chart by using firebase data?

    • @WornOffKeys
      @WornOffKeys  2 роки тому

      In theory you should be able to make a chart with data from any source

    • @chrollo8483
      @chrollo8483 2 роки тому

      @@WornOffKeys can you make a video tutorial?

  • @sonalisahoo5953
    @sonalisahoo5953 3 роки тому

    Hi, can i get the code pls?

  • @masj7786
    @masj7786 2 роки тому

    not working!

  • @mehedihasanridoy1588
    @mehedihasanridoy1588 2 роки тому

    Great Video.. But need to update it for now.

  • @ivesscripts8876
    @ivesscripts8876 3 роки тому

    Early

  • @vaalarivan_p
    @vaalarivan_p Рік тому

    15:00

  • @victorete3
    @victorete3 3 роки тому

    CORS Policy ):

  • @masj7786
    @masj7786 2 роки тому

    Another tutorial that as of now 2022 doesn't work. The 10th in a row.
    The person who will create a working React Chart js course will become rich.

  • @RinatWOT
    @RinatWOT 3 роки тому

    Great video, thank you!