Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Charts in FuelPHP
  • How does one connect a MySQL DB to charts.js within fuel?  I am lost on even how/where to begin...
  • You don't. MySQL is backend, charts.js is frontend.

    I don't know it as I'm not a frontend developer, but usually these type of solutions either require you to generate and include the data for the chart in the HTML/Javascript output that the View generates, or you use an Ajax call to have the chart fetch the data using a callback. In which case you need a REST controller that provides the data for the chart in a json structure.
  • This is a pretty good example: https://stackoverflow.com/questions/19894952/draw-a-chart-js-with-ajax-data-and-responsive-a-few-problems-and-questions

    On the Fuel side, you need to create a Controller that extends Controller_Rest, which contains an action method that does the DB query to retrieve your data, and returns it as an array. The controller will convert it to a json response for you. What it needs to return depends obviously on what chart.js expects.

    Once done, have the ajax call call your controller.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion