Data Visualization With Chart.js. Alireza Mohammadi Fall 2017

Similar documents
ChartJS Tutorial For Beginners

ScholarOne Manuscripts. COGNOS Reports User Guide

infogr.am -- getting started

University of North Dakota PeopleSoft Finance Tip Sheets. Utilizing the Query Download Feature

Displaying ndtv Graphics in Spotfire using TERR and JSViz

Excel Basics Rice Digital Media Commons Guide Written for Microsoft Excel 2010 Windows Edition by Eric Miller

Data Visualization on the Web with D3

What is the Box Model?

DKAN. Data Warehousing, Visualization, and Mapping

Your departmental website

Links Menu (Blogroll) Contents: Links Widget

Chart.js Documentation

Welcome Please sit on alternating rows. powered by lucid & no.dots.nl/student

Part 1. Introduction. Chapter 1 Why Use ODS? 3. Chapter 2 ODS Basics 13

TUTORIAL FOR IMPORTING OTTAWA FIRE HYDRANT PARKING VIOLATION DATA INTO MYSQL

CS1046 Lab 4. Timing: This lab should take you 85 to 130 minutes. Objectives: By the end of this lab you should be able to:

Microsoft Excel Pivot Tables & Pivot Table Charts

Making use of other Applications

DecisionPoint For Excel

(try adding using css to add some space between the bottom of the art div and the reset button, this can be done using Margins)

Week 8 Google Maps. This week you ll learn how to embed a Google Map into a web page and add custom markers with custom labels.

Making Tables and Graphs with Excel. The Basics

Ninja Menus extension for Magento 2

TUTORIAL FOR IMPORTING OTTAWA FIRE HYDRANT PARKING VIOLATION DATA INTO MYSQL

Beginning HTML. The Nuts and Bolts of building Web pages.

MEGA MENU USER GUIDE. Phone: Extension version: 1.0 Magento Compatibility: CE 2.

D3 Introduction. Gracie Young and Vera Lin. Slides adapted from

CSCU9B2 Practical 8: Location-Aware Web Pages NOT USED (DOES NOT ALL WORK AS ADVERTISED)

INFS 2150 / 7150 Intro to Web Development / HTML Programming

Creating a Basic Chart in Excel 2007

Overview... 4 JavaScript Charting and Metric Insights... 5

Introduction to WEB PROGRAMMING

CSS worksheet. JMC 105 Drake University

Real Time Marketing and Sales Data

Want to add cool effects like rollovers and pop-up windows?

PlayerLync Forms User Guide (MachForm)

Microsoft Word 2010 Intermediate

Using Dreamweaver CC. 6 Styles in Websites. Exercise 1 Linked Styles vs Embedded Styles

Using Dreamweaver CS6

SAS BI Dashboard 3.1. User s Guide Second Edition

Welcome Back! Without further delay, let s get started! First Things First. If you haven t done it already, download Turbo Lister from ebay.

Lastly, in case you don t already know this, and don t have Excel on your computers, you can get it for free through IT s website under software.

Chapter. Introducing Excel Charts

Survey of Math: Excel Spreadsheet Guide (for Excel 2016) Page 1 of 9

Graphing Interface Overview

JavaScript CS 4640 Programming Languages for Web Applications

SCRIPT REFERENCE. UBot Studio Version 4. The UI Commands

Let s create a grid of pixels that you can use for creating pixel art. CSS provides table styles for grid and table layouts.

MicroStrategy Academic Program

(Simple) JavaScript Framework Homework

Title and Modify Page Properties

Locate it inside of your Class/DreamWeaver folders and open it up.

HTML version of slides:

WebGL Seminar: O3D. Alexander Lokhman Tampere University of Technology

Internet: An international network of connected computers. The purpose of connecting computers together, of course, is to share information.

JavaScript Fundamentals_

Before you begin, make sure you have the images for these exercises saved in the location where you intend to create the Nuklear Family Website.

In this project, you ll learn how to create your own webpage to tell a story, joke or poem. Think about the story you want to tell.

Chapter 4 Statements. Slides Modified by Vicky Seno

ORB Education Quality Teaching Resources

Bioinformatics Resources

3. Prepare all your graphs, illustrations and text by cutting them to size. For straight lines use a guillotine.

Section 1. How to use Brackets to develop JavaScript applications

