mirror of https://gitee.com/antv-l7/antv-l7
fix(src): require 引入方式切换成import
This commit is contained in:
parent
6c42e433e1
commit
b140934f3e
|
@ -1,4 +1,5 @@
|
|||
build/
|
||||
bundler/
|
||||
coverage/
|
||||
lib/
|
||||
dist/
|
||||
|
@ -7,3 +8,5 @@ node_modules/
|
|||
demos/assets/
|
||||
demos/index.html
|
||||
demos/*
|
||||
rollup/*
|
||||
webpack/*
|
||||
|
|
|
@ -11,7 +11,11 @@
|
|||
"G2": true,
|
||||
"_": true,
|
||||
"mapboxgl":true,
|
||||
"dat" : true
|
||||
"dat" : true,
|
||||
},
|
||||
"env": {
|
||||
"browser": true,
|
||||
"node": true
|
||||
},
|
||||
"parser": "babel-eslint",
|
||||
"parserOptions": {
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
* @fileOverview the Attribute base class
|
||||
* @author huangtonger@aliyun.com
|
||||
*/
|
||||
const ColorUtil = require('./color-util');
|
||||
const Util = require('../util');
|
||||
import ColorUtil from './color-util';
|
||||
import Util from '../util';
|
||||
|
||||
function toScaleString(scale, value) {
|
||||
if (Util.isString(value)) {
|
||||
|
@ -171,7 +171,7 @@ class AttributeBase {
|
|||
}
|
||||
if (this.type === 'color' && !Util.isArray(values)) {
|
||||
values = ColorUtil.toRGB(values).map(e => e / 255);
|
||||
// values[3] = values[3] * 255;
|
||||
// values[3] = values[3] * 255;
|
||||
}
|
||||
if (!Util.isArray(values)) {
|
||||
values = [ values ];
|
||||
|
@ -196,4 +196,4 @@ class AttributeBase {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = AttributeBase;
|
||||
export default AttributeBase;
|
||||
|
|
|
@ -2,8 +2,7 @@
|
|||
* @fileOverview 颜色计算的辅助方法
|
||||
* @author dxq613@gmail.com
|
||||
*/
|
||||
|
||||
const Util = require('../util');
|
||||
import Util from '../util';
|
||||
const RGB_REG = /rgba?\(([\s.,0-9]+)\)/;
|
||||
// const RGBA_REG = /rgba\((\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(\d+)\s*\)/;
|
||||
|
||||
|
@ -80,7 +79,7 @@ const ColorUtil = {
|
|||
}
|
||||
return rst;
|
||||
},
|
||||
// 转成 WebGl color buffer
|
||||
// 转成 WebGl color buffer
|
||||
color2Arr(str) {
|
||||
const rgba = this.toRGB(str);
|
||||
return rgba.map(v => v / 255);
|
||||
|
@ -112,4 +111,4 @@ const ColorUtil = {
|
|||
}
|
||||
};
|
||||
|
||||
module.exports = ColorUtil;
|
||||
export default ColorUtil;
|
||||
|
|
|
@ -2,10 +2,9 @@
|
|||
* @fileOverview the color attribute of core
|
||||
* @author huangtonger@aliyun.com
|
||||
*/
|
||||
|
||||
const ColorUtil = require('./color-util');
|
||||
const Base = require('./base');
|
||||
const Util = require('../util');
|
||||
import ColorUtil from './color-util';
|
||||
import Base from './base';
|
||||
import Util from '../util';
|
||||
|
||||
/**
|
||||
* 视觉通道 color
|
||||
|
@ -38,4 +37,4 @@ class Color extends Base {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = Color;
|
||||
export default Color;
|
||||
|
|
|
@ -97,4 +97,4 @@ export const colorScales = {
|
|||
magma: new Uint8Array([ 0, 0, 4, 255, 1, 0, 5, 255, 1, 1, 6, 255, 1, 1, 8, 255, 2, 1, 9, 255, 2, 2, 11, 255, 2, 2, 13, 255, 3, 3, 15, 255, 3, 3, 18, 255, 4, 4, 20, 255, 5, 4, 22, 255, 6, 5, 24, 255, 6, 5, 26, 255, 7, 6, 28, 255, 8, 7, 30, 255, 9, 7, 32, 255, 10, 8, 34, 255, 11, 9, 36, 255, 12, 9, 38, 255, 13, 10, 41, 255, 14, 11, 43, 255, 16, 11, 45, 255, 17, 12, 47, 255, 18, 13, 49, 255, 19, 13, 52, 255, 20, 14, 54, 255, 21, 14, 56, 255, 22, 15, 59, 255, 24, 15, 61, 255, 25, 16, 63, 255, 26, 16, 66, 255, 28, 16, 68, 255, 29, 17, 71, 255, 30, 17, 73, 255, 32, 17, 75, 255, 33, 17, 78, 255, 34, 17, 80, 255, 36, 18, 83, 255, 37, 18, 85, 255, 39, 18, 88, 255, 41, 17, 90, 255, 42, 17, 92, 255, 44, 17, 95, 255, 45, 17, 97, 255, 47, 17, 99, 255, 49, 17, 101, 255, 51, 16, 103, 255, 52, 16, 105, 255, 54, 16, 107, 255, 56, 16, 108, 255, 57, 15, 110, 255, 59, 15, 112, 255, 61, 15, 113, 255, 63, 15, 114, 255, 64, 15, 116, 255, 66, 15, 117, 255, 68, 15, 118, 255, 69, 16, 119, 255, 71, 16, 120, 255, 73, 16, 120, 255, 74, 16, 121, 255, 76, 17, 122, 255, 78, 17, 123, 255, 79, 18, 123, 255, 81, 18, 124, 255, 82, 19, 124, 255, 84, 19, 125, 255, 86, 20, 125, 255, 87, 21, 126, 255, 89, 21, 126, 255, 90, 22, 126, 255, 92, 22, 127, 255, 93, 23, 127, 255, 95, 24, 127, 255, 96, 24, 128, 255, 98, 25, 128, 255, 100, 26, 128, 255, 101, 26, 128, 255, 103, 27, 128, 255, 104, 28, 129, 255, 106, 28, 129, 255, 107, 29, 129, 255, 109, 29, 129, 255, 110, 30, 129, 255, 112, 31, 129, 255, 114, 31, 129, 255, 115, 32, 129, 255, 117, 33, 129, 255, 118, 33, 129, 255, 120, 34, 129, 255, 121, 34, 130, 255, 123, 35, 130, 255, 124, 35, 130, 255, 126, 36, 130, 255, 128, 37, 130, 255, 129, 37, 129, 255, 131, 38, 129, 255, 132, 38, 129, 255, 134, 39, 129, 255, 136, 39, 129, 255, 137, 40, 129, 255, 139, 41, 129, 255, 140, 41, 129, 255, 142, 42, 129, 255, 144, 42, 129, 255, 145, 43, 129, 255, 147, 43, 128, 255, 148, 44, 128, 255, 150, 44, 128, 255, 152, 45, 128, 255, 153, 45, 128, 255, 155, 46, 127, 255, 156, 46, 127, 255, 158, 47, 127, 255, 160, 47, 127, 255, 161, 48, 126, 255, 163, 48, 126, 255, 165, 49, 126, 255, 166, 49, 125, 255, 168, 50, 125, 255, 170, 51, 125, 255, 171, 51, 124, 255, 173, 52, 124, 255, 174, 52, 123, 255, 176, 53, 123, 255, 178, 53, 123, 255, 179, 54, 122, 255, 181, 54, 122, 255, 183, 55, 121, 255, 184, 55, 121, 255, 186, 56, 120, 255, 188, 57, 120, 255, 189, 57, 119, 255, 191, 58, 119, 255, 192, 58, 118, 255, 194, 59, 117, 255, 196, 60, 117, 255, 197, 60, 116, 255, 199, 61, 115, 255, 200, 62, 115, 255, 202, 62, 114, 255, 204, 63, 113, 255, 205, 64, 113, 255, 207, 64, 112, 255, 208, 65, 111, 255, 210, 66, 111, 255, 211, 67, 110, 255, 213, 68, 109, 255, 214, 69, 108, 255, 216, 69, 108, 255, 217, 70, 107, 255, 219, 71, 106, 255, 220, 72, 105, 255, 222, 73, 104, 255, 223, 74, 104, 255, 224, 76, 103, 255, 226, 77, 102, 255, 227, 78, 101, 255, 228, 79, 100, 255, 229, 80, 100, 255, 231, 82, 99, 255, 232, 83, 98, 255, 233, 84, 98, 255, 234, 86, 97, 255, 235, 87, 96, 255, 236, 88, 96, 255, 237, 90, 95, 255, 238, 91, 94, 255, 239, 93, 94, 255, 240, 95, 94, 255, 241, 96, 93, 255, 242, 98, 93, 255, 242, 100, 92, 255, 243, 101, 92, 255, 244, 103, 92, 255, 244, 105, 92, 255, 245, 107, 92, 255, 246, 108, 92, 255, 246, 110, 92, 255, 247, 112, 92, 255, 247, 114, 92, 255, 248, 116, 92, 255, 248, 118, 92, 255, 249, 120, 93, 255, 249, 121, 93, 255, 249, 123, 93, 255, 250, 125, 94, 255, 250, 127, 94, 255, 250, 129, 95, 255, 251, 131, 95, 255, 251, 133, 96, 255, 251, 135, 97, 255, 252, 137, 97, 255, 252, 138, 98, 255, 252, 140, 99, 255, 252, 142, 100, 255, 252, 144, 101, 255, 253, 146, 102, 255, 253, 148, 103, 255, 253, 150, 104, 255, 253, 152, 105, 255, 253, 154, 106, 255, 253, 155, 107, 255, 254, 157, 108, 255, 254, 159, 109, 255, 254, 161, 110, 255, 254, 163, 111, 255, 254, 165, 113, 255, 254, 167, 114, 255, 254, 169, 115, 255, 254, 170, 116, 255, 254, 172, 118, 255, 254, 174, 119, 255, 254, 176, 120, 255, 254, 178, 122, 255, 254, 180, 123, 255, 254, 182, 124, 255, 254, 183, 126, 255, 254, 185, 127, 255, 254, 187, 129, 255, 254, 189, 130, 255, 254, 191, 132, 255, 254, 193, 133, 255, 254, 194, 135, 255, 254, 196, 136, 255, 254, 198, 138, 255, 254, 200, 140, 255, 254, 202, 141, 255, 254, 204, 143, 255, 254, 205, 144, 255, 254, 207, 146, 255, 254, 209, 148, 255, 254, 211, 149, 255, 254, 213, 151, 255, 254, 215, 153, 255, 254, 216, 154, 255, 253, 218, 156, 255, 253, 220, 158, 255, 253, 222, 160, 255, 253, 224, 161, 255, 253, 226, 163, 255, 253, 227, 165, 255, 253, 229, 167, 255, 253, 231, 169, 255, 253, 233, 170, 255, 253, 235, 172, 255, 252, 236, 174, 255, 252, 238, 176, 255, 252, 240, 178, 255, 252, 242, 180, 255, 252, 244, 182, 255, 252, 246, 184, 255, 252, 247, 185, 255, 252, 249, 187, 255, 252, 251, 189, 255, 252, 253, 191, 255 ]),
|
||||
plasma: new Uint8Array([ 13, 8, 135, 255, 16, 7, 136, 255, 19, 7, 137, 255, 22, 7, 138, 255, 25, 6, 140, 255, 27, 6, 141, 255, 29, 6, 142, 255, 32, 6, 143, 255, 34, 6, 144, 255, 36, 6, 145, 255, 38, 5, 145, 255, 40, 5, 146, 255, 42, 5, 147, 255, 44, 5, 148, 255, 46, 5, 149, 255, 47, 5, 150, 255, 49, 5, 151, 255, 51, 5, 151, 255, 53, 4, 152, 255, 55, 4, 153, 255, 56, 4, 154, 255, 58, 4, 154, 255, 60, 4, 155, 255, 62, 4, 156, 255, 63, 4, 156, 255, 65, 4, 157, 255, 67, 3, 158, 255, 68, 3, 158, 255, 70, 3, 159, 255, 72, 3, 159, 255, 73, 3, 160, 255, 75, 3, 161, 255, 76, 2, 161, 255, 78, 2, 162, 255, 80, 2, 162, 255, 81, 2, 163, 255, 83, 2, 163, 255, 85, 2, 164, 255, 86, 1, 164, 255, 88, 1, 164, 255, 89, 1, 165, 255, 91, 1, 165, 255, 92, 1, 166, 255, 94, 1, 166, 255, 96, 1, 166, 255, 97, 0, 167, 255, 99, 0, 167, 255, 100, 0, 167, 255, 102, 0, 167, 255, 103, 0, 168, 255, 105, 0, 168, 255, 106, 0, 168, 255, 108, 0, 168, 255, 110, 0, 168, 255, 111, 0, 168, 255, 113, 0, 168, 255, 114, 1, 168, 255, 116, 1, 168, 255, 117, 1, 168, 255, 119, 1, 168, 255, 120, 1, 168, 255, 122, 2, 168, 255, 123, 2, 168, 255, 125, 3, 168, 255, 126, 3, 168, 255, 128, 4, 168, 255, 129, 4, 167, 255, 131, 5, 167, 255, 132, 5, 167, 255, 134, 6, 166, 255, 135, 7, 166, 255, 136, 8, 166, 255, 138, 9, 165, 255, 139, 10, 165, 255, 141, 11, 165, 255, 142, 12, 164, 255, 143, 13, 164, 255, 145, 14, 163, 255, 146, 15, 163, 255, 148, 16, 162, 255, 149, 17, 161, 255, 150, 19, 161, 255, 152, 20, 160, 255, 153, 21, 159, 255, 154, 22, 159, 255, 156, 23, 158, 255, 157, 24, 157, 255, 158, 25, 157, 255, 160, 26, 156, 255, 161, 27, 155, 255, 162, 29, 154, 255, 163, 30, 154, 255, 165, 31, 153, 255, 166, 32, 152, 255, 167, 33, 151, 255, 168, 34, 150, 255, 170, 35, 149, 255, 171, 36, 148, 255, 172, 38, 148, 255, 173, 39, 147, 255, 174, 40, 146, 255, 176, 41, 145, 255, 177, 42, 144, 255, 178, 43, 143, 255, 179, 44, 142, 255, 180, 46, 141, 255, 181, 47, 140, 255, 182, 48, 139, 255, 183, 49, 138, 255, 184, 50, 137, 255, 186, 51, 136, 255, 187, 52, 136, 255, 188, 53, 135, 255, 189, 55, 134, 255, 190, 56, 133, 255, 191, 57, 132, 255, 192, 58, 131, 255, 193, 59, 130, 255, 194, 60, 129, 255, 195, 61, 128, 255, 196, 62, 127, 255, 197, 64, 126, 255, 198, 65, 125, 255, 199, 66, 124, 255, 200, 67, 123, 255, 201, 68, 122, 255, 202, 69, 122, 255, 203, 70, 121, 255, 204, 71, 120, 255, 204, 73, 119, 255, 205, 74, 118, 255, 206, 75, 117, 255, 207, 76, 116, 255, 208, 77, 115, 255, 209, 78, 114, 255, 210, 79, 113, 255, 211, 81, 113, 255, 212, 82, 112, 255, 213, 83, 111, 255, 213, 84, 110, 255, 214, 85, 109, 255, 215, 86, 108, 255, 216, 87, 107, 255, 217, 88, 106, 255, 218, 90, 106, 255, 218, 91, 105, 255, 219, 92, 104, 255, 220, 93, 103, 255, 221, 94, 102, 255, 222, 95, 101, 255, 222, 97, 100, 255, 223, 98, 99, 255, 224, 99, 99, 255, 225, 100, 98, 255, 226, 101, 97, 255, 226, 102, 96, 255, 227, 104, 95, 255, 228, 105, 94, 255, 229, 106, 93, 255, 229, 107, 93, 255, 230, 108, 92, 255, 231, 110, 91, 255, 231, 111, 90, 255, 232, 112, 89, 255, 233, 113, 88, 255, 233, 114, 87, 255, 234, 116, 87, 255, 235, 117, 86, 255, 235, 118, 85, 255, 236, 119, 84, 255, 237, 121, 83, 255, 237, 122, 82, 255, 238, 123, 81, 255, 239, 124, 81, 255, 239, 126, 80, 255, 240, 127, 79, 255, 240, 128, 78, 255, 241, 129, 77, 255, 241, 131, 76, 255, 242, 132, 75, 255, 243, 133, 75, 255, 243, 135, 74, 255, 244, 136, 73, 255, 244, 137, 72, 255, 245, 139, 71, 255, 245, 140, 70, 255, 246, 141, 69, 255, 246, 143, 68, 255, 247, 144, 68, 255, 247, 145, 67, 255, 247, 147, 66, 255, 248, 148, 65, 255, 248, 149, 64, 255, 249, 151, 63, 255, 249, 152, 62, 255, 249, 154, 62, 255, 250, 155, 61, 255, 250, 156, 60, 255, 250, 158, 59, 255, 251, 159, 58, 255, 251, 161, 57, 255, 251, 162, 56, 255, 252, 163, 56, 255, 252, 165, 55, 255, 252, 166, 54, 255, 252, 168, 53, 255, 252, 169, 52, 255, 253, 171, 51, 255, 253, 172, 51, 255, 253, 174, 50, 255, 253, 175, 49, 255, 253, 177, 48, 255, 253, 178, 47, 255, 253, 180, 47, 255, 253, 181, 46, 255, 254, 183, 45, 255, 254, 184, 44, 255, 254, 186, 44, 255, 254, 187, 43, 255, 254, 189, 42, 255, 254, 190, 42, 255, 254, 192, 41, 255, 253, 194, 41, 255, 253, 195, 40, 255, 253, 197, 39, 255, 253, 198, 39, 255, 253, 200, 39, 255, 253, 202, 38, 255, 253, 203, 38, 255, 252, 205, 37, 255, 252, 206, 37, 255, 252, 208, 37, 255, 252, 210, 37, 255, 251, 211, 36, 255, 251, 213, 36, 255, 251, 215, 36, 255, 250, 216, 36, 255, 250, 218, 36, 255, 249, 220, 36, 255, 249, 221, 37, 255, 248, 223, 37, 255, 248, 225, 37, 255, 247, 226, 37, 255, 247, 228, 37, 255, 246, 230, 38, 255, 246, 232, 38, 255, 245, 233, 38, 255, 245, 235, 39, 255, 244, 237, 39, 255, 243, 238, 39, 255, 243, 240, 39, 255, 242, 242, 39, 255, 241, 244, 38, 255, 241, 245, 37, 255, 240, 247, 36, 255, 240, 249, 33, 255 ])
|
||||
};
|
||||
// module.exports = colorScales;
|
||||
// export default colorScales;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* @Last Modified time: 2018-07-15 17:26:40
|
||||
*/
|
||||
|
||||
const Base = require('./base');
|
||||
import Base from './base';
|
||||
|
||||
/**
|
||||
* 视觉通道 symbol
|
||||
|
@ -19,4 +19,4 @@ class Filter extends Base {
|
|||
this.gradient = null;
|
||||
}
|
||||
}
|
||||
module.exports = Filter;
|
||||
export default Filter;
|
||||
|
|
|
@ -1,10 +1,19 @@
|
|||
|
||||
const Base = require('./base');
|
||||
Base.Color = require('./color');
|
||||
Base.Size = require('./size');
|
||||
Base.Opacity = require('./opacity');
|
||||
Base.Shape = require('./shape');
|
||||
Base.Position = require('./position');
|
||||
Base.Symbol = require('./symbol');
|
||||
Base.Filter = require('./filter');
|
||||
module.exports = Base;
|
||||
import Base from './base';
|
||||
import Color from './color';
|
||||
import Size from './size';
|
||||
import Opacity from './opacity';
|
||||
import Shape from './shape';
|
||||
import Position from './position';
|
||||
import Symbol from './symbol';
|
||||
import Filter from './filter';
|
||||
|
||||
Base.Color = Color;
|
||||
Base.Size = Size;
|
||||
Base.Opacity = Opacity;
|
||||
Base.Shape = Shape;
|
||||
Base.Position = Position;
|
||||
Base.Symbol = Symbol;
|
||||
Base.Filter = Filter;
|
||||
|
||||
export default Base;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* @author huangtonger@aliyun.com
|
||||
*/
|
||||
|
||||
const Base = require('./base');
|
||||
import Base from './base';
|
||||
|
||||
/**
|
||||
* 视觉通道 Opacity
|
||||
|
@ -18,4 +18,4 @@ class Opacity extends Base {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = Opacity;
|
||||
export default Opacity;
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
*/
|
||||
|
||||
|
||||
const Util = require('../util');
|
||||
const Base = require('./base');
|
||||
import Base from './base';
|
||||
import Util from '../util';
|
||||
|
||||
class Position extends Base {
|
||||
constructor(cfg) {
|
||||
|
@ -88,4 +88,4 @@ class Position extends Base {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = Position;
|
||||
export default Position;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*/
|
||||
|
||||
|
||||
const Base = require('./base');
|
||||
import Base from './base';
|
||||
|
||||
/**
|
||||
* 视觉通道 Shape
|
||||
|
@ -26,7 +26,7 @@ class Shape extends Base {
|
|||
const index = Math.round((values.length - 1) * percent);
|
||||
return values[index];
|
||||
}
|
||||
/**
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
_getAttrValue(scale, value) {
|
||||
|
@ -41,4 +41,4 @@ class Shape extends Base {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = Shape;
|
||||
export default Shape;
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
* @author huangtonger@aliyun.com
|
||||
*/
|
||||
|
||||
const Base = require('./base');
|
||||
const Util = require('../util');
|
||||
import Base from './base';
|
||||
import Util from '../util';
|
||||
|
||||
/**
|
||||
* 视觉通道 size
|
||||
|
@ -20,7 +20,7 @@ class Size extends Base {
|
|||
}
|
||||
|
||||
mapping() {
|
||||
// 重构
|
||||
// 重构
|
||||
const self = this;
|
||||
const outputs = [];
|
||||
const scales = self.scales;
|
||||
|
@ -62,4 +62,4 @@ class Size extends Base {
|
|||
|
||||
}
|
||||
|
||||
module.exports = Size;
|
||||
export default Size;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* @Last Modified time: 2018-07-02 18:24:58
|
||||
*/
|
||||
|
||||
const Base = require('./base');
|
||||
import Base from './base';
|
||||
|
||||
/**
|
||||
* 视觉通道 symbol
|
||||
|
@ -19,4 +19,4 @@ class Symbol extends Base {
|
|||
this.gradient = null;
|
||||
}
|
||||
}
|
||||
module.exports = Symbol;
|
||||
export default Symbol;
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
/**
|
||||
* @fileOverview chart component module
|
||||
* @author sima.zhang1990@gmail.com
|
||||
*/
|
||||
module.exports = {
|
||||
Axis: require('./axis/index'),
|
||||
Guide: require('./guide/index'),
|
||||
Label: require('./label/index'),
|
||||
Legend: require('./legend/index'),
|
||||
Plot: require('./plot'),
|
||||
Tooltip: require('./tooltip/index')
|
||||
};
|
|
@ -1,568 +0,0 @@
|
|||
/**
|
||||
* @fileOverview The class of tooltip
|
||||
* @author sima.zhang
|
||||
*/
|
||||
const Util = require('../../util');
|
||||
const Base = require('../../base');
|
||||
const Global = require('../../global');
|
||||
const { DomUtil } = require('@antv/g');
|
||||
|
||||
const CONTAINER_CLASS = 'g2-tooltip';
|
||||
const TITLE_CLASS = 'g2-tooltip-title';
|
||||
const LIST_CLASS = 'g2-tooltip-list';
|
||||
const MARKER_CLASS = 'g2-tooltip-marker';
|
||||
const LIST_ITEM_CLASS = 'g2-tooltip-list-item';
|
||||
|
||||
function find(dom, cls) {
|
||||
return dom.getElementsByClassName(cls)[0];
|
||||
}
|
||||
|
||||
function refixTooltipPosition(x, y, el, viewWidth, viewHeight) {
|
||||
const width = el.clientWidth;
|
||||
const height = el.clientHeight;
|
||||
const gap = 20;
|
||||
|
||||
if (x + width + gap > viewWidth) {
|
||||
x -= width + gap;
|
||||
x = x < 0 ? 0 : x;
|
||||
} else {
|
||||
x += gap;
|
||||
}
|
||||
if (y + height + gap > viewHeight) {
|
||||
y -= height + gap;
|
||||
y = x < 0 ? 0 : y;
|
||||
} else {
|
||||
y += gap;
|
||||
}
|
||||
return [ x, y ];
|
||||
}
|
||||
|
||||
function calcTooltipPosition(x, y, position, dom, target) {
|
||||
const domWidth = dom.clientWidth;
|
||||
const domHeight = dom.clientHeight;
|
||||
let rectWidth = 0;
|
||||
let rectHeight = 0;
|
||||
let gap = 20;
|
||||
|
||||
if (target) {
|
||||
const rect = target.getBBox();
|
||||
rectWidth = rect.width;
|
||||
rectHeight = rect.height;
|
||||
x = rect.x;
|
||||
y = rect.y;
|
||||
gap = 5;
|
||||
}
|
||||
switch (position) {
|
||||
case 'inside':
|
||||
x = x + rectWidth / 2 - domWidth / 2;
|
||||
y = y + rectHeight / 2 - domHeight / 2;
|
||||
break;
|
||||
case 'top':
|
||||
x = x + rectWidth / 2 - domWidth / 2;
|
||||
y = y - domHeight - gap;
|
||||
break;
|
||||
case 'left':
|
||||
x = x - domWidth - gap;
|
||||
y = y + rectHeight / 2 - domHeight / 2;
|
||||
break;
|
||||
case 'right':
|
||||
x = x + rectWidth + gap;
|
||||
y = y + rectHeight / 2 - domHeight / 2;
|
||||
break;
|
||||
case 'bottom':
|
||||
default:
|
||||
x = x + rectWidth / 2 - domWidth / 2;
|
||||
y = y + rectHeight + gap;
|
||||
break;
|
||||
}
|
||||
return [ x, y ];
|
||||
}
|
||||
|
||||
function confineTooltipPosition(x, y, el, plotRange) {
|
||||
const gap = 20;
|
||||
const width = el.clientWidth;
|
||||
const height = el.clientHeight;
|
||||
if (x + width > plotRange.tr.x) {
|
||||
x -= width + 2 * gap;
|
||||
}
|
||||
|
||||
if (x < plotRange.tl.x) {
|
||||
x = plotRange.tl.x;
|
||||
}
|
||||
|
||||
if (y + height > plotRange.bl.y) {
|
||||
y -= height + 2 * gap;
|
||||
}
|
||||
|
||||
if (y < plotRange.tl.y) {
|
||||
y = plotRange.tl.y;
|
||||
}
|
||||
|
||||
return [ x, y ];
|
||||
}
|
||||
|
||||
class Tooltip extends Base {
|
||||
getDefaultCfg() {
|
||||
return {
|
||||
/**
|
||||
* 右下角坐标
|
||||
* @type {Number}
|
||||
*/
|
||||
x: 0,
|
||||
/**
|
||||
* y 右下角坐标
|
||||
* @type {Number}
|
||||
*/
|
||||
y: 0,
|
||||
/**
|
||||
* tooltip 记录项
|
||||
* @type {Array}
|
||||
*/
|
||||
items: null,
|
||||
/**
|
||||
* 是否展示 title
|
||||
* @type {Boolean}
|
||||
*/
|
||||
showTitle: true,
|
||||
/**
|
||||
* tooltip 辅助线配置
|
||||
* @type {Object}
|
||||
*/
|
||||
crosshairs: null,
|
||||
/**
|
||||
* 视图范围
|
||||
* @type {Object}
|
||||
*/
|
||||
plotRange: null,
|
||||
/**
|
||||
* x轴上,移动到位置的偏移量
|
||||
* @type {Number}
|
||||
*/
|
||||
offset: 10,
|
||||
/**
|
||||
* 时间戳
|
||||
* @type {Number}
|
||||
*/
|
||||
timeStamp: 0,
|
||||
/**
|
||||
* tooltip 容器模板
|
||||
* @type {String}
|
||||
*/
|
||||
containerTpl: '<div class="' + CONTAINER_CLASS + '">'
|
||||
+ '<div class="' + TITLE_CLASS + '"></div>'
|
||||
+ '<ul class="' + LIST_CLASS + '"></ul>'
|
||||
+ '</div>',
|
||||
/**
|
||||
* tooltip 列表项模板
|
||||
* @type {String}
|
||||
*/
|
||||
itemTpl: '<li data-index={index}>'
|
||||
+ '<span style="background-color:{color};" class=' + MARKER_CLASS + '></span>'
|
||||
+ '{name}: {value}</li>',
|
||||
/**
|
||||
* 将 tooltip 展示在指定区域内
|
||||
* @type {Boolean}
|
||||
*/
|
||||
inPlot: true,
|
||||
/**
|
||||
* tooltip 内容跟随鼠标移动
|
||||
* @type {Boolean}
|
||||
*/
|
||||
follow: true,
|
||||
/**
|
||||
* 是否允许鼠标停留在 tooltip 上,默认不允许
|
||||
* @type {Boolean}
|
||||
*/
|
||||
enterable: false
|
||||
};
|
||||
}
|
||||
|
||||
_initTooltipWrapper() {
|
||||
const self = this;
|
||||
const containerTpl = self.get('containerTpl');
|
||||
const outterNode = self.get('canvas').get('el').parentNode;
|
||||
let container;
|
||||
if (/^\#/.test(containerTpl)) { // 如果传入 dom 节点的 id
|
||||
const id = containerTpl.replace('#', '');
|
||||
container = document.getElementById(id);
|
||||
} else {
|
||||
container = DomUtil.createDom(containerTpl);
|
||||
DomUtil.modifyCSS(container, self.get(CONTAINER_CLASS));
|
||||
outterNode.appendChild(container);
|
||||
outterNode.style.position = 'relative';
|
||||
}
|
||||
self.set('container', container);
|
||||
}
|
||||
|
||||
_init() {
|
||||
const crosshairs = this.get('crosshairs');
|
||||
const frontPlot = this.get('frontPlot');
|
||||
const backPlot = this.get('backPlot');
|
||||
let crosshairsGroup;
|
||||
|
||||
if (crosshairs) {
|
||||
if (crosshairs.type === 'rect') {
|
||||
this.set('crosshairs', Util.deepMix({}, Global.tooltipCrosshairsRect, crosshairs));
|
||||
crosshairsGroup = backPlot.addGroup({
|
||||
zIndex: 0
|
||||
});
|
||||
} else {
|
||||
this.set('crosshairs', Util.deepMix({}, Global.tooltipCrosshairsLine, crosshairs));
|
||||
crosshairsGroup = frontPlot.addGroup();
|
||||
}
|
||||
}
|
||||
|
||||
this.set('crosshairsGroup', crosshairsGroup);
|
||||
this._initTooltipWrapper();
|
||||
}
|
||||
|
||||
constructor(cfg) {
|
||||
super(cfg);
|
||||
this._init(); // 初始化属性
|
||||
|
||||
if (this.get('items')) {
|
||||
this._renderTooltip();
|
||||
}
|
||||
this._renderCrosshairs();
|
||||
}
|
||||
|
||||
|
||||
_clearDom() {
|
||||
const container = this.get('container');
|
||||
const titleDom = find(container, TITLE_CLASS);
|
||||
const listDom = find(container, LIST_CLASS);
|
||||
if (titleDom) {
|
||||
titleDom.innerHTML = '';
|
||||
}
|
||||
if (listDom) {
|
||||
listDom.innerHTML = '';
|
||||
}
|
||||
}
|
||||
|
||||
_addItem(item, index) {
|
||||
const itemTpl = this.get('itemTpl'); // TODO: 有可能是个回调函数
|
||||
|
||||
const itemDiv = Util.substitute(itemTpl, Util.mix({
|
||||
index
|
||||
}, item));
|
||||
|
||||
const itemDOM = DomUtil.createDom(itemDiv);
|
||||
DomUtil.modifyCSS(itemDOM, this.get(LIST_ITEM_CLASS));
|
||||
const markerDom = find(itemDOM, MARKER_CLASS);
|
||||
if (markerDom) {
|
||||
DomUtil.modifyCSS(markerDom, this.get(MARKER_CLASS));
|
||||
}
|
||||
|
||||
return itemDOM;
|
||||
}
|
||||
|
||||
_renderTooltip() {
|
||||
const self = this;
|
||||
const showTitle = self.get('showTitle');
|
||||
const titleContent = self.get('titleContent');
|
||||
const container = self.get('container');
|
||||
const titleDom = find(container, TITLE_CLASS);
|
||||
const listDom = find(container, LIST_CLASS);
|
||||
const items = self.get('items');
|
||||
self._clearDom();
|
||||
|
||||
if (titleDom && showTitle) {
|
||||
DomUtil.modifyCSS(titleDom, self.get(TITLE_CLASS));
|
||||
titleDom.innerHTML = titleContent;
|
||||
}
|
||||
|
||||
if (listDom) {
|
||||
DomUtil.modifyCSS(listDom, self.get(LIST_CLASS));
|
||||
Util.each(items, (item, index) => {
|
||||
listDom.appendChild(self._addItem(item, index));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
_clearCrosshairsGroup() {
|
||||
const crosshairsGroup = this.get('crosshairsGroup');
|
||||
this.set('crossLineShapeX', null);
|
||||
this.set('crossLineShapeY', null);
|
||||
this.set('crosshairsRectShape', null);
|
||||
crosshairsGroup.clear();
|
||||
}
|
||||
|
||||
_renderCrosshairs() {
|
||||
const crosshairs = this.get('crosshairs');
|
||||
const canvas = this.get('canvas');
|
||||
const plotRange = this.get('plotRange');
|
||||
const isTransposed = this.get('isTransposed');
|
||||
if (crosshairs) {
|
||||
this._clearCrosshairsGroup();
|
||||
switch (crosshairs.type) {
|
||||
case 'x':
|
||||
this._renderHorizontalLine(canvas, plotRange);
|
||||
break;
|
||||
case 'y':
|
||||
this._renderVerticalLine(canvas, plotRange);
|
||||
break;
|
||||
case 'cross':
|
||||
this._renderHorizontalLine(canvas, plotRange);
|
||||
this._renderVerticalLine(canvas, plotRange);
|
||||
break;
|
||||
case 'rect':
|
||||
this._renderBackground(canvas, plotRange);
|
||||
break;
|
||||
default:
|
||||
isTransposed ? this._renderHorizontalLine(canvas, plotRange) : this._renderVerticalLine(canvas, plotRange);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_addCrossLineShape(attrs, type) {
|
||||
const crosshairsGroup = this.get('crosshairsGroup');
|
||||
const shape = crosshairsGroup.addShape('line', {
|
||||
attrs
|
||||
});
|
||||
shape.hide();
|
||||
this.set('crossLineShape' + type, shape);
|
||||
return shape;
|
||||
}
|
||||
|
||||
_renderVerticalLine(canvas, plotRange) {
|
||||
const { style } = this.get('crosshairs');
|
||||
const attrs = Util.mix({
|
||||
x1: 0,
|
||||
y1: plotRange ? plotRange.bl.y : canvas.get('height'),
|
||||
x2: 0,
|
||||
y2: plotRange ? plotRange.tl.y : 0
|
||||
}, style);
|
||||
|
||||
this._addCrossLineShape(attrs, 'Y');
|
||||
}
|
||||
|
||||
_renderHorizontalLine(canvas, plotRange) {
|
||||
const { style } = this.get('crosshairs');
|
||||
const attrs = Util.mix({
|
||||
x1: plotRange ? plotRange.bl.x : canvas.get('width'),
|
||||
y1: 0,
|
||||
x2: plotRange ? plotRange.br.x : 0,
|
||||
y2: 0
|
||||
}, style);
|
||||
|
||||
this._addCrossLineShape(attrs, 'X');
|
||||
}
|
||||
|
||||
_renderBackground(canvas, plotRange) {
|
||||
const { style } = this.get('crosshairs');
|
||||
const crosshairsGroup = this.get('crosshairsGroup');
|
||||
const attrs = Util.mix({
|
||||
x: plotRange ? plotRange.tl.x : 0,
|
||||
y: plotRange ? plotRange.tl.y : canvas.get('height'),
|
||||
width: plotRange ? plotRange.br.x - plotRange.bl.x : canvas.get('width'),
|
||||
height: plotRange ? Math.abs(plotRange.tl.y - plotRange.bl.y) : canvas.get('height')
|
||||
}, style);
|
||||
|
||||
const shape = crosshairsGroup.addShape('rect', {
|
||||
attrs
|
||||
});
|
||||
shape.hide();
|
||||
this.set('crosshairsRectShape', shape);
|
||||
return shape;
|
||||
}
|
||||
|
||||
isContentChange(title, items) {
|
||||
const titleContent = this.get('titleContent');
|
||||
const lastItems = this.get('items');
|
||||
let isChanged = !(title === titleContent && lastItems.length === items.length);
|
||||
if (!isChanged) {
|
||||
Util.each(items, (item, index) => {
|
||||
const preItem = lastItems[index];
|
||||
isChanged = (item.value !== preItem.value) || (item.color !== preItem.color) || (item.name !== preItem.name) || (item.title !== preItem.title);
|
||||
if (isChanged) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return isChanged;
|
||||
}
|
||||
|
||||
setContent(title, items) {
|
||||
// const isChange = this.isContentChange(title, items);
|
||||
// if (isChange) {
|
||||
// 在外面进行判断是否内容发生改变
|
||||
const timeStamp = +new Date();
|
||||
this.set('items', items);
|
||||
this.set('titleContent', title);
|
||||
this.set('timeStamp', timeStamp);
|
||||
this._renderTooltip();
|
||||
// }
|
||||
return this;
|
||||
}
|
||||
|
||||
setMarkers(markerItems, markerCfg) {
|
||||
const self = this;
|
||||
let markerGroup = self.get('markerGroup');
|
||||
const frontPlot = self.get('frontPlot');
|
||||
if (!markerGroup) {
|
||||
markerGroup = frontPlot.addGroup({
|
||||
zIndex: 1,
|
||||
capture: false // 不进行拾取
|
||||
});
|
||||
self.set('markerGroup', markerGroup);
|
||||
} else {
|
||||
markerGroup.clear();
|
||||
}
|
||||
Util.each(markerItems, item => {
|
||||
markerGroup.addShape('marker', {
|
||||
color: item.color,
|
||||
attrs: Util.mix({}, markerCfg, {
|
||||
x: item.x,
|
||||
y: item.y
|
||||
})
|
||||
});
|
||||
});
|
||||
this.set('markerItems', markerItems);
|
||||
}
|
||||
|
||||
clearMarkers() {
|
||||
const markerGroup = this.get('markerGroup');
|
||||
markerGroup && markerGroup.clear();
|
||||
}
|
||||
|
||||
setPosition(x, y, target) {
|
||||
const container = this.get('container');
|
||||
const crossLineShapeX = this.get('crossLineShapeX');
|
||||
const crossLineShapeY = this.get('crossLineShapeY');
|
||||
const crosshairsRectShape = this.get('crosshairsRectShape');
|
||||
let endx = x;
|
||||
let endy = y;
|
||||
// const outterNode = this.get('canvas').get('el').parentNode;
|
||||
const outterNode = this.get('canvas').get('el');
|
||||
const viewWidth = DomUtil.getWidth(outterNode);
|
||||
const viewHeight = DomUtil.getHeight(outterNode);
|
||||
let offset = this.get('offset');
|
||||
|
||||
let position;
|
||||
if (this.get('position')) {
|
||||
position = calcTooltipPosition(x, y, this.get('position'), container, target);
|
||||
x = position[0];
|
||||
y = position[1];
|
||||
} else if (!this.get('position')) {
|
||||
position = refixTooltipPosition(x, y, container, viewWidth, viewHeight);
|
||||
x = position[0];
|
||||
y = position[1];
|
||||
}
|
||||
|
||||
if (this.get('inPlot')) { // tooltip 必须限制在绘图区域内
|
||||
const plotRange = this.get('plotRange');
|
||||
position = confineTooltipPosition(x, y, container, plotRange);
|
||||
x = position[0];
|
||||
y = position[1];
|
||||
}
|
||||
|
||||
if (this.get('x') !== x || this.get('y') !== y) {
|
||||
const markerItems = this.get('markerItems');
|
||||
if (!Util.isEmpty(markerItems)) {
|
||||
endx = markerItems[0].x;
|
||||
endy = markerItems[0].y;
|
||||
}
|
||||
if (crossLineShapeY) { // 第一次进入时,画布需要单独绘制,所以需要先设定corss的位置
|
||||
crossLineShapeY.move(endx, 0);
|
||||
}
|
||||
if (crossLineShapeX) {
|
||||
crossLineShapeX.move(0, endy);
|
||||
}
|
||||
|
||||
if (crosshairsRectShape) { // 绘制矩形辅助框,只在直角坐标系下生效
|
||||
const isTransposed = this.get('isTransposed');
|
||||
const items = this.get('items');
|
||||
const firstItem = items[0];
|
||||
const lastItem = items[items.length - 1];
|
||||
const dim = isTransposed ? 'y' : 'x';
|
||||
const attr = isTransposed ? 'height' : 'width';
|
||||
let startDim = firstItem[dim];
|
||||
if (items.length > 1 && firstItem[dim] > lastItem[dim]) {
|
||||
startDim = lastItem[dim];
|
||||
}
|
||||
|
||||
if (this.get('crosshairs').width) { // 用户定义了 width
|
||||
crosshairsRectShape.attr(dim, startDim - this.get('crosshairs').width / 2);
|
||||
crosshairsRectShape.attr(attr, this.get('crosshairs').width);
|
||||
} else {
|
||||
if (Util.isArray(firstItem.point[dim]) && !firstItem.size) { // 直方图
|
||||
const width = firstItem.point[dim][1] - firstItem.point[dim][0];
|
||||
crosshairsRectShape.attr(dim, firstItem.point[dim][0]);
|
||||
crosshairsRectShape.attr(attr, width);
|
||||
} else {
|
||||
offset = (3 * firstItem.size) / 4;
|
||||
crosshairsRectShape.attr(dim, startDim - offset);
|
||||
|
||||
if (items.length === 1) {
|
||||
crosshairsRectShape.attr(attr, (3 * firstItem.size) / 2);
|
||||
} else {
|
||||
crosshairsRectShape.attr(attr, Math.abs(lastItem[dim] - firstItem[dim]) + 2 * offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const follow = this.get('follow');
|
||||
container.style.left = follow ? (x + 'px') : 0;
|
||||
container.style.top = follow ? (y + 'px') : 0;
|
||||
}
|
||||
}
|
||||
|
||||
show() {
|
||||
const crossLineShapeX = this.get('crossLineShapeX');
|
||||
const crossLineShapeY = this.get('crossLineShapeY');
|
||||
const crosshairsRectShape = this.get('crosshairsRectShape');
|
||||
const markerGroup = this.get('markerGroup');
|
||||
const container = this.get('container');
|
||||
const canvas = this.get('canvas');
|
||||
crossLineShapeX && crossLineShapeX.show();
|
||||
crossLineShapeY && crossLineShapeY.show();
|
||||
crosshairsRectShape && crosshairsRectShape.show();
|
||||
markerGroup && markerGroup.show();
|
||||
super.show();
|
||||
container.style.visibility = 'visible';
|
||||
// canvas.sort();
|
||||
canvas.draw();
|
||||
}
|
||||
|
||||
hide() {
|
||||
const self = this;
|
||||
const container = self.get('container');
|
||||
const crossLineShapeX = self.get('crossLineShapeX');
|
||||
const crossLineShapeY = self.get('crossLineShapeY');
|
||||
const crosshairsRectShape = this.get('crosshairsRectShape');
|
||||
const markerGroup = self.get('markerGroup');
|
||||
const canvas = self.get('canvas');
|
||||
container.style.visibility = 'hidden';
|
||||
crossLineShapeX && crossLineShapeX.hide();
|
||||
crossLineShapeY && crossLineShapeY.hide();
|
||||
crosshairsRectShape && crosshairsRectShape.hide();
|
||||
markerGroup && markerGroup.hide();
|
||||
super.hide();
|
||||
canvas.draw();
|
||||
}
|
||||
|
||||
destroy() {
|
||||
const self = this;
|
||||
const crossLineShapeX = self.get('crossLineShapeX');
|
||||
const crossLineShapeY = self.get('crossLineShapeY');
|
||||
const markerGroup = self.get('markerGroup');
|
||||
const crosshairsRectShape = self.get('crosshairsRectShape');
|
||||
const container = self.get('container');
|
||||
const containerTpl = self.get('containerTpl');
|
||||
|
||||
if (container && !(/^\#/.test(containerTpl))) {
|
||||
container.parentNode.removeChild(container);
|
||||
}
|
||||
|
||||
crossLineShapeX && crossLineShapeX.remove();
|
||||
crossLineShapeY && crossLineShapeY.remove();
|
||||
markerGroup && markerGroup.remove();
|
||||
crosshairsRectShape && crosshairsRectShape.remove();
|
||||
// super.remove();
|
||||
super.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Tooltip;
|
|
@ -4,7 +4,7 @@
|
|||
*/
|
||||
|
||||
import EventEmitter from 'wolfy87-eventemitter';
|
||||
import { assign } from '../util';
|
||||
import Util from '../util';
|
||||
|
||||
class Base extends EventEmitter {
|
||||
|
||||
|
@ -19,7 +19,7 @@ class Base extends EventEmitter {
|
|||
};
|
||||
const defaultCfg = this.getDefaultCfg();
|
||||
this._attrs = attrs;
|
||||
assign(attrs, defaultCfg, cfg);
|
||||
Util.assign(attrs, defaultCfg, cfg);
|
||||
}
|
||||
|
||||
get(name) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import Scale from './scale';
|
||||
export {
|
||||
export default {
|
||||
Scale
|
||||
};
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
* @author dxq613@gmail.com
|
||||
*/
|
||||
|
||||
const Util = require('../../util');
|
||||
const Global = require('../../global');
|
||||
const Scale = require('../../scale/');
|
||||
import Util from '../../util';
|
||||
import Global from '../../global';
|
||||
import Scale from '../../scale/';
|
||||
const dateRegex = /^(?:(?!0000)[0-9]{4}([-/.]+)(?:(?:0?[1-9]|1[0-2])\1(?:0?[1-9]|1[0-9]|2[0-8])|(?:0?[13-9]|1[0-2])\1(?:29|30)|(?:0?[13578]|1[02])\1(?:31))|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)([-/.]?)0?2\2(?:29))(\s+([01]|([01][0-9]|2[0-3])):([0-9]|[0-5][0-9]):([0-9]|[0-5][0-9]))?$/;
|
||||
const TYPES = {
|
||||
LINEAR: 'linear',
|
||||
|
@ -111,4 +111,4 @@ class ScaleController {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = ScaleController;
|
||||
export default ScaleController;
|
||||
|
|
|
@ -18,7 +18,7 @@ export default class LoadImage extends EventEmitter {
|
|||
this.imagesIds = [];
|
||||
}
|
||||
addImage(id, opt) {
|
||||
this.imagesCount ++;
|
||||
this.imagesCount++;
|
||||
this.imagesIds.push(id);
|
||||
const imageCount = this.imagesCount;
|
||||
const x = imageCount % 8 * this.imageWidth;
|
||||
|
|
|
@ -9,7 +9,7 @@ import source from './source';
|
|||
import PickingMaterial from '../core/engine/picking/pickingMaterial';
|
||||
import Attr from '../attr/index';
|
||||
import Util from '../util';
|
||||
const Global = require('../global');
|
||||
import Global from '../global';
|
||||
let id = 1;
|
||||
function parseFields(field) {
|
||||
if (Util.isArray(field)) {
|
||||
|
@ -183,7 +183,6 @@ export default class Layer extends Base {
|
|||
if (colorItem.indexOf(item) !== -1 && styleOptions[item] !== 'none') {
|
||||
styleOptions[item] = ColorUtil.color2RGBA(styleOptions[item]);
|
||||
}
|
||||
styleOptions[item] = styleOptions[item];
|
||||
}
|
||||
this.set('styleOptions', styleOptions);
|
||||
return this;
|
||||
|
@ -525,7 +524,7 @@ export default class Layer extends Base {
|
|||
this._updateMaping();
|
||||
|
||||
}
|
||||
/**
|
||||
/**
|
||||
* 用于过滤数据
|
||||
* @param {*} object 需要过滤的mesh
|
||||
*/
|
||||
|
|
|
@ -25,7 +25,7 @@ export default class Scene extends Base {
|
|||
this.workerPool = new WorkerPool();
|
||||
compileBuiltinModules();
|
||||
}
|
||||
// 为pickup场景添加 object 对象
|
||||
// 为pickup场景添加 object 对象
|
||||
addPickMesh(object) {
|
||||
this._engine._picking.add(object);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
import Base from './base';
|
||||
const Controller = require('./controller/index');
|
||||
import Controller from './controller/index';
|
||||
import { getTransform, getParser } from '../source';
|
||||
import { getMap } from '../map/index';
|
||||
export default class Source extends Base {
|
||||
|
|
|
@ -23,16 +23,16 @@ export { Vector2 } from 'three/src/math/Vector2.js';
|
|||
export { ShaderMaterial } from 'three/src/materials/ShaderMaterial.js';
|
||||
export { DataTexture } from 'three/src/textures/DataTexture.js';
|
||||
export {
|
||||
Float64BufferAttribute,
|
||||
Float32BufferAttribute,
|
||||
Uint32BufferAttribute,
|
||||
Int32BufferAttribute,
|
||||
Uint16BufferAttribute,
|
||||
Int16BufferAttribute,
|
||||
Uint8ClampedBufferAttribute,
|
||||
Uint8BufferAttribute,
|
||||
Int8BufferAttribute,
|
||||
BufferAttribute
|
||||
Float64BufferAttribute,
|
||||
Float32BufferAttribute,
|
||||
Uint32BufferAttribute,
|
||||
Int32BufferAttribute,
|
||||
Uint16BufferAttribute,
|
||||
Int16BufferAttribute,
|
||||
Uint8ClampedBufferAttribute,
|
||||
Uint8BufferAttribute,
|
||||
Int8BufferAttribute,
|
||||
BufferAttribute
|
||||
} from 'three/src/core/BufferAttribute.js';
|
||||
|
||||
// export * from '../../build/Three.js';
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -3,8 +3,9 @@ import { regularShape } from '../shape/index';
|
|||
import * as polygonPath from '../shape/path';
|
||||
import * as polygonShape from '../shape/polygon';
|
||||
import * as lineShape from '../shape/line';
|
||||
import { pointShape } from '../../global';
|
||||
import Global from '../../global';
|
||||
import Util from '../../util';
|
||||
const { pointShape } = Global;
|
||||
export default class PointBuffer extends BufferBase {
|
||||
geometryBuffer() {
|
||||
const type = this.get('type');
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import { pointShape } from '../../../global';
|
||||
import Global from '../../../global';
|
||||
import * as THREE from '../../../core/three';
|
||||
import * as polygonShape from '../../shape/polygon';
|
||||
import * as polygonPath from '../../shape/path';
|
||||
import Util from '../../../util';
|
||||
const { pointShape } = Global;
|
||||
export default function fillBuffer(layerData) {
|
||||
const attribute = {
|
||||
vertices: [],
|
||||
|
|
|
@ -6,7 +6,7 @@ export default function NormalBuffer(layerData) {
|
|||
pickingIds: []
|
||||
};
|
||||
layerData.forEach(item => {
|
||||
const { color, size, id, coordinates} = item;
|
||||
const { color, size, id, coordinates } = item;
|
||||
attributes.vertices.push(...coordinates);
|
||||
attributes.colors.push(...color);
|
||||
attributes.pickingIds.push(id);
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import * as polygonPath from '../../shape/path';
|
||||
import * as polygonShape from '../../shape/polygon';
|
||||
import * as lineShape from '../../shape/line';
|
||||
import { pointShape } from '../../../global';
|
||||
import Global from '../../../global';
|
||||
const { pointShape } = Global;
|
||||
import Util from '../../../util';
|
||||
export default function StrokeBuffer(layerData, style) {
|
||||
const attribute = {
|
||||
|
@ -26,7 +27,7 @@ export default function StrokeBuffer(layerData, style) {
|
|||
} else if (pointShape['3d'].indexOf(shape) !== -1) {
|
||||
Util.isArray(size) || (size = [ size, size, size ]);
|
||||
const polygonExtrudePath = polygonShape.extrudeline([ path ]);
|
||||
// TODO 3d line
|
||||
// TODO 3d line
|
||||
polygon = lineShape.Line([ polygonExtrudePath ], { size: [ strokeWidth, 0 ], color: stroke, id }, positionsIndex);
|
||||
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ function loadTextTexture(url, cb) {
|
|||
img.src = url;
|
||||
|
||||
}
|
||||
/**
|
||||
/**
|
||||
* 计算每个标注词语的位置
|
||||
* @param {*} chars 文本信息
|
||||
* @param {*} pos 文字三维空间坐标
|
||||
|
@ -109,18 +109,18 @@ function drawGlyph(chars, pos, text, pen, size, colors, textureElements, originP
|
|||
pos[0] + originX, pos[1] + originY, 0,
|
||||
pos[0] + originX, pos[1] + originY, 0,
|
||||
pos[0] + originX, pos[1] + originY, 0,
|
||||
);
|
||||
);
|
||||
const bx = 0;
|
||||
const by = metrics.size / 2 + buffer;
|
||||
textSizes.push(
|
||||
((bx - buffer + width) * scale), (height - by) * scale,
|
||||
((bx - buffer) * scale), (height - by) * scale,
|
||||
((bx - buffer) * scale), -by * scale,
|
||||
((bx - buffer + width) * scale), (height - by) * scale,
|
||||
((bx - buffer) * scale), (height - by) * scale,
|
||||
((bx - buffer) * scale), -by * scale,
|
||||
|
||||
((bx - buffer + width) * scale), (height - by) * scale,
|
||||
((bx - buffer) * scale), -by * scale,
|
||||
((bx - buffer + width) * scale), -by * scale,
|
||||
);
|
||||
((bx - buffer + width) * scale), (height - by) * scale,
|
||||
((bx - buffer) * scale), -by * scale,
|
||||
((bx - buffer + width) * scale), -by * scale,
|
||||
);
|
||||
|
||||
|
||||
textOffsets.push(
|
||||
|
@ -142,14 +142,14 @@ function drawGlyph(chars, pos, text, pen, size, colors, textureElements, originP
|
|||
);
|
||||
textureElements.push(
|
||||
|
||||
posX + width, posY,
|
||||
posX, posY,
|
||||
posX, posY + height,
|
||||
posX + width, posY,
|
||||
posX, posY,
|
||||
posX, posY + height,
|
||||
|
||||
posX + width, posY,
|
||||
posX, posY + height,
|
||||
posX + width, posY + height
|
||||
);
|
||||
posX + width, posY,
|
||||
posX, posY + height,
|
||||
posX + width, posY + height
|
||||
);
|
||||
}
|
||||
pen.x = pen.x + size * 1.8;
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ export default class PolygonBuffer extends BufferBase {
|
|||
positions.push(extrudeData.positions);
|
||||
|
||||
if (shape !== 'line') {
|
||||
// faceUv.push(...extrudeData.faceUv);
|
||||
// faceUv.push(...extrudeData.faceUv);
|
||||
const count = extrudeData.faceUv.length / 2;
|
||||
for (let i = 0; i < count; i++) {
|
||||
// uv 系数生成等大小的窗户
|
||||
|
|
|
@ -116,7 +116,7 @@ export default class TextBuffer extends BufferBase {
|
|||
// const horiBearingX = metric[2];
|
||||
// const horiBearingY = metric[3];
|
||||
|
||||
// const horiAdvance = metric[4];
|
||||
// const horiAdvance = metric[4];
|
||||
// const posX = metric[5];
|
||||
// const posY = metric[6];
|
||||
const posX = x;
|
||||
|
@ -128,7 +128,7 @@ export default class TextBuffer extends BufferBase {
|
|||
width += buffer * 2;
|
||||
height += buffer * 2;
|
||||
|
||||
// Add a quad (= two triangles) per glyph.
|
||||
// Add a quad (= two triangles) per glyph.
|
||||
// const originX = (horiBearingX - buffer + width / 2) * scale;
|
||||
// const originY = -(height - horiBearingY) * scale;
|
||||
const originX = 0;
|
||||
|
@ -144,13 +144,13 @@ export default class TextBuffer extends BufferBase {
|
|||
const offsetX = pen.x;
|
||||
const offsetY = pen.y;
|
||||
originPoints.push(
|
||||
pos[0] + originX, pos[1] + originY, 0,
|
||||
pos[0] + originX, pos[1] + originY, 0,
|
||||
pos[0] + originX, pos[1] + originY, 0,
|
||||
pos[0] + originX, pos[1] + originY, 0,
|
||||
pos[0] + originX, pos[1] + originY, 0,
|
||||
pos[0] + originX, pos[1] + originY, 0,
|
||||
);
|
||||
pos[0] + originX, pos[1] + originY, 0,
|
||||
pos[0] + originX, pos[1] + originY, 0,
|
||||
pos[0] + originX, pos[1] + originY, 0,
|
||||
pos[0] + originX, pos[1] + originY, 0,
|
||||
pos[0] + originX, pos[1] + originY, 0,
|
||||
pos[0] + originX, pos[1] + originY, 0,
|
||||
);
|
||||
|
||||
// textSizes.push(
|
||||
// offsetWidth, offsetHeight,
|
||||
|
@ -169,31 +169,31 @@ export default class TextBuffer extends BufferBase {
|
|||
((bx - buffer) * scale), (height - by) * scale,
|
||||
((bx - buffer) * scale), -by * scale,
|
||||
|
||||
((bx - buffer + width) * scale), (height - by) * scale,
|
||||
((bx - buffer) * scale), -by * scale,
|
||||
((bx - buffer + width) * scale), -by * scale,
|
||||
((bx - buffer + width) * scale), (height - by) * scale,
|
||||
((bx - buffer) * scale), -by * scale,
|
||||
((bx - buffer + width) * scale), -by * scale,
|
||||
|
||||
|
||||
);
|
||||
|
||||
|
||||
textOffsets.push(
|
||||
offsetX, offsetY,
|
||||
offsetX, offsetY,
|
||||
offsetX, offsetY,
|
||||
offsetX, offsetY,
|
||||
offsetX, offsetY,
|
||||
offsetX, offsetY,
|
||||
);
|
||||
offsetX, offsetY,
|
||||
offsetX, offsetY,
|
||||
offsetX, offsetY,
|
||||
offsetX, offsetY,
|
||||
offsetX, offsetY,
|
||||
offsetX, offsetY,
|
||||
);
|
||||
|
||||
colors.push(
|
||||
...color,
|
||||
...color,
|
||||
...color,
|
||||
...color,
|
||||
...color,
|
||||
...color,
|
||||
);
|
||||
...color,
|
||||
...color,
|
||||
...color,
|
||||
...color,
|
||||
...color,
|
||||
...color,
|
||||
);
|
||||
textureElements.push(
|
||||
|
||||
posX + width, posY,
|
||||
|
|
|
@ -34,7 +34,7 @@ export default function extrudePolygon(points, extrude) {
|
|||
}
|
||||
}
|
||||
function full() {
|
||||
// 顶部纹理
|
||||
// 顶部纹理
|
||||
triangles.forEach(() => {
|
||||
faceUv.push(-1, -1);
|
||||
});
|
||||
|
@ -85,11 +85,11 @@ export function extrudePolygonLine(points, extrude) {
|
|||
extrude === 0 ? flat() : full();
|
||||
|
||||
function flat() {
|
||||
points[0].forEach(p => { positions.push([ p[0], p[1], 0 ]); }); // top
|
||||
points[0].forEach(p => { positions.push([ p[0], p[1], 0 ]); }); // top
|
||||
}
|
||||
function full() {
|
||||
points[0].forEach(p => { positions.push([ p[0], p[1], 1 ]); }); // top
|
||||
points[0].forEach(p => { positions.push([ p[0], p[1], 0 ]); }); // bottom
|
||||
points[0].forEach(p => { positions.push([ p[0], p[1], 0 ]); }); // bottom
|
||||
for (let i = 0; i < n; i++) {
|
||||
if (i === (n - 1)) {
|
||||
cells.push(i + n, n, i);
|
||||
|
|
|
@ -19,14 +19,14 @@ function hexagon() {
|
|||
return polygonPath(6);
|
||||
}
|
||||
export {
|
||||
circle,
|
||||
square,
|
||||
triangle,
|
||||
hexagon,
|
||||
circle as cylinder,
|
||||
triangle as triangleColumn,
|
||||
hexagon as hexagonColumn,
|
||||
square as squareColumn
|
||||
circle,
|
||||
square,
|
||||
triangle,
|
||||
hexagon,
|
||||
circle as cylinder,
|
||||
triangle as triangleColumn,
|
||||
hexagon as hexagonColumn,
|
||||
square as squareColumn
|
||||
};
|
||||
|
||||
export function polygonPath(pointCount) {
|
||||
|
|
|
@ -33,4 +33,4 @@ const Global = {
|
|||
};
|
||||
|
||||
|
||||
module.exports = Global;
|
||||
export default Global;
|
||||
|
|
|
@ -7,7 +7,7 @@ const version = Global.version;
|
|||
const track = function(enable) {
|
||||
Global.trackable = enable;
|
||||
};
|
||||
require('./track');
|
||||
import './track';
|
||||
export {
|
||||
version,
|
||||
Scene,
|
||||
|
|
|
@ -11,7 +11,6 @@ export default class LineLayer extends Layer {
|
|||
render() {
|
||||
this.type = 'polyline';
|
||||
this.init();
|
||||
const source = this.layerSource;
|
||||
const layerData = this.layerData;
|
||||
const style = this.get('styleOptions');
|
||||
const buffer = this._buffer = new LineBuffer({
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import Layer from '../core/layer';
|
||||
import * as THREE from '../core/three';
|
||||
import * as drawPoint from '../layer/render/point';
|
||||
import { pointShape } from '../global';
|
||||
import Global from '../global';
|
||||
// import PointBuffer from '../geom/buffer/point';
|
||||
import TextBuffer from '../geom/buffer/text';
|
||||
import TextMaterial from '../geom/material/textMaterial';
|
||||
import * as PointBuffer from '../geom/buffer/point/index';
|
||||
|
||||
const { pointShape } = Global;
|
||||
/**
|
||||
* point shape 2d circle, traingle text,image
|
||||
* shape 3d cube,column, sphere
|
||||
|
@ -37,39 +37,38 @@ export default class PointLayer extends Layer {
|
|||
this._textPoint();
|
||||
return;
|
||||
}
|
||||
const source = this.layerSource;
|
||||
const style = this.get('styleOptions');
|
||||
const pointShapeType = this._getShape();
|
||||
|
||||
switch (pointShapeType) {
|
||||
case 'fill' :// 填充图形
|
||||
{
|
||||
if (fill !== 'none') { // 是否填充
|
||||
const attributes = PointBuffer.FillBuffer(this.layerData, style);
|
||||
const meshfill = drawPoint.DrawFill(attributes, this.get('styleOptions'));
|
||||
this.add(meshfill);
|
||||
}
|
||||
if (stroke !== 'none') { // 是否绘制边界
|
||||
const lineAttribute = PointBuffer.StrokeBuffer(this.layerData, style);
|
||||
const meshStroke = drawPoint.DrawStroke(lineAttribute, this.get('styleOptions'));
|
||||
this.add(meshStroke, 'line');
|
||||
}
|
||||
break;
|
||||
{
|
||||
if (fill !== 'none') { // 是否填充
|
||||
const attributes = PointBuffer.FillBuffer(this.layerData, style);
|
||||
const meshfill = drawPoint.DrawFill(attributes, this.get('styleOptions'));
|
||||
this.add(meshfill);
|
||||
}
|
||||
if (stroke !== 'none') { // 是否绘制边界
|
||||
const lineAttribute = PointBuffer.StrokeBuffer(this.layerData, style);
|
||||
const meshStroke = drawPoint.DrawStroke(lineAttribute, this.get('styleOptions'));
|
||||
this.add(meshStroke, 'line');
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'image':// 绘制图片标注
|
||||
{
|
||||
const imageAttribute = PointBuffer.ImageBuffer(this.layerData, { imagePos: this.scene.image.imagePos });
|
||||
const imageMesh = drawPoint.DrawImage(imageAttribute, { ...style, texture: this.scene.image.texture });
|
||||
this.add(imageMesh);
|
||||
break;
|
||||
}
|
||||
{
|
||||
const imageAttribute = PointBuffer.ImageBuffer(this.layerData, { imagePos: this.scene.image.imagePos });
|
||||
const imageMesh = drawPoint.DrawImage(imageAttribute, { ...style, texture: this.scene.image.texture });
|
||||
this.add(imageMesh);
|
||||
break;
|
||||
}
|
||||
case 'normal' : // 原生点
|
||||
{
|
||||
const normalAttribute = PointBuffer.NormalBuffer(this.layerData, style);
|
||||
const normalPointMesh = drawPoint.DrawNormal(normalAttribute, style);
|
||||
this.add(normalPointMesh);
|
||||
break;
|
||||
}
|
||||
{
|
||||
const normalAttribute = PointBuffer.NormalBuffer(this.layerData, style);
|
||||
const normalPointMesh = drawPoint.DrawNormal(normalAttribute, style);
|
||||
this.add(normalPointMesh);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
@ -98,7 +97,6 @@ export default class PointLayer extends Layer {
|
|||
|
||||
}
|
||||
_textPoint() {
|
||||
const source = this.layerSource;
|
||||
const styleOptions = this.get('styleOptions');
|
||||
const buffer = new TextBuffer({
|
||||
type: this.shapeType,
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import Base from '../core/base';
|
||||
import { scene } from '../global';
|
||||
import Global from '../global';
|
||||
import * as Theme from '../theme/index';
|
||||
import Util from '../util';
|
||||
const DEG2RAD = Math.PI / 180;
|
||||
export default class GaodeMap extends Base {
|
||||
getDefaultCfg() {
|
||||
return Util.assign(scene, {
|
||||
return Util.assign(Global.scene, {
|
||||
resizeEnable: true,
|
||||
viewMode: '3D'
|
||||
});
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import Base from '../core/base';
|
||||
import Util from '../util';
|
||||
import { scene } from '../global';
|
||||
import Global from '../global';
|
||||
import * as THREE from '../core/three';
|
||||
const WORLD_SIZE = 512;
|
||||
const MERCATOR_A = 6378137.0;
|
||||
|
@ -8,7 +8,7 @@ const WORLD_SCALE = 1 / 100;
|
|||
const PROJECTION_WORLD_SIZE = WORLD_SIZE / (MERCATOR_A * Math.PI) / 2;
|
||||
export default class MapBox extends Base {
|
||||
getDefaultCfg() {
|
||||
return Util.assign(scene, {
|
||||
return Util.assign(Global.scene, {
|
||||
resizeEnable: true,
|
||||
viewMode: '3D'
|
||||
});
|
||||
|
@ -80,10 +80,10 @@ export default class MapBox extends Base {
|
|||
// Unlike the Mapbox GL JS camera, separate camera translation and rotation out into its world matrix
|
||||
// If this is applied directly to the projection matrix, it will work OK but break raycasting
|
||||
cameraWorldMatrix
|
||||
.premultiply(cameraTranslateZ)
|
||||
.premultiply(cameraRotateX)
|
||||
.premultiply(cameraRotateZ)
|
||||
.premultiply(cameraTranslateXY);
|
||||
.premultiply(cameraTranslateZ)
|
||||
.premultiply(cameraRotateX)
|
||||
.premultiply(cameraRotateZ)
|
||||
.premultiply(cameraTranslateXY);
|
||||
|
||||
camera.matrixWorld.copy(cameraWorldMatrix);
|
||||
|
||||
|
@ -94,23 +94,23 @@ export default class MapBox extends Base {
|
|||
const translateMap = new THREE.Matrix4();
|
||||
const rotateMap = new THREE.Matrix4();
|
||||
scale
|
||||
.makeScale(zoomPow, zoomPow, 1.0);
|
||||
.makeScale(zoomPow, zoomPow, 1.0);
|
||||
translateCenter
|
||||
.makeTranslation(WORLD_SIZE / 2, -WORLD_SIZE / 2, 0);
|
||||
.makeTranslation(WORLD_SIZE / 2, -WORLD_SIZE / 2, 0);
|
||||
translateMap
|
||||
.makeTranslation(-this.map.transform.x, this.map.transform.y, 0);
|
||||
.makeTranslation(-this.map.transform.x, this.map.transform.y, 0);
|
||||
rotateMap
|
||||
.makeRotationZ(Math.PI);
|
||||
.makeRotationZ(Math.PI);
|
||||
scene.matrix = new THREE.Matrix4();
|
||||
scene.matrix
|
||||
.premultiply(rotateMap)
|
||||
.premultiply(translateCenter)
|
||||
.premultiply(scale);
|
||||
.premultiply(rotateMap)
|
||||
.premultiply(translateCenter)
|
||||
.premultiply(scale);
|
||||
pickScene.matrix = new THREE.Matrix4();
|
||||
pickScene.matrix
|
||||
.premultiply(rotateMap)
|
||||
.premultiply(translateCenter)
|
||||
.premultiply(scale);
|
||||
.premultiply(rotateMap)
|
||||
.premultiply(translateCenter)
|
||||
.premultiply(scale);
|
||||
}
|
||||
makePerspectiveMatrix(fovy, aspect, near, far) {
|
||||
const out = new THREE.Matrix4();
|
||||
|
|
|
@ -2,8 +2,7 @@
|
|||
* @fileOverview 计算分类的的坐标点
|
||||
* @author dxq613@gmail.com
|
||||
*/
|
||||
|
||||
const Util = require('../../util');
|
||||
import Util from '../../util';
|
||||
const MAX_COUNT = 8;
|
||||
const SUB_COUNT = 4; // 控制个数不能过小
|
||||
|
||||
|
@ -32,7 +31,7 @@ function getGreatestFactor(count, number) {
|
|||
return i;
|
||||
}
|
||||
|
||||
module.exports = function(info) {
|
||||
export default function(info) {
|
||||
const rst = {};
|
||||
const ticks = [];
|
||||
const maxCount = info.maxCount || MAX_COUNT;
|
||||
|
@ -70,4 +69,4 @@ module.exports = function(info) {
|
|||
rst.categories = categories;
|
||||
rst.ticks = ticks;
|
||||
return rst;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
* @author dxq613@gmail.com
|
||||
*/
|
||||
|
||||
const Util = require('../../util');
|
||||
const AutoUtil = require('./util');
|
||||
import Util from '../../util';
|
||||
import AutoUtil from './util';
|
||||
const MIN_COUNT = 5;
|
||||
const MAX_COUNT = 7;
|
||||
const Global = require('../../global');
|
||||
import Global from '../../global';
|
||||
|
||||
module.exports = function(info) {
|
||||
export default function(info) {
|
||||
let min = info.min;
|
||||
let max = info.max;
|
||||
let interval = info.interval;
|
||||
|
@ -116,4 +116,4 @@ module.exports = function(info) {
|
|||
count,
|
||||
ticks
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
* @author dxq613@gmail.com
|
||||
*/
|
||||
|
||||
const Util = require('../../util');
|
||||
const AutoUtil = require('./util');
|
||||
import Util from '../../util';
|
||||
import AutoUtil from './util';
|
||||
|
||||
const MAX_COUNT = 6;
|
||||
const SNAP_ARRAY = [ 1, 2, 4, 6, 8, 12 ];
|
||||
|
@ -48,7 +48,7 @@ function diffMinus(min, max) {
|
|||
return Math.ceil((max - min) / (60 * 1000));
|
||||
}
|
||||
|
||||
module.exports = function(info) {
|
||||
export default function(info) {
|
||||
const minInterval = info.minInterval;
|
||||
const ticks = [];
|
||||
let min = info.min;
|
||||
|
@ -158,4 +158,4 @@ module.exports = function(info) {
|
|||
ticks,
|
||||
count: ticks.length
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -85,7 +85,8 @@ function arrayCeiling(values, value) {
|
|||
|
||||
const Util = {
|
||||
// 获取逼近的数值
|
||||
snapFactorTo(v, arr, snapType) { // 假设 v = -512,isFloor = true
|
||||
snapFactorTo(v, arr, snapType) {
|
||||
// 假设 v = -512,isFloor = true
|
||||
if (isNaN(v)) {
|
||||
return NaN;
|
||||
}
|
||||
|
@ -112,7 +113,7 @@ const Util = {
|
|||
if (Math.abs(factor) < 1 && rst.toString().length > DECIMAL_LENGTH) {
|
||||
const decimalVal = parseInt(1 / factor);
|
||||
const symbol = factor > 0 ? 1 : -1;
|
||||
rst = v / decimalVal * symbol;
|
||||
rst = (v / decimalVal) * symbol;
|
||||
}
|
||||
return rst;
|
||||
},
|
||||
|
@ -174,4 +175,4 @@ const Util = {
|
|||
}
|
||||
};
|
||||
|
||||
module.exports = Util;
|
||||
export default Util;
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
* @author dxq613@gmail.com
|
||||
*/
|
||||
|
||||
const Util = require('../util');
|
||||
import Util from '../util';
|
||||
|
||||
/**
|
||||
* 度量的构造函数
|
||||
* @class Scale
|
||||
*/
|
||||
class Scale {
|
||||
class Base {
|
||||
|
||||
/**
|
||||
* 获取默认的配置属性
|
||||
|
@ -183,4 +183,4 @@ class Scale {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = Scale;
|
||||
export default Base;
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
*/
|
||||
|
||||
|
||||
const Base = require('./base');
|
||||
const Util = require('../util');
|
||||
const catAuto = require('./auto/cat');
|
||||
import Base from './base';
|
||||
import Util from '../util';
|
||||
import catAuto from './auto/cat';
|
||||
|
||||
/**
|
||||
* 度量的构造函数
|
||||
|
@ -132,4 +132,4 @@ class Category extends Base {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = Category;
|
||||
export default Category;
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
* @author dxq613@gmail.com
|
||||
*/
|
||||
|
||||
const Base = require('./base');
|
||||
const Util = require('../util');
|
||||
import Base from './base';
|
||||
import Util from '../util';
|
||||
|
||||
class Identity extends Base {
|
||||
|
||||
|
@ -54,4 +54,4 @@ class Identity extends Base {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = Identity;
|
||||
export default Identity;
|
||||
|
|
|
@ -3,15 +3,23 @@
|
|||
* @author dxq613@gmail.com
|
||||
*/
|
||||
|
||||
const Util = require('../util');
|
||||
const Base = require('./base');
|
||||
Base.Linear = require('./linear');
|
||||
Base.Identity = require('./identity');
|
||||
Base.Cat = require('./category');
|
||||
Base.Time = require('./time');
|
||||
Base.TimeCat = require('./time-cat');
|
||||
Base.Log = require('./log');
|
||||
Base.Pow = require('./pow');
|
||||
import Util from '../util';
|
||||
import Base from './base';
|
||||
import Linear from './linear';
|
||||
import Identity from './identity';
|
||||
import Cat from './category';
|
||||
import Time from './time';
|
||||
import TimeCat from './time-cat';
|
||||
import Log from './log';
|
||||
import Pow from './pow';
|
||||
|
||||
Base.Linear = Linear;
|
||||
Base.Identity = Identity;
|
||||
Base.Cat = Cat;
|
||||
Base.Time = Time;
|
||||
Base.TimeCat = TimeCat;
|
||||
Base.Log = Log;
|
||||
Base.Pow = Pow;
|
||||
|
||||
for (const k in Base) {
|
||||
if (Base.hasOwnProperty(k)) {
|
||||
|
@ -28,4 +36,4 @@ Base.isCategory = function(type) {
|
|||
return CAT_ARR.indexOf(type) >= 0;
|
||||
};
|
||||
|
||||
module.exports = Base;
|
||||
export default Base;
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
*/
|
||||
|
||||
|
||||
const Base = require('./base');
|
||||
const Util = require('../util');
|
||||
const numberAuto = require('./auto/number');
|
||||
import Base from './base';
|
||||
import Util from '../util';
|
||||
import numberAuto from './auto/number';
|
||||
|
||||
/**
|
||||
* 线性度量
|
||||
|
@ -192,4 +192,4 @@ class Linear extends Base {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = Linear;
|
||||
export default Linear;
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
* @author dxq613@gmail.com
|
||||
*/
|
||||
|
||||
const Linear = require('./linear');
|
||||
const Util = require('../util');
|
||||
import Linear from './linear';
|
||||
import Util from '../util';
|
||||
|
||||
// 计算log
|
||||
function log(a, b) {
|
||||
|
@ -157,4 +157,4 @@ class Log extends Linear {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = Log;
|
||||
export default Log;
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
*/
|
||||
|
||||
|
||||
const Linear = require('./linear');
|
||||
const Util = require('../util');
|
||||
import Linear from './linear';
|
||||
import Util from '../util';
|
||||
|
||||
// 求以a为次幂,结果为b的基数,如 x^^a = b;求x
|
||||
function calBase(a, b) {
|
||||
|
@ -111,4 +111,4 @@ class Pow extends Linear {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = Pow;
|
||||
export default Pow;
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
* @author dxq613@gmail.com
|
||||
*/
|
||||
|
||||
const Category = require('./category');
|
||||
const Util = require('../util');
|
||||
const fecha = require('fecha');
|
||||
const catAuto = require('./auto/cat');
|
||||
const TimeUtil = require('./time-util');
|
||||
import Category from './category';
|
||||
import Util from '../util';
|
||||
import fecha from 'fecha';
|
||||
import TimeUtil from './time-util';
|
||||
import catAuto from './auto/cat';
|
||||
|
||||
/**
|
||||
* 度量的构造函数
|
||||
|
@ -166,4 +166,4 @@ class TimeCategory extends Category {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = TimeCategory;
|
||||
export default TimeCategory;
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
* @author dxq613@gmail.com
|
||||
*/
|
||||
|
||||
const Util = require('../util');
|
||||
import Util from '../util';
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
toTimeStamp(value) {
|
||||
if (Util.isString(value)) {
|
||||
if (value.indexOf('T') > 0) {
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
* @author dxq613@gmail.com
|
||||
*/
|
||||
|
||||
const Linear = require('./linear');
|
||||
const Util = require('../util');
|
||||
const timeAuto = require('./auto/time');
|
||||
const fecha = require('fecha');
|
||||
const TimeUtil = require('./time-util');
|
||||
import Linear from './linear';
|
||||
import Util from '../util';
|
||||
import timeAuto from './auto/time';
|
||||
import fecha from 'fecha';
|
||||
import TimeUtil from './time-util';
|
||||
|
||||
/**
|
||||
* 时间度量的构造函数
|
||||
|
@ -126,4 +126,4 @@ class Time extends Linear {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = Time;
|
||||
export default Time;
|
||||
|
|
|
@ -5,12 +5,6 @@ import * as statistics from './statistics';
|
|||
|
||||
const R_EARTH = 6378000;
|
||||
|
||||
/**
|
||||
* 计算方格密度图
|
||||
* @param {*} data 经纬度数据 和属性数据
|
||||
* @param {*} size 半径大小 单位 km
|
||||
* @return
|
||||
*/
|
||||
export function aggregatorToGrid(data, option) {
|
||||
const dataArray = data.dataArray;
|
||||
const { size = 10 } = option;
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
import DarkTheme from './dark';
|
||||
import LightTheme from './light';
|
||||
export {
|
||||
DarkTheme,
|
||||
LightTheme
|
||||
};
|
||||
export { DarkTheme, LightTheme };
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
const LightTheme = {
|
||||
mapStyle: 'amap://styles/a80c558f91b29cf56fa47f895fb1773c?isPublic=true'
|
||||
};
|
||||
|
||||
const LightTheme = {
|
||||
mapStyle: 'amap://styles/a80c558f91b29cf56fa47f895fb1773c?isPublic=true'
|
||||
};
|
||||
|
||||
export default LightTheme;
|
||||
export default LightTheme;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* @fileOverview track g2
|
||||
* @author dxq613@gmail.com
|
||||
*/
|
||||
const Global = require('./global');
|
||||
import Global from './global';
|
||||
const SERVER_URL = 'https://kcart.alipay.com/web/bi.do';
|
||||
|
||||
// 延迟发送请求
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* @author dxq613@gmail.com
|
||||
* @see https://github.com/lodash/lodash
|
||||
*/
|
||||
const Utils = require('@antv/util');
|
||||
import Utils from '@antv/util';
|
||||
|
||||
const Util = Utils.mix({}, Utils, {
|
||||
assign: Utils.mix, // simple mix
|
||||
|
@ -52,4 +52,4 @@ Util.Array = {
|
|||
remove: Utils.pull
|
||||
};
|
||||
|
||||
module.exports = Util;
|
||||
export default Util;
|
||||
|
|
|
@ -6,7 +6,7 @@ class AJAXError extends Error {
|
|||
this.status = status;
|
||||
this.url = url;
|
||||
|
||||
// work around for https://github.com/Rich-Harris/buble/issues/40
|
||||
// work around for https://github.com/Rich-Harris/buble/issues/40
|
||||
this.name = this.constructor.name;
|
||||
this.message = message;
|
||||
}
|
||||
|
@ -88,8 +88,8 @@ function sameOrigin(url) {
|
|||
const transparentPngUrl = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=';
|
||||
|
||||
export const getImage = function(requestParameters, callback) {
|
||||
// request the image with XHR to work around caching issues
|
||||
// see https://github.com/mapbox/mapbox-gl-js/issues/1470
|
||||
// request the image with XHR to work around caching issues
|
||||
// see https://github.com/mapbox/mapbox-gl-js/issues/1470
|
||||
return getArrayBuffer(requestParameters, (err, imgData) => {
|
||||
if (err) {
|
||||
callback(err);
|
||||
|
|
|
@ -2,7 +2,7 @@ const PRECISION = 0.00001; // 常量,据的精度,小于这个精度认为
|
|||
const RADIAN = Math.PI / 180;
|
||||
const DEGREE = 180 / Math.PI;
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
isFunction: require('lodash/isFunction'),
|
||||
isObject: require('lodash/isObject'),
|
||||
isBoolean: require('lodash/isBoolean'),
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const Util = require('./common');
|
||||
import Util from './common';
|
||||
|
||||
const TABLE = document.createElement('table');
|
||||
const TABLE_TR = document.createElement('tr');
|
||||
|
@ -13,7 +13,7 @@ const CONTAINERS = {
|
|||
'*': document.createElement('div')
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
getBoundingClientRect(node, defaultValue) {
|
||||
if (node && node.getBoundingClientRect) {
|
||||
const rect = node.getBoundingClientRect();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const Util = require('../util/index');
|
||||
import Util from '../util/index';
|
||||
|
||||
const regexTags = /[MLHVQTCSAZ]([^MLHVQTCSAZ]*)/ig;
|
||||
const regexDot = /[^\s\,]+/ig;
|
||||
|
@ -138,13 +138,14 @@ function parsePattern(color, self) {
|
|||
} else {
|
||||
img.onload = onload;
|
||||
// Fix onload() bug in IE9
|
||||
// eslint-disable-next-line
|
||||
img.src = img.src;
|
||||
}
|
||||
|
||||
return pattern;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
parsePath(path) {
|
||||
path = path || [];
|
||||
if (Util.isArray(path)) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const CommonUtil = require('./common');
|
||||
const DomUtil = require('./dom');
|
||||
import CommonUtil from './common';
|
||||
import DomUtil from './dom';
|
||||
|
||||
const Util = {};
|
||||
|
||||
|
@ -22,4 +22,4 @@ CommonUtil.merge(Util, CommonUtil, DomUtil, {
|
|||
}
|
||||
});
|
||||
|
||||
module.exports = Util;
|
||||
export default Util;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const CommonUtil = require('./common');
|
||||
const mat3 = require('gl-matrix/src/gl-matrix/mat3');
|
||||
const vec3 = require('gl-matrix/src/gl-matrix/vec3');
|
||||
const vec2 = require('gl-matrix/src/gl-matrix/vec2');
|
||||
import CommonUtil from './common';
|
||||
import mat3 from 'gl-matrix/src/gl-matrix/mat3';
|
||||
import vec3 from 'gl-matrix/src/gl-matrix/vec3';
|
||||
import vec2 from 'gl-matrix/src/gl-matrix/vec2';
|
||||
|
||||
vec2.angle = function(v1, v2) {
|
||||
const theta = vec2.dot(v1, v2) / (vec2.length(v1) * vec2.length(v2));
|
||||
|
@ -62,7 +62,7 @@ mat3.scale = function(out, a, v) {
|
|||
return mat3.multiply(out, scaleMat, a);
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
mat3,
|
||||
vec2,
|
||||
vec3,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const Util = require('./common');
|
||||
import Util from './common';
|
||||
const SPACES = '\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029';
|
||||
const PATH_COMMAND = new RegExp('([a-z])[' + SPACES + ',]*((-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?[' + SPACES + ']*,?[' + SPACES + ']*)+)', 'ig');
|
||||
const PATH_VALUES = new RegExp('(-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?)[' + SPACES + ']*,?[' + SPACES + ']*', 'ig');
|
||||
|
@ -954,7 +954,7 @@ const pathIntersection = function(path1, path2) {
|
|||
return interPathHelper(path1, path2);
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
parsePathString,
|
||||
parsePathArray,
|
||||
pathTocurve,
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
|
||||
self.addEventListener('message', e => {
|
||||
this.addEventListener('message', e => {
|
||||
const res = e.data;
|
||||
// res = {
|
||||
// command : 'POLYGON-EXTRUDE',
|
||||
|
@ -16,6 +15,8 @@ self.addEventListener('message', e => {
|
|||
break;
|
||||
}
|
||||
});
|
||||
self.addEventListener('error', function(e) {
|
||||
console.error('filename:' + e.filename + '\nmessage:' + e.message + '\nline:' + e.lineno);
|
||||
this.addEventListener('error', function(e) {
|
||||
console.error(
|
||||
'filename:' + e.filename + '\nmessage:' + e.message + '\nline:' + e.lineno
|
||||
);
|
||||
});
|
||||
|
|
|
@ -18,6 +18,5 @@ describe('hexagon Test', function() {
|
|||
};
|
||||
const hexgonGrid = pointToHexbin(data, { size: 100, field: 'v', method: 'sum' });
|
||||
expect(hexgonGrid.dataArray.length).eql(567);
|
||||
console.log(hexgonGrid);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
const webpackConfig = require('./webpack.config');
|
||||
const _ = require('lodash');
|
||||
|
||||
module.exports = _.merge({
|
||||
watch: true,
|
||||
watchOptions: {
|
||||
aggregateTimeout: 300,
|
||||
poll: 1000
|
||||
}
|
||||
}, webpackConfig);
|
||||
module.exports = _.merge(
|
||||
{
|
||||
mode: 'development',
|
||||
watch: true,
|
||||
watchOptions: {
|
||||
aggregateTimeout: 300,
|
||||
poll: 1000
|
||||
}
|
||||
},
|
||||
webpackConfig
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue