Skip to content

Commit

Permalink
Created a sample to test Highcharts with Browserify.
Browse files Browse the repository at this point in the history
  • Loading branch information
jon-a-nygaard committed Nov 25, 2015
1 parent 83c3a88 commit fbca0f1
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,4 @@ nbproject/
*.access_log

*.log
samples/highcharts/common-js/browserify/demo.js
11 changes: 11 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -493,3 +493,14 @@ gulp.task('scripts', function () {
fs.writeFileSync('./build/canvas-tools.src.js', js, 'utf8');
});
});

gulp.task('common', function () {
var browserify = require('browserify');
browserify('./samples/highcharts/common-js/browserify/app.js')
.bundle(function (err, buf) {
if (err) {
// @todo Do something meaningful with err
}
fs.writeFileSync('./samples/highcharts/common-js/browserify/demo.js', buf);
});
});
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
"url": "https://github.com/highslide-software/highcharts.com.git"
},
"devDependencies": {
"browserify": "^12.0.1",
"colors": "~1.1.2",
"grunt": "^0.4.5",
"grunt-jslint": "^1.1.12",
"gulp-eslint": "^1.0.0",
"request": "^2.65.0",
"vinyl-ftp": "^0.4.5",
"xml2js": "^0.4.13",
"colors": "~1.1.2"
"xml2js": "^0.4.13"
}
}
76 changes: 76 additions & 0 deletions samples/highcharts/common-js/browserify/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/* eslint-env node*/
// Require dependencies
var standalone = require('../../../../js/adapters/standalone-framework.src'),
Highcharts = require('../../../../js/highcharts.src');
// Load the HighchartsAdapter
Highcharts = new Highcharts(standalone);

QUnit.test("Check if Highcharts is loaded properly.", function (assert) {
var chart = new Highcharts.Chart({
chart: {
renderTo: 'container'
},
title: {
text: 'Monthly Average Temperature',
x: -20 //center
},
subtitle: {
text: 'Source: WorldClimate.com',
x: -20
},
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
yAxis: {
title: {
text: 'Temperature (°C)'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
tooltip: {
valueSuffix: '°C'
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'middle',
borderWidth: 0
},
series: [{
name: 'Tokyo',
data: [7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6]
}, {
name: 'New York',
data: [-0.2, 0.8, 5.7, 11.3, 17.0, 22.0, 24.8, 24.1, 20.1, 14.1, 8.6, 2.5]
}, {
name: 'Berlin',
data: [-0.9, 0.6, 3.5, 8.4, 13.5, 17.0, 18.6, 17.9, 14.3, 9.0, 3.9, 1.0]
}, {
name: 'London',
data: [3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8]
}]
});

assert.strictEqual(
window.HighchartsAdapter,
undefined,
"No global HighchartsAdapter variable."
);

assert.strictEqual(
window.Highcharts,
undefined,
"No global Highcharts variable."
);

assert.strictEqual(
Highcharts.product,
'Highcharts',
'Highcharts is loaded'
);
});
6 changes: 6 additions & 0 deletions samples/highcharts/common-js/browserify/demo.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.warning {
background-color: #f0ad4e;
color: white;
padding: 15px;
font-size: 20px;
}
8 changes: 8 additions & 0 deletions samples/highcharts/common-js/browserify/demo.details
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
name: Highcharts Browserify Demo
authors:
- Jon Arild Nygård
resources:
- http://code.jquery.com/qunit/qunit-1.19.0.js
- http://code.jquery.com/qunit/qunit-1.19.0.css
...
5 changes: 5 additions & 0 deletions samples/highcharts/common-js/browserify/demo.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<div id="qunit"></div>
<div id="qunit-fixture"></div>

<p class="warning">This sample will check if Highcharts works properly with Browserify. Before running this test, run "gulp common" in command line first.</p>
<div id="container" style="width: 600px;"></div>

0 comments on commit fbca0f1

Please sign in to comment.