- Download source files
- Run
npm install
to install all dependencies. - Run
node build
ornpm run build
to bundleapp.js
intobundle.js
- Open
index.html
in a browser.
'use strict'; | |
const Highcharts = require('highcharts'); | |
require('highcharts/modules/boost')(Highcharts); | |
const range = n => Array.from({ length: n }).map((_, i) => i); | |
const getData = (n) => { | |
let arr = [], | |
a, | |
b, | |
c, | |
spike; | |
return arr = range(n).reduce((arr, i) => { | |
if (i % 100 === 0) { | |
a = 2 * Math.random(); | |
} | |
if (i % 1000 === 0) { | |
b = 2 * Math.random(); | |
} | |
if (i % 10000 === 0) { | |
c = 2 * Math.random(); | |
} | |
if (i % 50000 === 0) { | |
spike = 10; | |
} else { | |
spike = 0; | |
} | |
arr.push([ | |
i, | |
2 * Math.sin(i / 100) + a + b + c + spike + Math.random() | |
]); | |
return arr; | |
}, []) | |
}; | |
const data = getData(500000); | |
console.time('area'); | |
Highcharts.chart('container', { | |
chart: { | |
type: 'area', | |
zoomType: 'x' | |
}, | |
title: { | |
text: 'Trimmed Highcharts drawing ' + data.length + ' points' | |
}, | |
subtitle: { | |
text: 'Using the experimental Highcharts Boost module' | |
}, | |
tooltip: { | |
valueDecimals: 2 | |
}, | |
series: [{ | |
data: data | |
}] | |
}) | |
console.timeEnd('area'); |
'use strict'; | |
const webpack = require('webpack'); | |
webpack({ | |
entry: "./app.js", | |
output: { | |
path: __dirname, | |
filename: "bundle.js" | |
}, | |
}, (err) => { | |
if (err) { | |
console.log(err) | |
} | |
}); |
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Highcharts Boost module with Webpack</title> | |
</head> | |
<body> | |
<div id="container"></div> | |
<script src="./bundle.js" type="text/javascript"></script> | |
</body> | |
</html> |
{ | |
"name": "highcharts-boost-webpack", | |
"version": "1.0.0", | |
"description": "Load Highcharts Boost Module with Webpack", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1", | |
"build": "node build.js" | |
}, | |
"author": "Jon Arild Nygård", | |
"license": "ISC", | |
"devDependencies": { | |
"webpack": "^1.13.3" | |
}, | |
"dependencies": { | |
"highcharts": "^5.0.3" | |
} | |
} |