HTML/CSS Lesson Plans

Using Dreamweaver CC. Logo. 4 Creating a Template. Page Heading. Page content in this area. About Us Gallery Ordering Contact Us Links

POWERPOINT Build a Presentation to Remember

Drag and Drop Responsive Template Builder

Illustrator Charts. Advanced options

1. Please, please, please look at the style sheets job aid that I sent to you some time ago in conjunction with this document.

Mobile & More: Preparing for the Latest Design Trends

Working with Images and Multimedia

A Guide to Using WordPress + RAVEN5. v 1.4 Updated May 25, 2018

Introduction to HTML & CSS. Instructor: Beck Johnson Week 5

Integrated Projects for Presentations

Lastly, in case you don t already know this, and don t have Excel on your computers, you can get it for free through IT s website under software.

Introduction to Advanced Features of PowerPoint 2010

How to lay out a web page with CSS

Microsoft Excel Pivot Tables & Pivot Table Charts

Participation Status Report STUDIO ELEMENTS I KATE SOHNG

Script for Interview about LATEX and Friends

How to lay out a web page with CSS

Copyright 2018 MakeUseOf. All Rights Reserved.

Adding Information to a Worksheet

1 Introduction to Using Excel Spreadsheets

Frontend guide. Everything you need to know about HTML, CSS, JavaScript and DOM. Dejan V Čančarević

University of Cincinnati. P5.JS: Getting Started. p5.js

ENGL 323: Writing for New Media Repurposing Content for the Web Part Two

Welcome to Book Display Widgets

Piktochart 101 Create your first infographic in 15 minutes

React. HTML code is made up of tags. In the example below, <head> is an opening tag and </head> is the matching closing tag.

MicroStrategy Academic Program

Let s use Technology Use Data from Cycle 14 of the General Social Survey with Fathom for a data analysis project

Technology Assignment: Limits at Infinity

Fish Eye Menu DMXzone.com Fish Eye Menu Manual

INFS 2150 / 7150 Introduction to Web Development & HTML Programming

Chapter 15 Plug-ins, ActiveX, and Applets

Basic Steps for Creating an Application with the ArcGIS Server API for JavaScript

COMSC-030 Web Site Development- Part 1. Part-Time Instructor: Joenil Mistal

ORB Education Quality Teaching Resources

Chapter 1 Getting Started with HTML 5 1. Chapter 2 Introduction to New Elements in HTML 5 21

Transcription:

Data Visualization With Chart.js Alireza Mohammadi Fall 2017

Introduction To Data Visualization You can tell powerful stories with data. If your website or application is data-intensive, then you will need to find a way to make that data easy to visualize. Humans, after all, are not wonderful at understanding long lists of raw numbers. Charts and graphs can make complicated statistical relationships obvious and intuitive. Using charts when it s beneficial, will make your website easier to understand and visually more appealing. Chart.js Presentation 2

Why Chart.js It can be learned and leveraged quickly. It s designed with simplicity in mind, yet is extremely customizable. Chart.js is one of the quickest and easiest libraries to learn that doesn t heavily limit your options. Chart.js Presentation 3

Why Chart.js (Cont.) It comes with eight different chart types that will cover almost all of your data visualization needs. Chart.js is actively maintained to a high standard by the open source community. Chart.js provides responsive charts that displayed correctly in any device with any display size and resolution. Chart.js Presentation 4

What you ll need Basic knowledge from HTML, CSS & JavaScript. A text editor like Atom, Visual Studio Code or even window notepad. Some experience in web API and JS will help you grasp the nuances of what s going on. Chart.js Presentation 5

Example 1: Bar Chart (Vertical) Chart.js Presentation 6

Example 2: Line Chart (Basic) Chart.js Presentation 7

Example 3: Area Chart (Radar) Chart.js Presentation 8

Example 4: Area Chart (Boundaries) Chart.js Presentation 9

Example 5: Pie Chart Chart.js Presentation 10

Example 6: Scatter Chart Chart.js Presentation 11

Installing Chart.js Installing using a package manager like bower as bellow: 1. Create a bower project in console or terminal with bower init command. 2. Download and install Chart.js with bower install --save chart.js command. 3. Create an empty.html file and link.css and.js files to it. You can download source from GitHub and link required files in your project. You can also use CDN and link files into your project without saving them. Chart.js Presentation 12

Steps To Draw A Chart Add Chart.js in your project. Define where on your page to draw the graph. Supply Chart.js with data, labels, and other options. Define what type of graph you want to draw. Add graphical styles to your graph. Chart.js Presentation 13

Step 1: Add Chart.js Create an empty.html file,.js file and.css file if needed and link them in your.html page. If you don t want to use CDN, install Chart.js using one of the methods described in previews slides. Link chart.js (or chart.min.js) file in your html page like below: <script src="[route prefix]/chart.min.js"></script> Chart.js Presentation 14

Step 2: Prepare a place in your HTML to render the chart The last thing we need to prepare before we can start visualizing our data is to define an area in our HTML where we want to draw the graph. For Chart.js you do this by adding a canvas element, and setting width and height to define the proportions of your graph. <canvas id="mychart" width="1600" height="900"></canvas> Notice that we ve added an id (mychart) to the canvas element that we can later use to reference our designated graph element in JavaScript or CSS. Chart.js Presentation 15

Step 3: Prepare the data Here s the raw data that we ll be using: World historical and predicted populations (in millions) Country 1500 1600 1700 1750 1800 1850 1900 1950 1999 2050 Africa 86 114 106 106 107 111 133 221 783 2478 Asia 282 350 411 502 635 809 947 1402 3700 5267 Europe 168 170 178 190 203 276 408 547 675 734 Latin America 40 20 10 16 24 38 74 167 508 784 North America 6 3 2 2 7 26 82 172 312 433 Chart.js Presentation 16

Step 3: Prepare the data (Cont.) Chart.js expects the data to be passed in the form of a set of arrays. The table in previous slide, reformatted to arrays, looks like so: // Our labels along the x-axis var years = [1500, 1600, 1700, 1750, 1800, 1850, 1900, 1950, 1999, 2050]; // For drawing the lines var africa = [86, 114, 106, 106, 107, 111, 133, 221, 783, 2478]; var asia = [282, 350, 411, 502, 635, 809, 947, 1402, 3700, 5267]; var europe = [168, 170, 178, 190, 203, 276, 408, 547, 675, 734]; var latinamerica = [40, 20, 10, 16, 24, 38, 74, 167, 508, 784]; var northamerica = [6, 3, 2, 2, 7, 26, 82, 172, 312, 433]; Chart.js Presentation 17

Step 4: Draw a line! All we need to do is define what graph we want to draw, and pass in the data that we want to visualize. Let s start by drawing one single line to see if we can get it to work: var ctx = document.getelementbyid("mychart"); var mychart = new Chart(ctx, { type: 'line, data: { labels: years, datasets: [ { data: africa } ] } }); Chart.js Presentation 18

Step 4: Draw a line! (Cont.) What s happening in this bit of code? First, we locate the canvas element that we added earlier to our index.html file (notice "mychart"): var ctx = document.getelementbyid("mychart"); Chart.js Presentation 19

Step 4: Draw a line! (Cont.) Then, using that canvas element, we create a line chart (type: 'line'), and pass along some of our data. labels: years sets our array of years (that we created earlier) for the labels along the x-axis, and data: africa uses our africa variable to draw the line. You may have noticed that our line is missing a label (it says undefined at the top of the graph), and it s not very colorful. Boo! Let s make it! Chart.js Presentation 20

Step 5: Style the line Start out by giving our first line a name. After data: africa, add a comma (hey! I m serious about the comma (remember the comma!), miss it and everything breaks), create a new row, and add label: "Africa": { } data: africa, label: "Africa" Chart.js Presentation 21

Step 5: Style the line (Cont.) To set the border color and remove the big gray area below the graph, add another comma after label: "Africa" and add these two lines: bordercolor: "#3e95cd", fill: false refresh and you should see a blue line named Africa! Chart.js Presentation 22

Step 6: Add the rest of the data All we need to do now is copy the code for Africa and paste it another four times, adding a comma after every }. { }, { }, { },... data: africa, label: "Africa", bordercolor: "#3e95cd", fill: false data: asia, label: "Asia", bordercolor: "#3e95cd", fill: false data: europe, label: "Europe", bordercolor: "#3e95cd", fill: false Chart.js Presentation 23

Thank You! Chart.js Presentation