concept c3 in category data

This is an excerpt from Manning's book Data Wrangling with JavaScript.
Next, I create a simple web application that uses the REST API to retrieve the data in JSON format. My simple web app retrieves data from the database using the REST API, and I can put that data to work. I’m using C3 here to render a chart. I add the chart to the web page and use JavaScript to inject the data. We’ll learn more about C3 later in the book.
Well, we have to start somewhere, and C3 is a convenient and easy place to start. Most simple charts are declarative (they can often be declared with a chart definition specified in a JSON file) although we also have the power of using code when we need it. C3 gives us interactivity right out of the box, and we can even make simple animated charts.
Listing 12.6c Generating the daily report and emailing it to interested parties (listing-12.6/server/generate-daily-report.js)
const generateReport = require('./toolkit/generate-report.js'); #1 const sendEmail = require('./send-email.js'); #2 const config = require('./config.js'); function generateDailyReport (db) { #3 const incomingDataCollection = db.collection("incoming"); const reportFilePath = "./output/daily-report.pdf"; #4 return incomingDataCollection.find() #5 .sort({ _id: -1 }) #6 .limit(24) #7 .toArray() .then(data => { const chartData = { #8 xFormat: "%d/%m/%Y %H:%M", #9 json: data.reverse(), #10 keys: { x: "Date", value: [ "PM10 (ug/m^3)" ] } }; return generateReport(chartData, reportFilePath); #11 }) .then(() => { const subject = "Daily report"; #12 const text = "Your daily report is attached."; #12 const html = text; #13 const attachments = [ #14 { #15 path: reportFilePath, #16 } ]; return sendEmail( #17 config.dailyReport.recipients, #17 subject, text, html, attachments #17 ); #17 }); }; module.exports = generateDailyReport; #1 Requires the toolkit function to generate the report #2 Requires the helper function to send the email #3 This is a helper function to generate the daily report and email it to interested parties. #4 This is the file path for the report we’re generating and writing to a file. #5 Queries the database for records #6 Gets the most recent records first, a convenient method of sorting based on MongoDB ObjectIds #7 Limits to entries for the most recent 24 hours #8 Prepares the data to display in the chart #9 Specifies the format of the Date column used by C3 to parse the data series for the X axis #10 Reverses the data so it’s in chronological order for display in the chart #11 Renders a report to a PDF file #12 Specifies the subject and the body of the email #13 This could also include a fancy HTML-formatted version of the email here. #14 Specifies attachments to send with the email #15 We only need a single attachment here, but you could easily add more. #16 Attaches our generated report to the email #17 Emails the report to specified recipients