Skip to content

Instantly share code, notes, and snippets.

@jon-a-nygaard
Last active June 9, 2017 12:21
Show Gist options
  • Save jon-a-nygaard/6a3646f0c1fa6ba271847b6a0743c23d to your computer and use it in GitHub Desktop.
Save jon-a-nygaard/6a3646f0c1fa6ba271847b6a0743c23d to your computer and use it in GitHub Desktop.
Highcharts example with SystemJS

Highcharts example with SystemJS

This is an example of how Highcharts can be used with SystemJS. It uses SystemJS to load source files, SystemJS Babel Plugin to transpile ES6 code, ExpressJS for the server application. ##Steps Install dependencies

npm install

Run the application

  • Start the application by running either npm run start or node server.js.
  • Open localhost:8080 and you should see a simple Highcharts demo.
import Highcharts from 'highcharts/highcharts.js';
const chart = Highcharts.chart('container', {
series: [{
data: [1, 2, 3]
}]
});
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>System.js demo</title>
</head>
<body>
<h1>Highcharts example with SystemJS</h1>
<div id="container"></div>
<script src="/node_modules/systemjs/dist/system.src.js"></script>
<script>
System.config({
baseURL: './',
map: {
'plugin-babel': 'node_modules/systemjs-plugin-babel/plugin-babel.js',
'systemjs-babel-build': 'node_modules/systemjs-plugin-babel/systemjs-babel-browser.js',
'highcharts': 'node_modules/highcharts'
},
transpiler: 'plugin-babel'
});
System.import('app.js');
</script>
</body>
</html>
{
"name": "highcharts-systemjs",
"version": "1.0.0",
"description": "**Install dependencies**",
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js"
},
"author": "Jon Arild Nygård",
"license": "ISC",
"dependencies": {
"express": "^4.14.0",
"highcharts": "^5.0.0",
"systemjs": "^0.19.39",
"systemjs-plugin-babel": "0.0.16"
}
}
@marcalj
Copy link

marcalj commented Jan 3, 2017

@gevgeny I love you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment