Skip to content

Commit

Permalink
📖 publish: 1.3.5
Browse files Browse the repository at this point in the history
  • Loading branch information
sakitam-fdd committed Aug 5, 2018
1 parent bf6a094 commit 1212b7c
Show file tree
Hide file tree
Showing 38 changed files with 14,734 additions and 1,076 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ https://unpkg.com/ol3-echarts/dist/ol3Echarts.min.js
```

#### [示例](//sakitam-fdd.github.io/ol3Echarts/)
#### [文档](//sakitam-fdd.github.io/ol3Echarts/docs/)
#### [文档](//sakitam-fdd.github.io/ol3Echarts/docs/index.html)

##### openlayers

Expand Down Expand Up @@ -225,11 +225,11 @@ class Index extends React.Component {

## 截图示例

![散点图](https://raw.githubusercontent.com/sakitam-fdd/ol3Echarts/master/docs/assets/images/scatter.jpg)
![散点图](https://raw.githubusercontent.com/sakitam-fdd/ol3Echarts/master/website/static/images/scatter.jpg)

![迁徙图](https://raw.githubusercontent.com/sakitam-fdd/ol3Echarts/master/docs/assets/images/mock-migration.jpg)
![迁徙图](https://raw.githubusercontent.com/sakitam-fdd/ol3Echarts/master/website/static/images/mock-migration.jpg)

![微博签到数据点亮中国](https://raw.githubusercontent.com/sakitam-fdd/ol3Echarts/master/docs/assets/images/wchart-gl.jpg)
![微博签到数据点亮中国](https://raw.githubusercontent.com/sakitam-fdd/ol3Echarts/website/static/assets/images/wchart-gl.jpg)

其他示例请自己挖掘

Expand Down
5 changes: 5 additions & 0 deletions build/webpack.generate.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ const webpackConfig = merge(require('./webpack.base.conf'), {
from: 'website/static',
to: 'static',
ignore: ['.*']
},
{
from: 'docs',
to: 'docs',
ignore: ['.*']
}
])
],
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
"lint": "eslint --fix --ext .js,.jsx packages/ol-echarts/src packages/ol3-echarts/src",
"prettify": "prettier --write packages/ol-echarts/src/**/*.js packages/ol3-echarts/src/**/*.js",
"bootstrap": "lerna bootstrap",
"publish-packages": "lerna publish --conventional-commits",
"publish-packages": "lerna publish --force-publish",
"precommit": "lint-staged",
"website": "webpack-dev-server --inline --config build/webpack.preview.conf.js",
"generate": "webpack --config build/webpack.generate.conf.js"
"generate": "webpack --config build/webpack.generate.conf.js",
"deploy": "gh-pages -d _site"
},
"lint-staged": {
"*.{js}": [
Expand All @@ -27,6 +28,7 @@
},
"dependencies": {
"echarts": "^4.1.0",
"echarts-gl": "^1.0.0",
"ol": "^5.1.3"
},
"devDependencies": {
Expand Down Expand Up @@ -112,6 +114,7 @@
"sass-loader": "^7.0.3",
"shx": "^0.3.2",
"sinon": "^3.2.1",
"gh-pages": "^1.2.0",
"style-loader": "^0.21.0",
"uglify-js": "^3.4.6",
"url-loader": "^1.0.1",
Expand Down
17 changes: 9 additions & 8 deletions packages/ol-echarts/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class EChartsLayer extends Object {
* append data
* @param data
* @param save
* @returns {ol3Echarts}
* @returns {EChartsLayer}
*/
appendData (data, save = true) {
if (data) {
Expand All @@ -132,6 +132,14 @@ class EChartsLayer extends Object {
return this;
}

/**
* clear layer
*/
clear () {
this._incremental = [];
this.$chart.clear();
}

/**
* get map
* @returns {null}
Expand Down Expand Up @@ -180,13 +188,6 @@ class EChartsLayer extends Object {
this.$container.parentNode.removeChild(this.$container);
}

/**
* clear chart
*/
clear () {
this.$chart.clear();
}

/**
* show loading bar
*/
Expand Down
15 changes: 8 additions & 7 deletions packages/ol3-echarts/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,14 @@ class ol3Echarts extends ol.Object {
return this;
}

/**
* clear layer
*/
clear () {
this._incremental = [];
this.$chart.clear();
}

/**
* get map
* @returns {null}
Expand Down Expand Up @@ -175,13 +183,6 @@ class ol3Echarts extends ol.Object {
this.$container.parentNode.removeChild(this.$container);
}

/**
* clear chart
*/
clear () {
this.$chart.clear();
}

/**
* show loading bar
*/
Expand Down
6 changes: 5 additions & 1 deletion website/pages/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ class Header extends Component {
}
}

openDocs (event) {
window.open('./docs/index.html')
}

render () {
return (
<div className="header clearfix" onClick={event => this.handleDefEvent(event)}>
Expand All @@ -36,7 +40,7 @@ class Header extends Component {
<a href="./">首页</a>
</li>
<li id="nav-doc" className="dropdown">
<a href="https://sakitam-fdd.github.io/ol3Echarts/docs/" target="_blank">文档</a>
<a href="./docs/index.html" target="_blank" onClick={event => this.openDocs(event)}>文档</a>
</li>
</ul>
<ul className="nav navbar-nav navbar-right">
Expand Down
100 changes: 100 additions & 0 deletions website/pages/aireline.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import * as React from 'react';
import {Map, View} from 'ol';
import TileLayer from 'ol/layer/Tile';
import XYZ from 'ol/source/XYZ';
import EChartsLayer from 'ol-echarts';
import { getJSON } from '../helper';
import 'ol/ol.css';
import '../assets/style/art.scss'

class Index extends React.Component {
constructor (props, context) {
super(props, context);
this.state = {
zoom: 14,
fov: 0,
pitch: 0,
bearing: 0
};

this.container = null;
this.map = null;
}

componentDidMount () {
this.map = new Map({
target: this.container,
view: new View({
center: [113.53450137499999, 34.44104525],
projection: 'EPSG:4326',
zoom: 5
}),
layers: [
new TileLayer({
source: new XYZ({
url: 'http://cache1.arcgisonline.cn/arcgis/rest/services/ChinaOnline' +
'StreetPurplishBlue/MapServer/tile/{z}/{y}/{x}'
})
})
]
});

const echartslayer = new EChartsLayer(null, {
hideOnMoving: false
});
echartslayer.appendTo(this.map);
getJSON('../../json/flights.json', function (data) {
function getAirportCoord (idx) {
return [data.airports[idx][3], data.airports[idx][4]];
}
var routes = data.routes.map(function (airline) {
return [
getAirportCoord(airline[1]),
getAirportCoord(airline[2])
];
});
var option = {
title: {
text: '航线',
left: 'center',
textStyle: {
color: '#eee'
}
},
backgroundColor: 'transparent',
tooltip: {
formatter: function (param) {
var route = data.routes[param.dataIndex];
return data.airports[route[1]][1] + ' > ' + data.airports[route[2]][1];
}
},
series: [{
type: 'lines',
data: routes,
large: true,
largeThreshold: 100,
lineStyle: {
normal: {
opacity: 0.05,
width: 0.5,
curveness: 0.3
}
},
// 设置混合模式为叠加
blendMode: 'lighter'
}]
};
echartslayer.setChartOptions(option);
});
}

setRef = (x = null) => {
this.container = x;
};

render () {
return (<div ref={this.setRef} className="map-content"></div>);
}
}

export default Index;
125 changes: 125 additions & 0 deletions website/pages/flowgl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
import * as React from 'react';
import echarts from 'echarts'; // eslint-disable-line
import echartsgl from 'echarts-gl'; // eslint-disable-line
import {Map, View} from 'ol';
import TileLayer from 'ol/layer/Tile';
import XYZ from 'ol/source/XYZ';
import EChartsLayer from 'ol-echarts';
import { getJSON } from '../helper';
import 'ol/ol.css';
import '../assets/style/art.scss'

class Index extends React.Component {
constructor (props, context) {
super(props, context);
this.state = {
zoom: 14,
fov: 0,
pitch: 0,
bearing: 0
};

this.container = null;
this.map = null;
}

componentDidMount () {
this.map = new Map({
target: this.container,
view: new View({
center: [113.53450137499999, 34.44104525],
projection: 'EPSG:4326',
zoom: 5
}),
layers: [
new TileLayer({
source: new XYZ({
url: 'http://cache1.arcgisonline.cn/arcgis/rest/services/ChinaOnline' +
'StreetPurplishBlue/MapServer/tile/{z}/{y}/{x}'
})
})
]
});

const echartslayer = new EChartsLayer(null, {
hideOnMoving: true,
hideOnZooming: true
});
echartslayer.appendTo(this.map);

getJSON('./static/json/wind.json', function (windData) {
var data = [];
var p = 0;
var maxMag = 0;
var minMag = Infinity;
for (var j = 0; j < windData.ny; j++) {
for (var i = 0; i < windData.nx; i++, p++) {
var vx = windData.data[p][0];
var vy = windData.data[p][1];
var mag = Math.sqrt(vx * vx + vy * vy);
// 数据是一个一维数组
// [ [经度, 维度,向量经度方向的值,向量维度方向的值] ]
data.push([
i / windData.nx * 360 - 180,
j / windData.ny * 180 - 90,
vx,
vy,
mag
]);
maxMag = Math.max(mag, maxMag);
minMag = Math.min(mag, minMag);
}
}
var option = {
title: {
text: '风场',
left: 'center',
top: 'top',
textStyle: {
color: '#fff'
}
},
visualMap: {
left: 'left',
min: minMag,
max: maxMag,
dimension: 4,
inRange: {
// color: ['green', 'yellow', 'red']
color: ['#313695', '#4575b4', '#74add1', '#abd9e9', '#e0f3f8', '#ffffbf', '#fee090', '#fdae61', '#f46d43', '#d73027', '#a50026']
},
realtime: false,
calculable: true,
textStyle: {
color: '#fff'
}
},
series: [
{
type: 'flowGL',
data: data,
particleDensity: 512,
particleSpeed: 2,
particleSize: 1,
// gridWidth: windData.nx,
// gridHeight: windData.ny,
itemStyle: {
opacity: 0.7
}
}
]
};
echartslayer.setChartOptions(option);
});
}

setRef = (x = null) => {
this.container = x;
};

render () {
return (<div ref={this.setRef} className="map-content"></div>);
}
}

export default Index;
Loading

0 comments on commit 1212b7c

Please sign in to comment.