Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

149
Views
Update data using chart js in react

I have a bar chart rendering data from a database and I'm trying to allow the user to update that data through an input tag.

   var bar = {
        type : 'bar',
        data: {
            labels: studentList,
            datasets: [
                {
                    label: "student grades",
                    data: [30, 80, 20, 10, 90,100,50],
                    backgroundColor: "turquoise",
                    width:50,
                    height:100
                

                }
            ]
        }}     

    
    
    const updateFirst = () => {
        console.log(bar.data.datasets[0].data[0])
        bar.data.datasets[0].data[0] = grade
        console.log(name, grade)
    }

    const currentClassClicked = localStorage.getItem("currentClassClicked")
    console.log(currentClassClicked)
    const [students, setStudents] = useState([])
    return (
        <div className='class-grades-container'>
            <h1>{currentClassClicked}</h1>
            <div className='class-grades-wrapper'>
                <div className='bar-chart'>
                <Bar 
                    className="bar-chart-canvas"
                    data={bar.data} 
                        />
                </div>
                <div className='change-grades'>
                    <input type="text" placeholder="First name..." onChange={((e) => setName(e.target.value))}/>
                    <input type="text" placeholder="Percentage..." onChange={((e) => setGrade(e.target.value))}/>
                    <button onClick={updateFirst}>Update grade</button>
                </div>
            </div>
        </div>

Any help would be greatly appreciated since I don't have much experience wit chart js.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!