CS 315 Homework 1 - Data Grapher Online

Due Fri Sep 12 at 11:59pm

Overview

This assignment will give you a chance to get started with JavaScript and creating graphics, as well as to begin thinking about the use of graphics as representation.

You will be making a basic webpage that displays simple graphs of numeric data. Your webpage will be able to show different kinds of charts: line charts, bar charts, and pie charts. Your charts will include simple decorations (i.e., labels), and should use color to differentiate between data sets. The data to graph will be loaded and parsed from a specially formatted textfile.

You will be drawing these charts using an HTML5 canvas, which provides an API reminiscent of the Java2D API that you should be familiar with. While we will soon move beyond this simple API to doing more complex graphical operations, the canvas provides a good basis for experimenting with and learning JavaScript.

Note: while there are many different existing libraries for generating charts in JavaScript and HTML5, for this assignment you will need to create charts "from scratch". This will give you a more thorough practice with JavaScript, which you will need for the rest of the course. However, you are welcome to look at other libraries for examples of what might make a chart "look good", as well as for ideas for further embellishments!

This assignment should be completed individually.

Objectives

Necessary Files

You will need a copy of the cs315-hwk1.zip file which contains a basic code framework to get you started. I'll describe the file structure briefly, since future assignments will use a similar setup.

Normally, you can view a simple website simply by opening a .html file in your favorite browser. However, for security reasons you can't have JavaScript load a file that comes from a different source. Thus in order to easily load external files (which we'll be doing regularly), you'll need to instead load your grapher.html page from a web server.

You don't actually need to put your assignments online; instead you can just run a local web server and serve web pages to yourself! (You let your computer be both the server and the client). The easiest way to do this (which is sufficient for this class) is by using Node.js and specifically the http-server package.

  1. First, download and install node.js on your machine.
  2. On the terminal, run the command
    npm install http-server -g
    in order to install the http-server package.
  3. In the terminal, change directory to the root of your assignment (that is, the directory with the grapher.html file), and run
    http-server .

    (don't forget the period!)

    This will start a local webserver at you can access at localhost:8080/, and you can access the grapher.html file via localhost:8080/grapher.html. Open that link in your browser and you should see your application! You will need to do this every time you want to view your application (but you only need to run the command once, then just refresh the page to see changes to your code reflected).

Resources

There are a number of good tutorials and references for working with the HTML5 Canvas, including

among others.

Assignment Details

The overall goal of this assignment should be straightforward, though there are a couple of moving parts.

Extensions

Once you've got the basics of your charts working, go all out! You can add in further decorations, interaction (e.g., bolding bars when you mouse over them), etc. Exceptional, creative submissions makes for a happy professor, and a happy professor may give you extra credit.

But be careful: it can be easy to get bogged down in these extra features; make sure you have the core components in first!

Submitting

BEFORE YOU SUBMIT: make sure your code is fully functional! If your code doesn't run, I can't give you credit! And yes, you should include comments explaining what your code and methods do (to help me as well as help you)! Exclamation point!

Upload your entire project (including the lib/ and asset/ folders) to the Hwk1 submission folder on vhedwig (see the instructions if you need help). Also include a filled-in copy of the README.txt file in your project directory!

The homework is due at midnight on Fri Sep 12.

Grading

This assignment will be graded out of 20 points: