Skip to content

Commit dfa34ba

Browse files
author
Reza Karimi
committed
3D sample
1 parent e27a91b commit dfa34ba

File tree

5 files changed

+46
-7
lines changed

5 files changed

+46
-7
lines changed

custom-plotly.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
var Plotly = require('plotly.js/lib/core.js');
2+
Plotly.register([
3+
require('plotly.js/lib/surface'),
4+
]);
5+
module.exports = Plotly;

index.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<!DOCTYPE html>
2-
<html lang=en>
2+
<html lang="en">
33
<head>
4-
<meta charset=utf-8>
4+
<meta charset="utf-8" />
55
<title>plotly-webpack</title>
66
</head>
77
<body>
8-
<div id="gd"></div>
8+
<div id="myDiv"></div>
99
<script src="bundle.js"></script>
1010
</body>
1111
</html>

index.js

+30-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,31 @@
1-
var Plotly = require('plotly.js');
1+
var Plotly = require('./custom-plotly');
22

3-
Plotly.plot("gd", [{ x: [0, 1], y: [0, 1] }]);
3+
Plotly.d3.csv('https://raw.githubusercontent.com/plotly/datasets/master/api_docs/mt_bruno_elevation.csv', function (err, rows) {
4+
function unpack(rows, key) {
5+
return rows.map(function (row) { return row[key]; });
6+
}
7+
8+
var z_data = []
9+
for (i = 0; i < 24; i++) {
10+
z_data.push(unpack(rows, i));
11+
}
12+
13+
var data = [{
14+
z: z_data,
15+
type: 'surface'
16+
}];
17+
18+
var layout = {
19+
title: 'Mt Bruno Elevation',
20+
autosize: false,
21+
width: 500,
22+
height: 500,
23+
margin: {
24+
l: 65,
25+
r: 50,
26+
b: 65,
27+
t: 90,
28+
}
29+
};
30+
Plotly.newPlot('myDiv', data, layout);
31+
});

package.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,22 @@
55
"main": "index.js",
66
"scripts": {
77
"webpack-dev": "webpack --mode=development --devtool false",
8-
"webpack-prod": "webpack --mode=production"
8+
"webpack-prod": "webpack --mode=production",
9+
"browserify-prod": "browserify index.js -p [minifyify --no-map] > bundle.js"
910
},
1011
"keywords": [],
1112
"author": "",
1213
"license": "ISC",
1314
"devDependencies": {
15+
"compression-webpack-plugin": "^4.0.0",
1416
"ify-loader": "^1.1.0",
1517
"transform-loader": "^0.2.4",
1618
"webpack": "^4.41.5",
1719
"webpack-cli": "^3.3.10"
1820
},
1921
"dependencies": {
22+
"browserify": "^16.5.1",
23+
"minifyify": "^7.3.5",
2024
"plotly.js": "^1.52.0"
2125
}
2226
}

webpack.config.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
var webpack = require('webpack');
2+
const CompressionPlugin = require('compression-webpack-plugin');
23

34
module.exports = {
45
entry: "./index.js",
@@ -16,5 +17,6 @@ module.exports = {
1617
]
1718
},
1819
]
19-
}
20+
},
21+
plugins: [new CompressionPlugin()]
2022
};

0 commit comments

Comments
 (0)