install.js
1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// TODO ECharts GL must be imported whatever component,charts is imported.
import '../../echarts-gl';
import SurfaceSeries from './SurfaceSeries';
import SurfaceView from './SurfaceView';
export function install(registers) {
registers.registerChartView(SurfaceView);
registers.registerSeriesModel(SurfaceSeries);
registers.registerLayout(function (ecModel, api) {
ecModel.eachSeriesByType('surface', function (surfaceModel) {
var cartesian = surfaceModel.coordinateSystem;
if (!cartesian || cartesian.type !== 'cartesian3D') {
if (process.env.NODE_ENV !== 'production') {
console.error('Surface chart only support cartesian3D coordinateSystem');
}
}
var data = surfaceModel.getData();
var points = new Float32Array(3 * data.count());
var nanPoint = [NaN, NaN, NaN];
if (cartesian && cartesian.type === 'cartesian3D') {
var coordDims = cartesian.dimensions;
var dims = coordDims.map(function (coordDim) {
return surfaceModel.coordDimToDataDim(coordDim)[0];
});
data.each(dims, function (x, y, z, idx) {
var pt;
if (!data.hasValue(idx)) {
pt = nanPoint;
}
else {
pt = cartesian.dataToPoint([x, y, z]);
}
points[idx * 3] = pt[0];
points[idx * 3 + 1] = pt[1];
points[idx * 3 + 2] = pt[2];
});
}
data.setLayout('points', points);
});
});
}