-2

I've created a simple Flask app that has a Chart.js bar chart and a data table below it. See below: enter image description here

(Live view:https://flaskapp.gullp.repl.co/)

My particular bar chart counts the number of items for each label.

My question: how would I go about making an onclick chart.js event that updates the table below the chart?

So for example, if I clicked the first bar in the chart, the table below it would be updated to show all the data for just that first bar.

Also, my table is a Pandas dataframe which I propagate into flask.

Code Base: https://repl.it/join/rbkobiqi-gullp

My intuition tells me, if some how I can pass the label back to the dataframe as a filter that should work.

Not sure how to approach this.

mikelowry
  • 1,307
  • 4
  • 21
  • 43

1 Answers1

0

You can get the value from the bar in the way as described in this thread: Chart.js: Bar Chart Click Events

After you get the value you can use javascript to add it to your table

LeeLenalee
  • 27,463
  • 6
  • 45
  • 69