This is an example of a Node/Express application that connects to a MySQL database and returns data formatted for ZingChart on a GET request to localhost:3000/test
.
-
Replace the
host
,port
,user
,password
, anddatabase
options in the MySQL connection with your MySQL server information. -
Configure
queryString
to the desired query. -
In formatData, add or remove fields to or from the
seriesData
object to fit the data being retrieved from your database. -
In the formatData loop, change the key names that are being pulled from each object in
dataArray
to fit your data. -
Run
node server.js
to start the Express server. -
In your application, make a GET request to
localhost:3000/test
to retrieve your database data for use in a chart.