Skip to content

Commit

Permalink
use latest Chart.js, my-archives#6
Browse files Browse the repository at this point in the history
  • Loading branch information
fundon committed Jan 30, 2015
1 parent 484775c commit 3905746
Show file tree
Hide file tree
Showing 17 changed files with 3,642 additions and 122 deletions.
3,475 changes: 3,475 additions & 0 deletions Chart.js

Large diffs are not rendered by default.

File renamed without changes.
6 changes: 3 additions & 3 deletions examples/bar.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
var Canvas = require('canvas'),
canvas = new Canvas(600, 400),
canvas = new Canvas(600, 450),
ctx = canvas.getContext('2d'),
Chart = require('../'),
fs = require('fs'),
data = JSON.parse(fs.readFileSync(__dirname + '/bar.json'));
data = require('./bar.json');

ctx.fillStyle = '#fff';
ctx.fillRect(0, 0, canvas.width, canvas.height);
Chart(ctx).Bar(data);
new Chart(ctx).Bar(data);

canvas.toBuffer(function (err, buf) {
if (err) throw err;
Expand Down
15 changes: 0 additions & 15 deletions examples/bar.json

This file was deleted.

49 changes: 49 additions & 0 deletions examples/bar.json.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
var randomScalingFactor = function(){
return Math.round(Math.random()*100);
};

var barChartData = {
labels : [
"January",
"February",
"March",
"April",
"May",
"June",
"July"
],
datasets : [
{
fillColor : "rgba(220,220,220,0.5)",
strokeColor : "rgba(220,220,220,0.8)",
highlightFill: "rgba(220,220,220,0.75)",
highlightStroke: "rgba(220,220,220,1)",
data : [
randomScalingFactor(),
randomScalingFactor(),
randomScalingFactor(),
randomScalingFactor(),
randomScalingFactor(),
randomScalingFactor(),
randomScalingFactor()
]
},
{
fillColor : "rgba(151,187,205,0.5)",
strokeColor : "rgba(151,187,205,0.8)",
highlightFill : "rgba(151,187,205,0.75)",
highlightStroke : "rgba(151,187,205,1)",
data : [
randomScalingFactor(),
randomScalingFactor(),
randomScalingFactor(),
randomScalingFactor(),
randomScalingFactor(),
randomScalingFactor(),
randomScalingFactor()
]
}
]
};

module.exports = barChartData;
9 changes: 4 additions & 5 deletions examples/doughnut.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
var Canvas = require('canvas')
, canvas = new Canvas(800, 800)
, canvas = new Canvas(500, 500)
, ctx = canvas.getContext('2d')
, Chart = require('../')
, fs = require('fs')
, data = JSON.parse(fs.readFileSync(__dirname + '/doughnut.json'));
, data = require('./doughnut.json');

Chart(ctx).Doughnut(data, {
scaleShowValues: true,
scaleFontSize: 24
new Chart(ctx).Doughnut(data, {
//responsive : true
});

canvas.toBuffer(function (err, buf) {
Expand Down
22 changes: 0 additions & 22 deletions examples/doughnut.json

This file was deleted.

32 changes: 32 additions & 0 deletions examples/doughnut.json.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
module.exports = [
{
value: 300,
color:"#F7464A",
highlight: "#FF5A5E",
label: "Red"
},
{
value: 50,
color: "#46BFBD",
highlight: "#5AD3D1",
label: "Green"
},
{
value: 100,
color: "#FDB45C",
highlight: "#FFC870",
label: "Yellow"
},
{
value: 40,
color: "#949FB1",
highlight: "#A8B3C5",
label: "Grey"
},
{
value: 120,
color: "#4D5360",
highlight: "#616774",
label: "Dark Grey"
}
]
12 changes: 3 additions & 9 deletions examples/line.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
var Canvas = require('canvas')
, canvas = new Canvas(1200, 800)
, canvas = new Canvas(600, 450)
, ctx = canvas.getContext('2d')
, Chart = require('../')
, fs = require('fs')
, data = JSON.parse(fs.readFileSync(__dirname + '/line.json'));
, data = require('./line.json');

ctx.fillStyle = '#fff';
ctx.fillRect(0, 0, canvas.width, canvas.height);
Chart(ctx).Line(data, {
scaleOverlay: !true,
scaleOverride: true,
scaleSteps: 10,
scaleStartValue: 0,
scaleStepWidth: 10
});
new Chart(ctx).Line(data);

canvas.toBuffer(function (err, buf) {
if (err) throw err;
Expand Down
19 changes: 0 additions & 19 deletions examples/line.json

This file was deleted.

28 changes: 28 additions & 0 deletions examples/line.json.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
var randomScalingFactor = function(){ return Math.round(Math.random()*100)};
var lineChartData = {
labels : ["January","February","March","April","May","June","July"],
datasets : [
{
label: "My First dataset",
fillColor : "rgba(220,220,220,0.2)",
strokeColor : "rgba(220,220,220,1)",
pointColor : "rgba(220,220,220,1)",
pointStrokeColor : "#fff",
pointHighlightFill : "#fff",
pointHighlightStroke : "rgba(220,220,220,1)",
data : [randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor()]
},
{
label: "My Second dataset",
fillColor : "rgba(151,187,205,0.2)",
strokeColor : "rgba(151,187,205,1)",
pointColor : "rgba(151,187,205,1)",
pointStrokeColor : "#fff",
pointHighlightFill : "#fff",
pointHighlightStroke : "rgba(151,187,205,1)",
data : [randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor()]
}
]
}

module.exports = lineChartData;
13 changes: 4 additions & 9 deletions examples/polararea.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,12 @@ var Canvas = require('canvas')
, ctx = canvas.getContext('2d')
, Chart = require('../')
, fs = require('fs')
, data = JSON.parse(fs.readFileSync(__dirname + '/polararea.json'));
, data = require('./polararea.json');

ctx.fillStyle = '#fff';
ctx.fillRect(0, 0, canvas.width, canvas.height);
//new Chart(ctx).PolarArea(data, {
Chart(ctx).PolarArea(data, {
scaleFontFamily : "'Helvetica'",
scaleFontSize : 13,
scaleFontStyle : "bold",
scaleFontColor : "#333",
scaleShowLabelBackdrop : true,
scaleBackdropColor : "#fafafa"
});
new Chart(ctx).PolarArea(data);

canvas.toBuffer(function (err, buf) {
if (err) throw err;
Expand Down
27 changes: 0 additions & 27 deletions examples/polararea.json

This file was deleted.

32 changes: 32 additions & 0 deletions examples/polararea.json.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
module.exports = [
{
value: 300,
color:"#F7464A",
highlight: "#FF5A5E",
label: "Red"
},
{
value: 50,
color: "#46BFBD",
highlight: "#5AD3D1",
label: "Green"
},
{
value: 100,
color: "#FDB45C",
highlight: "#FFC870",
label: "Yellow"
},
{
value: 40,
color: "#949FB1",
highlight: "#A8B3C5",
label: "Grey"
},
{
value: 120,
color: "#4D5360",
highlight: "#616774",
label: "Dark Grey"
}
]
4 changes: 2 additions & 2 deletions examples/radar.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
var Canvas = require('canvas')
, canvas = new Canvas(800, 800)
, canvas = new Canvas(450, 450)
, ctx = canvas.getContext('2d')
, Chart = require('../')
, fs = require('fs')
, data = JSON.parse(fs.readFileSync(__dirname + '/radar.json'));

ctx.fillStyle = '#fff';
ctx.fillRect(0, 0, canvas.width, canvas.height);
Chart(ctx).Radar(data);
new Chart(ctx).Radar(data);

canvas.toBuffer(function (err, buf) {
if (err) throw err;
Expand Down
5 changes: 4 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
module.exports = require('./lib/chart');
// hacked for io.js/node.js
global.window || (global.window = global);

module.exports = require('./Chart');
16 changes: 6 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
{
"name": "nchart",
"version": "0.1.6",
"version": "1.0.0",
"description": "nChart for node.js inspired by Chart.js.",
"author": "FangDun Cai <[email protected]>",
"license": "MIT",
"readmeFilename": "Readme.md",
"keywords": [
"chart",
"nchart",
"canvas",
"graphics",
"image"
],
"main": "./lib/chart.js",
"main": "index.js",
"scripts": {
"test": "make test"
},
"repository": {
"type": "git",
"url": "git://github.com/cfddream/nchart.git"
},
"repository": "cfddream/nchart.git",
"devDependencies": {
"canvas": "1.1.3",
"mocha": "~1.9.0",
"should": "~3.1.3"
"canvas": "1.1.6",
"mocha": "1.9.0",
"should": "3.1.3"
}
}

0 comments on commit 3905746

Please sign in to comment.