mirror of
https://github.com/chartjs/Chart.js.git
synced 2026-02-01 17:47:09 +00:00
Bundled builds
Possible usages are: src/Chart.js (umd) dist/Chart.js (ChartJS) dist/Chart.min.js (ChartJS minified) dist/Chart.bundle.js (ChartJS with Moment.js) dist/Chart.bundle.min.js (ChartJS with Moment.js minified)
This commit is contained in:
parent
f2780bb825
commit
007d029837
14
Chart.min.js
vendored
14
Chart.min.js
vendored
File diff suppressed because one or more lines are too long
10590
dist/Chart.bundle.js
vendored
Normal file
10590
dist/Chart.bundle.js
vendored
Normal file
File diff suppressed because one or more lines are too long
21
dist/Chart.bundle.min.js
vendored
Normal file
21
dist/Chart.bundle.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
93
Chart.js → dist/Chart.js
vendored
93
Chart.js → dist/Chart.js
vendored
File diff suppressed because one or more lines are too long
14
dist/Chart.min.js
vendored
Normal file
14
dist/Chart.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
25
gulpfile.js
25
gulpfile.js
@ -16,9 +16,11 @@ var gulp = require('gulp'),
|
||||
karma = require('gulp-karma'),
|
||||
browserify = require('browserify'),
|
||||
streamify = require('gulp-streamify'),
|
||||
source = require('vinyl-source-stream');
|
||||
source = require('vinyl-source-stream'),
|
||||
merge = require('merge-stream');
|
||||
|
||||
var srcDir = './src/';
|
||||
var outDir = './dist/';
|
||||
var testDir = './test/';
|
||||
|
||||
var preTestFiles = [
|
||||
@ -52,19 +54,30 @@ gulp.task('default', ['build', 'watch']);
|
||||
|
||||
function buildTask() {
|
||||
|
||||
var isCustom = !!(util.env.types),
|
||||
outputDir = (isCustom) ? 'custom' : '.';
|
||||
var bundled = browserify('./src/Chart.js')
|
||||
.bundle()
|
||||
.pipe(source('Chart.bundle.js'))
|
||||
.pipe(streamify(replace('{{ version }}', package.version)))
|
||||
.pipe(gulp.dest(outDir))
|
||||
.pipe(streamify(uglify({
|
||||
preserveComments: 'some'
|
||||
})))
|
||||
.pipe(streamify(concat('Chart.bundle.min.js')))
|
||||
.pipe(gulp.dest(outDir));
|
||||
|
||||
return browserify('./src/chart.js')
|
||||
var nonBundled = browserify('./src/Chart.js')
|
||||
.ignore('moment')
|
||||
.bundle()
|
||||
.pipe(source('Chart.js'))
|
||||
.pipe(streamify(replace('{{ version }}', package.version)))
|
||||
.pipe(gulp.dest(outputDir))
|
||||
.pipe(gulp.dest(outDir))
|
||||
.pipe(streamify(uglify({
|
||||
preserveComments: 'some'
|
||||
})))
|
||||
.pipe(streamify(concat('Chart.min.js')))
|
||||
.pipe(gulp.dest(outputDir));
|
||||
.pipe(gulp.dest(outDir));
|
||||
|
||||
return merge(bundled, nonBundled);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -33,6 +33,7 @@
|
||||
"karma-firefox-launcher": "^0.1.6",
|
||||
"karma-jasmine": "^0.3.6",
|
||||
"karma-jasmine-html-reporter": "^0.1.8",
|
||||
"merge-stream": "^1.0.0",
|
||||
"semver": "^3.0.1",
|
||||
"vinyl-source-stream": "^1.1.0"
|
||||
},
|
||||
|
||||
@ -3,8 +3,8 @@
|
||||
|
||||
<head>
|
||||
<title>Line Chart</title>
|
||||
<script src="../../node_modules/moment/min/moment.min.js"></script>
|
||||
<script src="../../Chart.js"></script>
|
||||
<!-- <script src="../../node_modules/moment/min/moment.min.js"></script> -->
|
||||
<script src="../../dist/Chart.bundle.js"></script>
|
||||
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
|
||||
<style>
|
||||
canvas {
|
||||
@ -31,7 +31,7 @@
|
||||
</div>
|
||||
<script>
|
||||
var timeFormat = 'MM/DD/YYYY HH:mm';
|
||||
|
||||
|
||||
function randomScalingFactor() {
|
||||
return Math.round(Math.random() * 100 * (Math.random() > 0.5 ? -1 : 1));
|
||||
}
|
||||
@ -47,7 +47,7 @@
|
||||
function newDate(days) {
|
||||
return moment().add(days, 'd').toDate();
|
||||
}
|
||||
|
||||
|
||||
function newDateString(days) {
|
||||
return moment().add(days, 'd').format(timeFormat);
|
||||
}
|
||||
|
||||
@ -33,7 +33,7 @@ require('./scales/scale.category')(Chart)
|
||||
require('./scales/scale.linear')(Chart)
|
||||
require('./scales/scale.logarithmic')(Chart)
|
||||
require('./scales/scale.radialLinear')(Chart)
|
||||
require('./scales/scale.time')(Chart, moment)
|
||||
require('./scales/scale.time')(Chart)
|
||||
|
||||
require('./elements/element.arc')(Chart)
|
||||
require('./elements/element.line')(Chart)
|
||||
@ -47,3 +47,5 @@ require('./charts/Chart.Line')(Chart)
|
||||
require('./charts/Chart.PolarArea')(Chart)
|
||||
require('./charts/Chart.Radar')(Chart)
|
||||
require('./charts/Chart.Scatter')(Chart)
|
||||
|
||||
window.Chart = module.exports = Chart
|
||||
|
||||
@ -2,6 +2,8 @@
|
||||
|
||||
module.exports = function() {
|
||||
|
||||
var helpers = require('./core.helpers')
|
||||
|
||||
//Occupy the global variable of Chart, and create a simple base class
|
||||
var Chart = function(context, config) {
|
||||
this.config = config;
|
||||
@ -23,8 +25,8 @@ module.exports = function() {
|
||||
// If the canvas has a specified width and height, we use those else
|
||||
// we look to see if the canvas node has a CSS width and height.
|
||||
// If there is still no height, fill the parent container
|
||||
this.width = context.canvas.width || parseInt(Chart.helpers.getStyle(context.canvas, 'width')) || Chart.helpers.getMaximumWidth(context.canvas);
|
||||
this.height = context.canvas.height || parseInt(Chart.helpers.getStyle(context.canvas, 'height')) || Chart.helpers.getMaximumHeight(context.canvas);
|
||||
this.width = context.canvas.width || parseInt(helpers.getStyle(context.canvas, 'width')) || helpers.getMaximumWidth(context.canvas);
|
||||
this.height = context.canvas.height || parseInt(helpers.getStyle(context.canvas, 'height')) || helpers.getMaximumHeight(context.canvas);
|
||||
|
||||
this.aspectRatio = this.width / this.height;
|
||||
|
||||
@ -40,7 +42,7 @@ module.exports = function() {
|
||||
this.originalCanvasStyleHeight = context.canvas.style.height;
|
||||
|
||||
// High pixel density displays - multiply the size of the canvas height/width by the device pixel ratio, then scale.
|
||||
Chart.helpers.retinaScale(this);
|
||||
helpers.retinaScale(this);
|
||||
|
||||
if (config) {
|
||||
this.controller = new Chart.Controller(this);
|
||||
@ -48,7 +50,7 @@ module.exports = function() {
|
||||
|
||||
// Always bind this so that if the responsive state changes we still work
|
||||
var _this = this;
|
||||
Chart.helpers.addResizeListener(context.canvas.parentNode, function() {
|
||||
helpers.addResizeListener(context.canvas.parentNode, function() {
|
||||
if (_this.controller && _this.controller.config.options.responsive) {
|
||||
_this.controller.resize();
|
||||
}
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
"use strict";
|
||||
|
||||
module.exports = function(Chart, moment) {
|
||||
var moment = require('moment')
|
||||
moment = typeof(moment) === 'function' ? moment : window.moment
|
||||
|
||||
module.exports = function(Chart) {
|
||||
|
||||
var helpers = require('../core/core.helpers.js');
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user