Skip to content
This repository has been archived by the owner on Mar 4, 2021. It is now read-only.

Commit

Permalink
Merge branch 'master' into fix/sparse-datasets
Browse files Browse the repository at this point in the history
Conflicts:
	Chart.min.js
  • Loading branch information
nnnick committed Aug 3, 2014
2 parents 529d582 + 14e7275 commit 30777e4
Show file tree
Hide file tree
Showing 9 changed files with 109 additions and 20 deletions.
23 changes: 20 additions & 3 deletions Chart.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*!
* Chart.js
* http://chartjs.org/
* Version: 1.0.1-beta.3
*
* Copyright 2014 Nick Downie
* Released under the MIT license
Expand Down Expand Up @@ -91,6 +92,9 @@
// Boolean - whether or not the chart should be responsive and resize when the browser does.
responsive: false,

// Boolean - whether to maintain the starting aspect ratio or not when responsive, if set to false, will take up entire container
maintainAspectRatio: true,

// Boolean - Determines whether to draw tooltips on the canvas or not - attaches events to touchmove & mousemove
showTooltips: true,

Expand Down Expand Up @@ -402,6 +406,12 @@
//Templating methods
//Javascript micro templating by John Resig - source at http://ejohn.org/blog/javascript-micro-templating/
template = helpers.template = function(templateString, valuesObject){
// If templateString is function rather than string-template - call the function for valuesObject
if(templateString instanceof Function)
{
return templateString(valuesObject);
}

var cache = {};
function tmpl(str, data){
// Figure out if we're getting a template, or if we need to
Expand Down Expand Up @@ -693,11 +703,17 @@
removeEvent(chartInstance.chart.canvas, eventName, handler);
});
},
getMaximumSize = helpers.getMaximumSize = function(domNode){
getMaximumWidth = helpers.getMaximumWidth = function(domNode){
var container = domNode.parentNode;
// TODO = check cross browser stuff with this.
return container.clientWidth;
},
getMaximumHeight = helpers.getMaximumHeight = function(domNode){
var container = domNode.parentNode;
// TODO = check cross browser stuff with this.
return container.clientHeight;
},
getMaximumSize = helpers.getMaximumSize = helpers.getMaximumWidth, // legacy support
retinaScale = helpers.retinaScale = function(chart){
var ctx = chart.ctx,
width = chart.canvas.width,
Expand Down Expand Up @@ -776,8 +792,8 @@
resize : function(callback){
this.stop();
var canvas = this.chart.canvas,
newWidth = getMaximumSize(this.chart.canvas),
newHeight = newWidth / this.chart.aspectRatio;
newWidth = getMaximumWidth(this.chart.canvas),
newHeight = this.options.maintainAspectRatio ? newWidth / this.chart.aspectRatio : getMaximumHeight(this.chart.canvas);

canvas.width = this.chart.width = newWidth;
canvas.height = this.chart.height = newHeight;
Expand Down Expand Up @@ -1890,6 +1906,7 @@
};

}).call(this);

(function(){
"use strict";

Expand Down
5 changes: 3 additions & 2 deletions Chart.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2013 Nick Downie
Copyright (c) 2013-2014 Nick Downie

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
9 changes: 5 additions & 4 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"name": "Chart.js",
"version": "1.0.1-beta.2",
"version": "1.0.1-beta.3",
"description": "Simple HTML5 Charts using the canvas element",
"homepage": "https://github.com/nnnick/Chart.js",
"author": "nnnick",
"main": ["Chart.min.js"],
"dependencies": {
}
"main": [
"Chart.min.js"
],
"dependencies": {}
}
3 changes: 3 additions & 0 deletions docs/00-Getting-Started.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ Chart.defaults.global = {
// Boolean - whether or not the chart should be responsive and resize when the browser does.
responsive: false,

// Boolean - whether to maintain the starting aspect ratio or not when responsive, if set to false, will take up entire container
maintainAspectRatio: true,

// Boolean - Determines whether to draw tooltips on the canvas or not
showTooltips: true,

Expand Down
3 changes: 3 additions & 0 deletions docs/06-Advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ Chart.Type.extend({
initialize: function(data){
this.chart.ctx // The drawing context for this chart
this.chart.canvas // the canvas node for this chart
},
// Used to draw something on the canvas
draw: function() {
}
});

Expand Down
46 changes: 45 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ var gulp = require('gulp'),
jshint = require('gulp-jshint'),
size = require('gulp-size'),
connect = require('gulp-connect'),
exec = require('child_process').exec;
replace = require('gulp-replace'),
inquirer = require('inquirer'),
semver = require('semver'),
exec = require('child_process').exec,
fs = require('fs'),
package = require('./package.json'),
bower = require('./bower.json');

var srcDir = './src/';
/*
Expand All @@ -28,8 +34,10 @@ gulp.task('build', function(){
// So we can use this to sort out dependency order - aka include Core first!
srcFiles.push(srcDir+'*');
}

return gulp.src(srcFiles)
.pipe(concat('Chart.js'))
.pipe(replace('{{ version }}', package.version))
.pipe(gulp.dest(outputDir))
.pipe(uglify({preserveComments:'some'}))
.pipe(concat('Chart.min.js'))
Expand All @@ -40,6 +48,42 @@ gulp.task('build', function(){
};
});

/*
* Usage : gulp bump
* Prompts: Version increment to bump
* Output: - New version number written into package.json & bower.json
*/

gulp.task('bump', function(complete){
util.log('Current version:', util.colors.cyan(package.version));
var choices = ['major', 'premajor', 'minor', 'preminor', 'patch', 'prepatch', 'prerelease'].map(function(versionType){
return versionType + ' (v' + semver.inc(package.version, versionType) + ')';
});
inquirer.prompt({
type: 'list',
name: 'version',
message: 'What version update would you like?',
choices: choices
}, function(res){
var increment = res.version.split(' ')[0],
newVersion = semver.inc(package.version, increment);

// Set the new versions into the bower/package object
package.version = newVersion;
bower.version = newVersion;

// Write these to their own files, then build the output
fs.writeFileSync('package.json', JSON.stringify(package, null, 2));
fs.writeFileSync('bower.json', JSON.stringify(bower, null, 2));

complete();
});
});

gulp.task('release', ['build'], function(){
exec('git tag -a v' + package.version);
});

gulp.task('jshint', function(){
return gulp.src(srcDir + '*.js')
.pipe(jshint())
Expand Down
14 changes: 9 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"name": "chart.js",
"homepage": "http://www.chartjs.org",
"description": "Simple HTML5 charts using the canvas element.",
"version": "1.0.1-beta.2",
"version": "1.0.1-beta.3",
"main": "Chart.js",
"repository": {
"type": "git",
"url": "https://github.com/nnnick/Chart.js.git"
Expand All @@ -11,10 +12,13 @@
"devDependencies": {
"gulp": "3.5.x",
"gulp-concat": "~2.1.x",
"gulp-uglify": "~0.2.x",
"gulp-util": "~2.2.x",
"gulp-connect": "~2.0.5",
"gulp-jshint": "~1.5.1",
"gulp-replace": "^0.4.0",
"gulp-size": "~0.4.0",
"gulp-connect": "~2.0.5"
"gulp-uglify": "~0.2.x",
"gulp-util": "~2.2.x",
"inquirer": "^0.5.1",
"semver": "^3.0.1"
}
}
}
24 changes: 20 additions & 4 deletions src/Chart.Core.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*!
* Chart.js
* http://chartjs.org/
* Version: {{ version }}
*
* Copyright 2014 Nick Downie
* Released under the MIT license
Expand Down Expand Up @@ -91,6 +92,9 @@
// Boolean - whether or not the chart should be responsive and resize when the browser does.
responsive: false,

// Boolean - whether to maintain the starting aspect ratio or not when responsive, if set to false, will take up entire container
maintainAspectRatio: true,

// Boolean - Determines whether to draw tooltips on the canvas or not - attaches events to touchmove & mousemove
showTooltips: true,

Expand Down Expand Up @@ -402,6 +406,12 @@
//Templating methods
//Javascript micro templating by John Resig - source at http://ejohn.org/blog/javascript-micro-templating/
template = helpers.template = function(templateString, valuesObject){
// If templateString is function rather than string-template - call the function for valuesObject
if(templateString instanceof Function)
{
return templateString(valuesObject);
}

var cache = {};
function tmpl(str, data){
// Figure out if we're getting a template, or if we need to
Expand Down Expand Up @@ -693,11 +703,17 @@
removeEvent(chartInstance.chart.canvas, eventName, handler);
});
},
getMaximumSize = helpers.getMaximumSize = function(domNode){
getMaximumWidth = helpers.getMaximumWidth = function(domNode){
var container = domNode.parentNode;
// TODO = check cross browser stuff with this.
return container.clientWidth;
},
getMaximumHeight = helpers.getMaximumHeight = function(domNode){
var container = domNode.parentNode;
// TODO = check cross browser stuff with this.
return container.clientHeight;
},
getMaximumSize = helpers.getMaximumSize = helpers.getMaximumWidth, // legacy support
retinaScale = helpers.retinaScale = function(chart){
var ctx = chart.ctx,
width = chart.canvas.width,
Expand Down Expand Up @@ -776,8 +792,8 @@
resize : function(callback){
this.stop();
var canvas = this.chart.canvas,
newWidth = getMaximumSize(this.chart.canvas),
newHeight = newWidth / this.chart.aspectRatio;
newWidth = getMaximumWidth(this.chart.canvas),
newHeight = this.options.maintainAspectRatio ? newWidth / this.chart.aspectRatio : getMaximumHeight(this.chart.canvas);

canvas.width = this.chart.width = newWidth;
canvas.height = this.chart.height = newHeight;
Expand Down Expand Up @@ -1889,4 +1905,4 @@
return Chart;
};

}).call(this);
}).call(this);

0 comments on commit 30777e4

Please sign in to comment.