提交 ddef1ffa 编写于 作者: Y yangji

Merge branch 'master' of https://github.com/ecomfe/echarts

......@@ -102,7 +102,6 @@ option = {
linkStyle : {}
}
},
useWorker: false,
minRadius : 15,
maxRadius : 25,
gravity: 1.1,
......@@ -114,15 +113,13 @@ option = {
nodes:[
{
category:0, name: '乔布斯', value : 10,
symbol: 'star',
symbolSize: 40,
symbol: 'image://http://www.cnii.com.cn/hg/zt/2012315zt/content/attachement/jpg/site2/20120217/00137274b1a410a8340f07.jpg',
symbolSize: 30,
draggable: true,
itemStyle: {
normal: {
label: {
textStyle: {
color: 'white'
}
show: false
}
}
}
......@@ -149,7 +146,7 @@ option = {
{source : '克拉拉-乔布斯', target : '乔布斯', weight : 1},
{source : '劳伦-鲍威尔', target : '乔布斯', weight : 2},
{source : '史蒂夫-沃兹尼艾克', target : '乔布斯', weight : 3},
{source : '奥巴马', target : '乔布斯', weight : 6},
{source : '奥巴马', target : '乔布斯', weight : 3},
{source : '比尔-盖茨', target : '乔布斯', weight : 6},
{source : '乔纳森-艾夫', target : '乔布斯', weight : 1},
{source : '蒂姆-库克', target : '乔布斯', weight : 1},
......
此差异已折叠。
此差异已折叠。
......@@ -15,7 +15,7 @@ define(function (require) {
var TextShape = require('zrender/shape/Text');
var LineShape = require('zrender/shape/Line');
var SectorShape = require('zrender/shape/Sector');
var ChordShape = require('../util/shape/Chord');
var RibbonShape = require('../util/shape/Ribbon');
var ecConfig = require('../config');
var ecData = require('../util/ecData');
......@@ -35,11 +35,11 @@ define(function (require) {
}
Chord.prototype = {
type : ecConfig.CHART_TYPE_CHORD,
type: ecConfig.CHART_TYPE_CHORD,
/**
* 绘制图形
*/
_buildShape : function () {
_buildShape: function () {
var series = this.series;
this.selectedMap = {};
this.chordSeries = [];
......@@ -233,7 +233,7 @@ define(function (require) {
this.addShapeList();
},
_filterData : function (dataMat, groups) {
_filterData: function (dataMat, groups) {
var indices = [];
var groupsFilted = [];
// Filter by selected group
......@@ -275,7 +275,7 @@ define(function (require) {
return [dataMat, groupsFilted2];
},
_buildSectors : function (angles, data) {
_buildSectors: function (angles, data) {
var len = this.groups.length;
var len2 = this.chordSeries.length;
......@@ -355,21 +355,21 @@ define(function (require) {
var _end = (this.clockWise ? (360 - angle[0]) : angle[1]) + this.startAngle;
var sector = {
zlevel : this._zlevelBase,
style : {
x : this.center[0],
y : this.center[1],
r0 : this.innerRadius,
r : this.outerRadius,
startAngle : _start,
endAngle : _end,
brushType : 'fill',
zlevel: this._zlevelBase,
style: {
x: this.center[0],
y: this.center[1],
r0: this.innerRadius,
r: this.outerRadius,
startAngle: _start,
endAngle: _end,
brushType: 'fill',
opacity: 1,
color : this.getColor(group.name)
color: this.getColor(group.name)
},
clickable: this.chordSerieSample.clickable,
highlightStyle : {
brushType : 'fill'
highlightStyle: {
brushType: 'fill'
}
};
sector.style.lineWidth = this.deepQuery(
......@@ -414,12 +414,12 @@ define(function (require) {
vec2.add(start, start, this.center);
var labelShape = {
zlevel : this._zlevelBase - 1,
hoverable : false,
style : {
text : group.name,
textAlign : isRightSide ? 'left' : 'right',
color : labelColor
zlevel: this._zlevelBase - 1,
hoverable: false,
style: {
text: group.name,
textAlign: isRightSide ? 'left' : 'right',
color: labelColor
}
};
if (rotateLabel) {
......@@ -463,9 +463,9 @@ define(function (require) {
}
var len2 = angles[0][0].length;
var chordLineStyle
var ribbonLineStyle
= this.chordSerieSample.itemStyle.normal.chordStyle.lineStyle;
var chordLineStyleEmphsis
var ribbonLineStyleEmphsis
= this.chordSerieSample.itemStyle.emphasis.chordStyle.lineStyle;
for (var i = 0; i < len; i++) {
......@@ -481,8 +481,10 @@ define(function (require) {
var angleIJ1 = angles[i][j][k][1];
var angleJI1 = angles[j][i][k][1];
if (angleIJ0 - angleJI1 === 0 ||
angleJI0 - angleJI1 === 0) {
if (
angleIJ0 - angleJI1 === 0
|| angleJI0 - angleJI1 === 0
) {
this.chordShapes[i][j][k] = null;
continue;
}
......@@ -502,25 +504,26 @@ define(function (require) {
var t0 = !this.clockWise ? (360 - angleJI1) : angleJI0;
var t1 = !this.clockWise ? (360 - angleJI0) : angleJI1;
var chord = {
zlevel : this._zlevelBase,
style : {
center : this.center,
r : this.innerRadius,
source0 : s0 - this.startAngle,
source1 : s1 - this.startAngle,
target0 : t0 - this.startAngle,
target1 : t1 - this.startAngle,
brushType : 'both',
opacity : 0.5,
color : color,
lineWidth : chordLineStyle.width,
strokeColor : chordLineStyle.color
zlevel: this._zlevelBase,
style: {
x: this.center[0],
y: this.center[1],
r: this.innerRadius,
source0: s0 - this.startAngle,
source1: s1 - this.startAngle,
target0: t0 - this.startAngle,
target1: t1 - this.startAngle,
brushType: 'both',
opacity: 0.5,
color: color,
lineWidth: ribbonLineStyle.width,
strokeColor: ribbonLineStyle.color
},
clickable: this.chordSerieSample.clickable,
highlightStyle : {
brushType : 'both',
lineWidth : chordLineStyleEmphsis.width,
strokeColor : chordLineStyleEmphsis.color
highlightStyle: {
brushType: 'both',
lineWidth: ribbonLineStyleEmphsis.width,
strokeColor: ribbonLineStyleEmphsis.color
}
};
......@@ -534,7 +537,7 @@ define(function (require) {
dataArr[j][i][k]
);
chord = new ChordShape(chord);
chord = new RibbonShape(chord);
this.chordShapes[i][j][k] = chord;
this.shapeList.push(chord);
}
......@@ -565,16 +568,16 @@ define(function (require) {
var end = vec2.scale([], v, this.outerRadius + this.scaleLineLength);
vec2.add(end, end, this.center);
var scaleShape = {
zlevel : this._zlevelBase - 1,
hoverable : false,
style : {
xStart : start[0],
yStart : start[1],
xEnd : end[0],
yEnd : end[1],
lineCap : 'round',
brushType : 'stroke',
strokeColor : '#666',
zlevel: this._zlevelBase - 1,
hoverable: false,
style: {
xStart: start[0],
yStart: start[1],
xEnd: end[0],
yEnd: end[1],
lineCap: 'round',
brushType: 'stroke',
strokeColor: '#666',
lineWidth: 1
}
};
......@@ -598,19 +601,19 @@ define(function (require) {
var isRightSide = thelta <= 90
|| thelta >= 270;
var textShape = {
zlevel : this._zlevelBase - 1,
hoverable : false,
style : {
x : isRightSide
zlevel: this._zlevelBase - 1,
hoverable: false,
style: {
x: isRightSide
? this.outerRadius + this.scaleLineLength + 4
: -this.outerRadius - this.scaleLineLength - 4,
y : 0,
text : Math.round(scaleValues.shift()*10)/10
y: 0,
text: Math.round(scaleValues.shift()*10)/10
+ unitPostfix,
textAlign : isRightSide ? 'left' : 'right'
textAlign: isRightSide ? 'left' : 'right'
},
position : this.center.slice(),
rotation : isRightSide
position: this.center.slice(),
rotation: isRightSide
? [thelta / 180 * Math.PI, 0, 0]
: [
(thelta + 180) / 180 * Math.PI,
......@@ -655,28 +658,9 @@ define(function (require) {
this.series = newOption.series;
}
/*
this.legend;
this.getColor;
this.isSelected;
this.chordSerieSample;
*/
// Config
this.chordSeries = [];
/*
this.groups;
this.startAngle;
this.clockWise;
this.innerRadius;
this.outerRadius;
this.padding;
this.sortGroups;
this.sortSubGroups;
this.center;
this.showScale;
this.showScaleText;
this.dataMat;
*/
this.strokeFix = 0;
// Adjacency matrix
this.sectorShapes = [];
......
......@@ -15,6 +15,7 @@ define(function (require) {
// 图形依赖
var LineShape = require('zrender/shape/Line');
var ImageShape = require('zrender/shape/Image');
var IconShape = require('../util/shape/Icon');
var ecConfig = require('../config');
......@@ -451,6 +452,17 @@ define(function (require) {
shape.style.width = shape.style.height
= (this.deepQuery(queryTarget, 'symbolSize') || 0) * 2;
if (shape.style.iconType.match('image')) {
shape.style.image = shape.style.iconType.replace(
new RegExp('^image:\\/\\/'), ''
);
shape = new ImageShape({
style: shape.style,
highlightStyle: shape.highlightStyle,
clickable: shape.clickable
});
}
// 节点样式
for (var k = 0; k < shapeNormalStyle.length; k++) {
if (shapeNormalStyle[k]) {
......@@ -462,7 +474,7 @@ define(function (require) {
if (shapeEmphasisStyle[k]) {
zrUtil.merge(shape.highlightStyle, shapeEmphasisStyle[k], true);
}
}
}
// 节点标签样式
if (this.deepQuery(queryTarget, 'itemStyle.normal.label.show')) {
......
此差异已折叠。
此差异已折叠。
......@@ -69,14 +69,14 @@ define(function (require) {
}
Island.prototype = {
type : ecConfig.CHART_TYPE_ISLAND,
type: ecConfig.CHART_TYPE_ISLAND,
/**
* 孤岛合并
*
* @param {string} tarShapeIndex 目标索引
* @param {Object} srcShape 源目标,合入目标后删除
*/
_combine : function (tarShape, srcShape) {
_combine: function (tarShape, srcShape) {
var zrColor = require('zrender/tool/color');
var accMath = require('../util/accMath');
var value = accMath.accAdd(
......@@ -101,7 +101,7 @@ define(function (require) {
/**
* 刷新
*/
refresh : function (newOption) {
refresh: function (newOption) {
if (newOption) {
newOption.island = this.reformOption(newOption.island);
this.option = newOption;
......@@ -111,16 +111,16 @@ define(function (require) {
}
},
getOption : function () {
getOption: function () {
return this.option;
},
resize : function () {
resize: function () {
var newWidth = this.zr.getWidth();
var newHieght = this.zr.getHeight();
var xScale = newWidth / (this._zrWidth || newWidth);
var yScale = newHieght / (this._zrHeight || newHieght);
if (xScale == 1 && yScale == 1) {
if (xScale === 1 && yScale === 1) {
return;
}
this._zrWidth = newWidth;
......@@ -138,29 +138,29 @@ define(function (require) {
}
},
add : function (shape) {
add: function (shape) {
var name = ecData.get(shape, 'name');
var value = ecData.get(shape, 'value');
var seriesName = typeof ecData.get(shape, 'series') != 'undefined'
var seriesName = ecData.get(shape, 'series') != null
? ecData.get(shape, 'series').name
: '';
var font = this.getFont(this.option.island.textStyle);
var islandShape = {
zlevel : this._zlevelBase,
style : {
x : shape.style.x,
y : shape.style.y,
r : this.option.island.r,
color : shape.style.color || shape.style.strokeColor,
text : name + this._valueConnector + value,
textFont : font
zlevel: this._zlevelBase,
style: {
x: shape.style.x,
y: shape.style.y,
r: this.option.island.r,
color: shape.style.color || shape.style.strokeColor,
text: name + this._valueConnector + value,
textFont: font
},
draggable : true,
hoverable : true,
onmousewheel : this.shapeHandler.onmousewheel,
_type : 'island'
draggable: true,
hoverable: true,
onmousewheel: this.shapeHandler.onmousewheel,
_type: 'island'
};
if (islandShape.style.color == '#fff') {
if (islandShape.style.color === '#fff') {
islandShape.style.color = shape.style.strokeColor;
}
this.setCalculable(islandShape);
......@@ -176,7 +176,7 @@ define(function (require) {
this.zr.addShape(islandShape);
},
del : function (shape) {
del: function (shape) {
this.zr.delShape(shape.id);
var newShapeList = [];
for (var i = 0, l = this.shapeList.length; i < l; i++) {
......@@ -190,7 +190,7 @@ define(function (require) {
/**
* 数据项被拖拽进来, 重载基类方法
*/
ondrop : function (param, status) {
ondrop: function (param, status) {
if (!this.isDrop || !param.target) {
// 没有在当前实例上发生拖拽行为则直接返回
return;
......@@ -213,7 +213,7 @@ define(function (require) {
/**
* 数据项被拖拽出去, 重载基类方法
*/
ondragend : function (param, status) {
ondragend: function (param, status) {
var target = param.target; // 拖拽安放目标
if (!this.isDragend) {
// 拖拽的不是孤岛数据,如果没有图表接受孤岛数据,需要新增孤岛数据
......
......@@ -37,25 +37,25 @@ define(function (require) {
}
K.prototype = {
type : ecConfig.CHART_TYPE_K,
type: ecConfig.CHART_TYPE_K,
/**
* 绘制图形
*/
_buildShape : function () {
_buildShape: function () {
var series = this.series;
this.selectedMap = {};
// 水平垂直双向series索引 ,position索引到seriesIndex
var _position2sIndexMap = {
top : [],
bottom : []
top: [ ],
bottom: [ ]
};
var xAxis;
for (var i = 0, l = series.length; i < l; i++) {
if (series[i].type == ecConfig.CHART_TYPE_K) {
if (series[i].type === ecConfig.CHART_TYPE_K) {
series[i] = this.reformOption(series[i]);
xAxis = this.component.xAxis.getAxis(series[i].xAxisIndex);
if (xAxis.type == ecConfig.COMPONENT_TYPE_AXIS_CATEGORY
if (xAxis.type === ecConfig.COMPONENT_TYPE_AXIS_CATEGORY
) {
_position2sIndexMap[xAxis.getPosition()].push(i);
}
......@@ -78,7 +78,7 @@ define(function (require) {
*
* @param {number} seriesIndex 系列索引
*/
_buildSinglePosition : function (position, seriesArray) {
_buildSinglePosition: function (position, seriesArray) {
var mapData = this._mapData(seriesArray);
var locationMap = mapData.locationMap;
var maxDataLength = mapData.maxDataLength;
......@@ -97,7 +97,7 @@ define(function (require) {
* 数据整形
* 数组位置映射到系列索引
*/
_mapData : function (seriesArray) {
_mapData: function (seriesArray) {
var series = this.series;
var serie; // 临时映射变量
var serieName; // 临时映射变量
......@@ -121,15 +121,15 @@ define(function (require) {
maxDataLength = Math.max(maxDataLength, serie.data.length);
}
return {
locationMap : locationMap,
maxDataLength : maxDataLength
locationMap: locationMap,
maxDataLength: maxDataLength
};
},
/**
* 构建类目轴为水平方向的K线图系列
*/
_buildHorizontal : function (seriesArray, maxDataLength, locationMap) {
_buildHorizontal: function (seriesArray, maxDataLength, locationMap) {
var series = this.series;
// 确定类目轴和数值轴,同一方向随便找一个即可
var seriesIndex;
......@@ -161,18 +161,18 @@ define(function (require) {
pointList[seriesIndex] = [];
for (var i = 0, l = maxDataLength; i < l; i++) {
if (typeof categoryAxis.getNameByIndex(i) == 'undefined') {
if (categoryAxis.getNameByIndex(i) == null) {
// 系列数据超出类目轴长度
break;
}
data = serie.data[i];
value = typeof data != 'undefined'
? (typeof data.value != 'undefined'
value = data != null
? (data.value != null
? data.value
: data)
: '-';
if (value == '-' || value.length != 4) {
if (value === '-' || value.length != 4) {
// 数据格式不符
continue;
}
......@@ -195,7 +195,7 @@ define(function (require) {
/**
* 生成K线
*/
_buildKLine : function (seriesArray, pointList) {
_buildKLine: function (seriesArray, pointList) {
var series = this.series;
// normal:
var nLineWidth;
......@@ -228,9 +228,7 @@ define(function (require) {
seriesPL = this._getLargePointList(seriesPL);
}
if (serie.type == ecConfig.CHART_TYPE_K
&& typeof seriesPL != 'undefined'
) {
if (serie.type === ecConfig.CHART_TYPE_K && seriesPL != null) {
// 多级控制
queryTarget = serie;
nLineWidth = this.query(
......@@ -352,14 +350,14 @@ define(function (require) {
// console.log(this.shapeList)
},
_isLarge : function(singlePL) {
_isLarge: function(singlePL) {
return singlePL[0][1] < 0.5;
},
/**
* 大规模pointList优化
*/
_getLargePointList : function(singlePL) {
_getLargePointList: function(singlePL) {
var total = this.component.grid.getWidth();
var len = singlePL.length;
var newList = [];
......@@ -372,7 +370,7 @@ define(function (require) {
/**
* 生成K线图上的图形
*/
_getCandle : function (
_getCandle: function (
seriesIndex, dataIndex, name,
x, width, y0, y1, y2, y3,
nColor, nLinewidth, nLineColor,
......@@ -380,23 +378,23 @@ define(function (require) {
) {
var series = this.series;
var itemShape = {
zlevel : this._zlevelBase,
zlevel: this._zlevelBase,
clickable: this.deepQuery(
[series[seriesIndex].data[dataIndex], series[seriesIndex]], 'clickable'
),
style : {
x : x,
y : [y0, y1, y2, y3],
width : width,
color : nColor,
strokeColor : nLineColor,
lineWidth : nLinewidth,
brushType : 'both'
style: {
x: x,
y: [y0, y1, y2, y3],
width: width,
color: nColor,
strokeColor: nLineColor,
lineWidth: nLinewidth,
brushType: 'both'
},
highlightStyle : {
color : eColor,
strokeColor : eLineColor,
lineWidth : eLinewidth
highlightStyle: {
color: eColor,
strokeColor: eLineColor,
lineWidth: eLinewidth
},
_seriesIndex: seriesIndex
};
......@@ -412,7 +410,7 @@ define(function (require) {
},
// 位置转换
getMarkCoord : function (seriesIndex, mpData) {
getMarkCoord: function (seriesIndex, mpData) {
var serie = this.series[seriesIndex];
var xAxis = this.component.xAxis.getAxis(serie.xAxisIndex);
var yAxis = this.component.yAxis.getAxis(serie.yAxisIndex);
......@@ -431,7 +429,7 @@ define(function (require) {
/**
* 刷新
*/
refresh : function (newOption) {
refresh: function (newOption) {
if (newOption) {
this.option = newOption;
this.series = newOption.series;
......@@ -444,7 +442,7 @@ define(function (require) {
/**
* 动画设定
*/
addDataAnimation : function (params) {
addDataAnimation: function (params) {
var series = this.series;
var aniMap = {}; // seriesIndex索引参数
for (var i = 0, l = params.length; i < l; i++) {
......@@ -460,11 +458,11 @@ define(function (require) {
seriesIndex = this.shapeList[i]._seriesIndex;
if (aniMap[seriesIndex] && !aniMap[seriesIndex][3]) {
// 有数据删除才有移动的动画
if (this.shapeList[i].type == 'candle') {
if (this.shapeList[i].type === 'candle') {
dataIndex = ecData.get(this.shapeList[i], 'dataIndex');
serie = series[seriesIndex];
if (aniMap[seriesIndex][2]
&& dataIndex == serie.data.length - 1
&& dataIndex === serie.data.length - 1
) {
// 队头加入删除末尾
this.zr.delShape(this.shapeList[i].id);
......@@ -483,7 +481,7 @@ define(function (require) {
this.zr.animate(this.shapeList[i].id, '')
.when(
500,
{position : [x, y]}
{ position: [ x, y ] }
)
.start();
}
......
此差异已折叠。
......@@ -143,19 +143,18 @@ define(function (require) {
this._selectedMode[mapType] = this._selectedMode[mapType]
|| series[i].selectedMode;
if (typeof this._hoverable[mapType] == 'undefined'
|| this._hoverable[mapType] // false 1票否决
) {
if (this._hoverable[mapType] == null || this._hoverable[mapType]) {
// false 1票否决
this._hoverable[mapType] = series[i].hoverable;
}
if (typeof this._clickable[mapType] == 'undefined'
|| this._clickable[mapType] // false 1票否决
) {
if (this._clickable[mapType] == null || this._clickable[mapType]) {
// false 1票否决
this._clickable[mapType] = series[i].clickable;
}
if (typeof this._showLegendSymbol[mapType] == 'undefined'
|| this._showLegendSymbol[mapType] // false 1票否决
if (this._showLegendSymbol[mapType] == null
|| this._showLegendSymbol[mapType]
) {
// false 1票否决
this._showLegendSymbol[mapType] = series[i].showLegendSymbol;
}
......@@ -179,12 +178,10 @@ define(function (require) {
data[j][key];
}
else if (!isNaN(data[j].value)) {
typeof valueData[mapType][name].value
== 'undefined'
valueData[mapType][name].value == null
&& (valueData[mapType][name].value = 0);
valueData[mapType][name].value +=
data[j].value;
valueData[mapType][name].value += data[j].value;
}
}
//索引有该区域的系列样式
......@@ -561,19 +558,13 @@ define(function (require) {
//y = isNaN(cusY) ? padding : cusY;
y = this.parsePercent(cusY, zrHeight);
y = isNaN(y) ? padding : y;
if (typeof width == 'undefined') {
width = zrWidth - x - 2 * padding;
}
else {
width = this.parsePercent(width, zrWidth);
}
if (typeof height == 'undefined') {
height = zrHeight - y - 2 * padding;
}
else {
height = this.parsePercent(height, zrHeight);
}
width = width == null
? (zrWidth - x - 2 * padding)
: (this.parsePercent(width, zrWidth));
height = height == null
? (zrHeight - y - 2 * padding)
: (this.parsePercent(height, zrHeight));
var mapWidth = bbox.width;
var mapHeight = bbox.height;
......@@ -816,7 +807,7 @@ define(function (require) {
_style: zrUtil.clone(style),
_mapType: mapType
};
if (typeof style.scale != 'undefined') {
if (style.scale != null) {
shape.scale = zrUtil.clone(style.scale);
}
......@@ -839,7 +830,7 @@ define(function (require) {
break;
default :
shape = new PathShape(shape);
shape.pathArray = shape._parsePathData(shape.style.path);
shape.style.pathArray = shape.buildPathArray(shape.style.path);
break;
}
......@@ -853,22 +844,22 @@ define(function (require) {
textShape.clickable = shape.clickable =
this._clickable[mapType]
&& (typeof data.clickable == 'undefined' || data.clickable);
&& (data.clickable == null || data.clickable);
if (this._selectedMode[mapType]) {
this._selected[name] = typeof this._selected[name] != 'undefined'
this._selected[name] = this._selected[name] != null
? this._selected[name]
: data.selected;
this._mapTypeMap[name] = mapType;
if (typeof data.selectable == 'undefined' || data.selectable) {
if (data.selectable == null || data.selectable) {
shape.clickable = textShape.clickable = true;
shape.onclick = textShape.onclick = this.shapeHandler.onclick;
}
}
if (this._hoverable[mapType]
&& (typeof data.hoverable == 'undefined' || data.hoverable)
&& (data.hoverable == null || data.hoverable)
) {
textShape.hoverable = shape.hoverable = true;
shape.hoverConnect = textShape.id;
......@@ -1038,7 +1029,7 @@ define(function (require) {
var geoAndPos = this.pos2geo(mapType, [mx - left, my - top]);
if (delta > 0) {
delta = 1.2; // 放大
if (typeof this._scaleLimitMap[mapType].max != 'undefined'
if (this._scaleLimitMap[mapType].max != null
&& transform.baseScale >= this._scaleLimitMap[mapType].max
) {
return; // 缩放限制
......@@ -1046,7 +1037,7 @@ define(function (require) {
}
else {
delta = 1 / 1.2; // 缩小
if (typeof this._scaleLimitMap[mapType].min != 'undefined'
if (this._scaleLimitMap[mapType].min != null
&& transform.baseScale <= this._scaleLimitMap[mapType].min
) {
return; // 缩放限制
......
此差异已折叠。
......@@ -38,11 +38,11 @@ define(function (require) {
}
Scatter.prototype = {
type : ecConfig.CHART_TYPE_SCATTER,
type: ecConfig.CHART_TYPE_SCATTER,
/**
* 绘制图形
*/
_buildShape : function () {
_buildShape: function () {
var series = this.series;
this._sIndex2ColorMap = {}; // series默认颜色索引,seriesIndex索引到color
this._symbol = this.option.symbolList;
......@@ -60,7 +60,7 @@ define(function (require) {
for (var i = 0, l = series.length; i < l; i++) {
serie = series[i];
serieName = serie.name;
if (serie.type == ecConfig.CHART_TYPE_SCATTER) {
if (serie.type === ecConfig.CHART_TYPE_SCATTER) {
series[i] = this.reformOption(series[i]);
this._sIndex2ShapeMap[i] = this.query(serie, 'symbol')
|| this._symbol[i % this._symbol.length];
......@@ -122,7 +122,7 @@ define(function (require) {
/**
* 构建类目轴为水平方向的散点图系列
*/
_buildSeries : function (seriesArray) {
_buildSeries: function (seriesArray) {
if (seriesArray.length === 0) {
return;
}
......@@ -150,12 +150,12 @@ define(function (require) {
pointList[seriesIndex] = [];
for (var i = 0, l = serie.data.length; i < l; i++) {
data = serie.data[i];
value = typeof data != 'undefined'
? (typeof data.value != 'undefined'
value = data != null
? (data.value != null
? data.value
: data)
: '-';
if (value == '-' || value.length < 2) {
if (value === '-' || value.length < 2) {
// 数据格式不符
continue;
}
......@@ -179,18 +179,18 @@ define(function (require) {
this._buildPointList(pointList);
},
_markMap : function (xAxis, yAxis, data, pointList) {
_markMap: function (xAxis, yAxis, data, pointList) {
var xMarkMap = {
min0 : Number.POSITIVE_INFINITY,
max0 : Number.NEGATIVE_INFINITY,
sum0 : 0,
counter0 : 0,
average0 : 0,
min1 : Number.POSITIVE_INFINITY,
max1 : Number.NEGATIVE_INFINITY,
sum1 : 0,
counter1 : 0,
average1 : 0
min0: Number.POSITIVE_INFINITY,
max0: Number.NEGATIVE_INFINITY,
sum0: 0,
counter0: 0,
average0: 0,
min1: Number.POSITIVE_INFINITY,
max1: Number.NEGATIVE_INFINITY,
sum1: 0,
counter1: 0,
average1: 0
};
var value;
for (var i = 0, l = pointList.length; i < l; i++) {
......@@ -273,7 +273,7 @@ define(function (require) {
/**
* 生成折线和折线上的拐点
*/
_buildPointList : function (pointList) {
_buildPointList: function (pointList) {
var series = this.series;
var serie;
var seriesPL;
......@@ -323,7 +323,7 @@ define(function (require) {
/**
* 生成折线图上的拐点图形
*/
_getSymbol : function (seriesIndex, dataIndex, name, x, y) {
_getSymbol: function (seriesIndex, dataIndex, name, x, y) {
var series = this.series;
var serie = series[seriesIndex];
var data = serie.data[dataIndex];
......@@ -355,24 +355,24 @@ define(function (require) {
return itemShape;
},
_getLargeSymbol : function (pointList, nColor) {
_getLargeSymbol: function (pointList, nColor) {
return new SymbolShape({
zlevel : this._zlevelBase,
_main : true,
zlevel: this._zlevelBase,
_main: true,
hoverable: false,
style : {
pointList : pointList,
color : nColor,
strokeColor : nColor
style: {
pointList: pointList,
color: nColor,
strokeColor: nColor
},
highlightStyle : {
pointList : []
highlightStyle: {
pointList: [ ]
}
});
},
// 位置转换
getMarkCoord : function (seriesIndex, mpData) {
getMarkCoord: function (seriesIndex, mpData) {
var serie = this.series[seriesIndex];
var xMarkMap = this.xMarkMap[seriesIndex];
var xAxis = this.component.xAxis.getAxis(serie.xAxisIndex);
......@@ -380,12 +380,11 @@ define(function (require) {
var pos;
if (mpData.type
&& (mpData.type == 'max' || mpData.type == 'min' || mpData.type == 'average')
&& (mpData.type === 'max' || mpData.type === 'min' || mpData.type === 'average')
) {
// 特殊值内置支持
// 默认取纵值
var valueIndex = typeof mpData.valueIndex != 'undefined'
? mpData.valueIndex : 1;
var valueIndex = mpData.valueIndex != null ? mpData.valueIndex : 1;
pos = [
xMarkMap[mpData.type + 'X' + valueIndex],
xMarkMap[mpData.type + 'Y' + valueIndex],
......@@ -411,7 +410,7 @@ define(function (require) {
/**
* 刷新
*/
refresh : function (newOption) {
refresh: function (newOption) {
if (newOption) {
this.option = newOption;
this.series = newOption.series;
......@@ -426,7 +425,7 @@ define(function (require) {
* @param {Object} param
* @param {Object} status
*/
ondataRange : function (param, status) {
ondataRange: function (param, status) {
if (this.component.dataRange) {
this.refresh();
status.needRefresh = true;
......
......@@ -43,56 +43,56 @@ define(function (require) {
}
Axis.prototype = {
type : ecConfig.COMPONENT_TYPE_AXIS,
axisBase : {
type: ecConfig.COMPONENT_TYPE_AXIS,
axisBase: {
// 轴线
_buildAxisLine : function () {
_buildAxisLine: function () {
var lineWidth = this.option.axisLine.lineStyle.width;
var halfLineWidth = lineWidth / 2;
var axShape = {
_axisShape : 'axisLine',
zlevel : this._zlevelBase + 1,
hoverable : false
_axisShape: 'axisLine',
zlevel: this._zlevelBase + 1,
hoverable: false
};
switch (this.option.position) {
case 'left' :
axShape.style = {
xStart : this.grid.getX() - halfLineWidth,
yStart : this.grid.getYend(),
xEnd : this.grid.getX() - halfLineWidth,
yEnd : this.grid.getY(),
lineCap : 'round'
xStart: this.grid.getX() - halfLineWidth,
yStart: this.grid.getYend(),
xEnd: this.grid.getX() - halfLineWidth,
yEnd: this.grid.getY(),
lineCap: 'round'
};
break;
case 'right' :
axShape.style = {
xStart : this.grid.getXend() + halfLineWidth,
yStart : this.grid.getYend(),
xEnd : this.grid.getXend() + halfLineWidth,
yEnd : this.grid.getY(),
lineCap : 'round'
xStart: this.grid.getXend() + halfLineWidth,
yStart: this.grid.getYend(),
xEnd: this.grid.getXend() + halfLineWidth,
yEnd: this.grid.getY(),
lineCap: 'round'
};
break;
case 'bottom' :
axShape.style = {
xStart : this.grid.getX(),
yStart : this.grid.getYend() + halfLineWidth,
xEnd : this.grid.getXend(),
yEnd : this.grid.getYend() + halfLineWidth,
lineCap : 'round'
xStart: this.grid.getX(),
yStart: this.grid.getYend() + halfLineWidth,
xEnd: this.grid.getXend(),
yEnd: this.grid.getYend() + halfLineWidth,
lineCap: 'round'
};
break;
case 'top' :
axShape.style = {
xStart : this.grid.getX(),
yStart : this.grid.getY() - halfLineWidth,
xEnd : this.grid.getXend(),
yEnd : this.grid.getY() - halfLineWidth,
lineCap : 'round'
xStart: this.grid.getX(),
yStart: this.grid.getY() - halfLineWidth,
xEnd: this.grid.getXend(),
yEnd: this.grid.getY() - halfLineWidth,
lineCap: 'round'
};
break;
}
if (this.option.name !== '') {
if (this.option.name !== '') { // 别帮我代码规范
axShape.style.text = this.option.name;
axShape.style.textPosition = this.option.nameLocation;
axShape.style.textFont = this.getFont(this.option.nameTextStyle);
......@@ -129,7 +129,7 @@ define(function (require) {
this.shapeList.push(axShape);
},
_axisLabelClickable : function(clickable, axShape) {
_axisLabelClickable: function(clickable, axShape) {
if (clickable) {
ecData.pack(
axShape, undefined, -1, undefined, -1, axShape.style.text
......@@ -137,7 +137,7 @@ define(function (require) {
axShape.hoverable = true;
axShape.clickable = true;
axShape.highlightStyle = {
color : zrColor.lift(axShape.style.color, 1),
color: zrColor.lift(axShape.style.color, 1),
brushType: 'fill'
};
return axShape;
......@@ -147,15 +147,15 @@ define(function (require) {
}
},
refixAxisShape : function(zeroX, zeroY) {
refixAxisShape: function(zeroX, zeroY) {
if (!this.option.axisLine.onZero) {
return;
}
var tickLength;
if (this.isHorizontal() && typeof zeroY != 'undefined') {
if (this.isHorizontal() && zeroY != null) {
// 横向布局调整纵向y
for (var i = 0, l = this.shapeList.length; i < l; i++) {
if (this.shapeList[i]._axisShape == 'axisLine') {
if (this.shapeList[i]._axisShape === 'axisLine') {
this.shapeList[i].style.yStart
= this.shapeList[i].style.yEnd
= this.subPixelOptimize(
......@@ -163,7 +163,7 @@ define(function (require) {
);
this.zr.modShape(this.shapeList[i].id);
}
else if (this.shapeList[i]._axisShape == 'axisTick') {
else if (this.shapeList[i]._axisShape === 'axisTick') {
tickLength = this.shapeList[i].style.yEnd
- this.shapeList[i].style.yStart;
this.shapeList[i].style.yStart = zeroY - tickLength;
......@@ -172,10 +172,10 @@ define(function (require) {
}
}
}
if (!this.isHorizontal() && typeof zeroX != 'undefined') {
if (!this.isHorizontal() && zeroX != null) {
// 纵向布局调整横向x
for (var i = 0, l = this.shapeList.length; i < l; i++) {
if (this.shapeList[i]._axisShape == 'axisLine') {
if (this.shapeList[i]._axisShape === 'axisLine') {
this.shapeList[i].style.xStart
= this.shapeList[i].style.xEnd
= this.subPixelOptimize(
......@@ -183,7 +183,7 @@ define(function (require) {
);
this.zr.modShape(this.shapeList[i].id);
}
else if (this.shapeList[i]._axisShape == 'axisTick') {
else if (this.shapeList[i]._axisShape === 'axisTick') {
tickLength = this.shapeList[i].style.xEnd
- this.shapeList[i].style.xStart;
this.shapeList[i].style.xStart = zeroX;
......@@ -194,22 +194,22 @@ define(function (require) {
}
},
getPosition : function () {
getPosition: function () {
return this.option.position;
},
isHorizontal : function() {
return this.option.position == 'bottom' || this.option.position == 'top';
isHorizontal: function() {
return this.option.position === 'bottom' || this.option.position === 'top';
}
},
/**
* 参数修正&默认值赋值,重载基类方法
* @param {Object} opt 参数
*/
reformOption : function (opt) {
reformOption: function (opt) {
// 不写或传了个空数值默认为数值轴
if (!opt || (opt instanceof Array && opt.length === 0)) {
opt = [{type : ecConfig.COMPONENT_TYPE_AXIS_VALUE}];
opt = [ { type: ecConfig.COMPONENT_TYPE_AXIS_VALUE } ];
}
else if (!(opt instanceof Array)){
opt = [opt];
......@@ -220,7 +220,7 @@ define(function (require) {
opt = [opt[0],opt[1]];
}
if (this.axisType == 'xAxis') {
if (this.axisType === 'xAxis') {
// 横轴位置默认配置
if (!opt[0].position // 没配置或配置错
|| (opt[0].position != 'bottom'
......@@ -229,8 +229,7 @@ define(function (require) {
opt[0].position = 'bottom';
}
if (opt.length > 1) {
opt[1].position = opt[0].position == 'bottom'
? 'top' : 'bottom';
opt[1].position = opt[0].position === 'bottom' ? 'top' : 'bottom';
}
for (var i = 0, l = opt.length; i < l; i++) {
......@@ -251,8 +250,7 @@ define(function (require) {
}
if (opt.length > 1) {
opt[1].position = opt[0].position == 'left'
? 'right' : 'left';
opt[1].position = opt[0].position === 'left' ? 'right' : 'left';
}
for (var i = 0, l = opt.length; i < l; i++) {
......@@ -270,11 +268,11 @@ define(function (require) {
/**
* 刷新
*/
refresh : function (newOption) {
refresh: function (newOption) {
var axisOption;
if (newOption) {
this.option = newOption;
if (this.axisType == 'xAxis') {
if (this.axisType === 'xAxis') {
this.option.xAxis = this.reformOption(newOption.xAxis);
axisOption = this.option.xAxis;
}
......@@ -304,7 +302,7 @@ define(function (require) {
);
}
else if (axisOption && axisOption[i]) {
this._axisList[i] = axisOption[i].type == 'category'
this._axisList[i] = axisOption[i].type === 'category'
? new CategoryAxis(
this.ecTheme, this.messageCenter, this.zr,
axisOption[i], this.myChart, this.axisBase
......@@ -323,11 +321,11 @@ define(function (require) {
* 根据值换算位置
* @param {number} idx 坐标轴索引0~1
*/
getAxis : function (idx) {
getAxis: function (idx) {
return this._axisList[idx];
},
clear : function () {
clear: function () {
for (var i = 0, l = this._axisList.length; i < l; i++) {
this._axisList[i].dispose && this._axisList[i].dispose();
}
......
......@@ -55,12 +55,12 @@ define(function (require) {
* 基类方法
*/
Base.prototype = {
canvasSupported : require('zrender/tool/env').canvasSupported,
canvasSupported: require('zrender/tool/env').canvasSupported,
/**
* 获取zlevel基数配置
* @param {Object} contentType
*/
getZlevelBase : function (contentType) {
getZlevelBase: function (contentType) {
contentType = contentType || this.type + '';
switch (contentType) {
......@@ -112,7 +112,7 @@ define(function (require) {
*
* @return {Object} 修正后的参数
*/
reformOption : function (opt) {
reformOption: function (opt) {
return zrUtil.merge(
opt || {},
zrUtil.clone(this.ecTheme[this.type] || {})
......@@ -122,7 +122,7 @@ define(function (require) {
/**
* css类属性数组补全,如padding,margin等~
*/
reformCssArray : function (p) {
reformCssArray: function (p) {
if (p instanceof Array) {
switch (p.length + '') {
case '4':
......@@ -142,9 +142,9 @@ define(function (require) {
}
},
getShapeById : function(id) {
getShapeById: function(id) {
for (var i = 0, l = this.shapeList.length; i < l; i++) {
if (this.shapeList[i].id == id) {
if (this.shapeList[i].id === id) {
return this.shapeList[i];
}
}
......@@ -154,7 +154,7 @@ define(function (require) {
/**
* 获取自定义和默认配置合并后的字体设置
*/
getFont : function (textStyle) {
getFont: function (textStyle) {
var finalTextStyle = zrUtil.merge(
zrUtil.clone(textStyle) || {},
this.ecTheme.textStyle
......@@ -165,16 +165,16 @@ define(function (require) {
+ finalTextStyle.fontFamily;
},
getItemStyleColor : function (itemColor, seriesIndex, dataIndex, data) {
return typeof itemColor == 'function'
getItemStyleColor: function (itemColor, seriesIndex, dataIndex, data) {
return typeof itemColor === 'function'
? itemColor(seriesIndex, dataIndex, data) : itemColor;
},
// 亚像素优化
subPixelOptimize : function (position, lineWidth) {
if (lineWidth % 2 == 1) {
//position += position == Math.ceil(position) ? 0.5 : 0;
subPixelOptimize: function (position, lineWidth) {
if (lineWidth % 2 === 1) {
//position += position === Math.ceil(position) ? 0.5 : 0;
position = Math.floor(position) + 0.5;
}
else {
......@@ -184,7 +184,7 @@ define(function (require) {
},
resize : function () {
resize: function () {
this.refresh && this.refresh();
this.clearEffectShape && this.clearEffectShape(true);
var self = this;
......@@ -205,20 +205,20 @@ define(function (require) {
/**
* 释放后实例不可用
*/
dispose : function () {
dispose: function () {
this.clear();
this.shapeList = null;
this.effectList = null;
},
query : ecQuery.query,
deepQuery : ecQuery.deepQuery,
deepMerge : ecQuery.deepMerge,
query: ecQuery.query,
deepQuery: ecQuery.deepQuery,
deepMerge: ecQuery.deepMerge,
parsePercent : number.parsePercent,
parseCenter : number.parseCenter,
parseRadius : number.parseRadius,
numAddCommas : number.addCommas
parsePercent: number.parsePercent,
parseCenter: number.parseCenter,
parseRadius: number.parseRadius,
numAddCommas: number.addCommas
};
return Base;
......
......@@ -31,45 +31,52 @@ define(function (require) {
}
Grid.prototype = {
type : ecConfig.COMPONENT_TYPE_GRID,
type: ecConfig.COMPONENT_TYPE_GRID,
getX : function () {
getX: function () {
return this._x;
},
getY : function () {
getY: function () {
return this._y;
},
getWidth : function () {
getWidth: function () {
return this._width;
},
getHeight : function () {
getHeight: function () {
return this._height;
},
getXend : function () {
getXend: function () {
return this._x + this._width;
},
getYend : function () {
getYend: function () {
return this._y + this._height;
},
getArea : function () {
getArea: function () {
return {
x : this._x,
y : this._y,
width : this._width,
height : this._height
x: this._x,
y: this._y,
width: this._width,
height: this._height
};
},
getBbox: function() {
return [
[ this._x, this._y ],
[ this.getXend(), this.getYend() ]
];
},
/**
* 实在找不到合适的地方做了,各种粗暴的写法~ -_-
*/
refixAxisShape : function(component) {
refixAxisShape: function(component) {
var zeroX;
var zeroY;
var axisList = component.xAxis._axisList.concat(component.yAxis._axisList);
......@@ -94,7 +101,7 @@ define(function (require) {
}
},
refresh : function (newOption) {
refresh: function (newOption) {
if (newOption
|| this._zrWidth != this.zr.getWidth()
|| this._zrHeight != this.zr.getHeight()
......@@ -132,18 +139,18 @@ define(function (require) {
this._y = this.subPixelOptimize(this._y, gridOption.borderWidth);
this.shapeList.push(new RectangleShape({
zlevel : this._zlevelBase,
hoverable : false,
style : {
x : this._x,
y : this._y,
width : this._width,
height : this._height,
brushType : gridOption.borderWidth > 0 ? 'both' : 'fill',
color : gridOption.backgroundColor,
zlevel: this._zlevelBase,
hoverable: false,
style: {
x: this._x,
y: this._y,
width: this._width,
height: this._height,
brushType: gridOption.borderWidth > 0 ? 'both' : 'fill',
color: gridOption.backgroundColor,
strokeColor: gridOption.borderColor,
lineWidth : gridOption.borderWidth
// type : this.option.splitArea.areaStyle.type,
lineWidth: gridOption.borderWidth
// type: this.option.splitArea.areaStyle.type,
}
}));
this.zr.addShape(this.shapeList[0]);
......
此差异已折叠。
......@@ -140,7 +140,7 @@ define(function (require) {
var r = Math.min(width / 2 - 5, height) / 2;
var x = this._itemGroupLocation.x
+ (text == 'scaleDown' ? (width - r) : r);
+ (text === 'scaleDown' ? (width - r) : r);
var y = this._itemGroupLocation.y + this._itemGroupLocation.height - r;
var scaleShape = {
......@@ -150,7 +150,7 @@ define(function (require) {
y: y,
r: r,
color: this.rcOption.handlerColor,
text: text == 'scaleDown' ? '-' : '+',
text: text === 'scaleDown' ? '-' : '+',
textX: x,
textY: y - 2,
textAlign: 'center',
......@@ -291,7 +291,7 @@ define(function (require) {
this._dispatchEvent(params.event, params.target._roamType);
},
_dispatchEvent : function(event, roamType){
_dispatchEvent: function(event, roamType){
this.messageCenter.dispatch(
ecConfig.EVENT.ROAMCONTROLLER,
event,
......
此差异已折叠。
......@@ -30,8 +30,8 @@ define(function (require) {
}
Title.prototype = {
type : ecConfig.COMPONENT_TYPE_TITLE,
_buildShape : function () {
type: ecConfig.COMPONENT_TYPE_TITLE,
_buildShape: function () {
// 标题元素组的位置参数,通过计算所得x, y, width, height
this._itemGroupLocation = this._getItemGroupLocation();
......@@ -46,7 +46,7 @@ define(function (require) {
/**
* 构建所有标题元素
*/
_buildItem : function () {
_buildItem: function () {
var text = this.titleOption.text;
var link = this.titleOption.link;
var target = this.titleOption.target;
......@@ -62,16 +62,16 @@ define(function (require) {
var height = this._itemGroupLocation.height;
var textShape = {
zlevel : this._zlevelBase,
style : {
y : y,
color : this.titleOption.textStyle.color,
zlevel: this._zlevelBase,
style: {
y: y,
color: this.titleOption.textStyle.color,
text: text,
textFont: font,
textBaseline: 'top'
},
highlightStyle: {
color : zrColor.lift(this.titleOption.textStyle.color, 1),
color: zrColor.lift(this.titleOption.textStyle.color, 1),
brushType: 'fill'
},
hoverable: false
......@@ -90,16 +90,16 @@ define(function (require) {
}
var subtextShape = {
zlevel : this._zlevelBase,
style : {
y : y + height,
color : this.titleOption.subtextStyle.color,
zlevel: this._zlevelBase,
style: {
y: y + height,
color: this.titleOption.subtextStyle.color,
text: subtext,
textFont: subfont,
textBaseline: 'bottom'
},
highlightStyle: {
color : zrColor.lift(this.titleOption.subtextStyle.color, 1),
color: zrColor.lift(this.titleOption.subtextStyle.color, 1),
brushType: 'fill'
},
hoverable: false
......@@ -149,25 +149,24 @@ define(function (require) {
subtext !== '' && this.shapeList.push(new TextShape(subtextShape));
},
_buildBackground : function () {
_buildBackground: function () {
var pTop = this.titleOption.padding[0];
var pRight = this.titleOption.padding[1];
var pBottom = this.titleOption.padding[2];
var pLeft = this.titleOption.padding[3];
this.shapeList.push(new RectangleShape({
zlevel : this._zlevelBase,
zlevel: this._zlevelBase,
hoverable :false,
style : {
x : this._itemGroupLocation.x - pLeft,
y : this._itemGroupLocation.y - pTop,
width : this._itemGroupLocation.width + pLeft + pRight,
height : this._itemGroupLocation.height + pTop + pBottom,
brushType : this.titleOption.borderWidth === 0
? 'fill' : 'both',
color : this.titleOption.backgroundColor,
strokeColor : this.titleOption.borderColor,
lineWidth : this.titleOption.borderWidth
style: {
x: this._itemGroupLocation.x - pLeft,
y: this._itemGroupLocation.y - pTop,
width: this._itemGroupLocation.width + pLeft + pRight,
height: this._itemGroupLocation.height + pTop + pBottom,
brushType: this.titleOption.borderWidth === 0 ? 'fill' : 'both',
color: this.titleOption.backgroundColor,
strokeColor: this.titleOption.borderColor,
lineWidth: this.titleOption.borderWidth
}
}));
},
......@@ -175,7 +174,7 @@ define(function (require) {
/**
* 根据选项计算标题实体的位置坐标
*/
_getItemGroupLocation : function () {
_getItemGroupLocation: function () {
var text = this.titleOption.text;
var subtext = this.titleOption.subtext;
var font = this.getFont(this.titleOption.textStyle);
......@@ -235,17 +234,17 @@ define(function (require) {
}
return {
x : x,
y : y,
width : totalWidth,
height : totalHeight
x: x,
y: y,
width: totalWidth,
height: totalHeight
};
},
/**
* 刷新
*/
refresh : function (newOption) {
refresh: function (newOption) {
if (newOption) {
this.option = newOption;
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
......@@ -3,7 +3,7 @@
*/
define(function() {
return {
'Russia' : [100, 60],
'United States of America' : [-99, 38]
'Russia': [ 100, 60 ],
'United States of America': [ -99, 38 ]
};
});
\ No newline at end of file
......@@ -65,7 +65,7 @@ define(function (require) {
}
var mapParams = {
'none' : {
'none': {
getGeoJson: function(callback) {
callback({
type: 'FeatureCollection',
......@@ -97,10 +97,10 @@ define(function (require) {
});
}
},
'南海诸岛' : {
textCoord : [126, 25],
getPath : function (leftTop, scale) {
// scale.x : width = 10.51 : 64
'南海诸岛': {
textCoord: [126, 25],
getPath: function (leftTop, scale) {
// scale.x: width = 10.51 : 64
var pList = [
[
[0,3.5],[7,11.2],[15,11.9],[30,7],[42,0.7],[52,0.7],
......@@ -402,7 +402,7 @@ define(function (require) {
};
return {
decode : decode,
params : mapParams
decode: decode,
params: mapParams
};
});
\ No newline at end of file
......@@ -48,10 +48,10 @@ define(function() {
}
json.srcSize = {
left : convertorParse.xmin.toFixed(4)*1,
top : convertorParse.ymin.toFixed(4)*1,
width : (convertorParse.xmax - convertorParse.xmin).toFixed(4)*1,
height : (convertorParse.ymax - convertorParse.ymin).toFixed(4)*1
left: convertorParse.xmin.toFixed(4)*1,
top: convertorParse.ymin.toFixed(4)*1,
width: (convertorParse.xmax - convertorParse.xmin).toFixed(4)*1,
height: (convertorParse.ymax - convertorParse.ymin).toFixed(4)*1
};
return json;
......@@ -59,13 +59,13 @@ define(function() {
var convertor = {
//调整俄罗斯东部到地图右侧与俄罗斯相连
formatPoint : function (p) {
formatPoint: function (p) {
return [
((p[0] < -168.5 && p[1] > 63.8) ? p[0] + 360 : p[0]) + 168.5,
90 - p[1]
];
},
makePoint : function (p) {
makePoint: function (p) {
var self = this;
var point = self.formatPoint(p);
// for cp
......@@ -79,11 +79,11 @@ define(function() {
+ convertor.offset.top;
return [x, y];
},
Point : function (coordinates) {
Point: function (coordinates) {
coordinates = this.makePoint(coordinates);
return coordinates.join(',');
},
LineString : function (coordinates) {
LineString: function (coordinates) {
var str = '';
var point;
for (var i = 0, len = coordinates.length; i < len; i++) {
......@@ -96,28 +96,28 @@ define(function() {
}
return str;
},
Polygon : function (coordinates) {
Polygon: function (coordinates) {
var str = '';
for (var i = 0, len = coordinates.length; i < len; i++) {
str = str + convertor.LineString(coordinates[i]) + 'z';
}
return str;
},
MultiPoint : function (coordinates) {
MultiPoint: function (coordinates) {
var arr = [];
for (var i = 0, len = coordinates.length; i < len; i++) {
arr.push(convertor.Point(coordinates[i]));
}
return arr;
},
MultiLineString : function (coordinates) {
MultiLineString: function (coordinates) {
var str = '';
for (var i = 0, len = coordinates.length; i < len; i++) {
str += convertor.LineString(coordinates[i]);
}
return str;
},
MultiPolygon : function (coordinates) {
MultiPolygon: function (coordinates) {
var str = '';
for (var i = 0, len = coordinates.length; i < len; i++) {
str += convertor.Polygon(coordinates[i]);
......@@ -127,9 +127,9 @@ define(function() {
};
var convertorParse = {
formatPoint : convertor.formatPoint,
formatPoint: convertor.formatPoint,
makePoint : function (p) {
makePoint: function (p) {
var self = this;
var point = self.formatPoint(p);
var x = point[0];
......@@ -139,30 +139,30 @@ define(function() {
if (self.ymin > y) { self.ymin = y; }
if (self.ymax < y) { self.ymax = y; }
},
Point : function (coordinates) {
Point: function (coordinates) {
this.makePoint(coordinates);
},
LineString : function (coordinates) {
LineString: function (coordinates) {
for (var i = 0, len = coordinates.length; i < len; i++) {
this.makePoint(coordinates[i]);
}
},
Polygon : function (coordinates) {
Polygon: function (coordinates) {
for (var i = 0, len = coordinates.length; i < len; i++) {
this.LineString(coordinates[i]);
}
},
MultiPoint : function (coordinates) {
MultiPoint: function (coordinates) {
for (var i = 0, len = coordinates.length; i < len; i++) {
this.Point(coordinates[i]);
}
},
MultiLineString : function (coordinates) {
MultiLineString: function (coordinates) {
for (var i = 0, len = coordinates.length; i < len; i++) {
this.LineString(coordinates[i]);
}
},
MultiPolygon : function (coordinates) {
MultiPolygon: function (coordinates) {
for (var i = 0, len = coordinates.length; i < len; i++) {
this.Polygon(coordinates[i]);
}
......@@ -179,10 +179,10 @@ define(function() {
}
transform.offset = {
x : json.srcSize.left,
y : json.srcSize.top,
left : transform.OffsetLeft || 0,
top : transform.OffsetTop || 0
x: json.srcSize.left,
y: json.srcSize.top,
left: transform.OffsetLeft || 0,
top: transform.OffsetTop || 0
};
convertor.scale = transform.scale;
......@@ -218,23 +218,23 @@ define(function() {
shapeType = gm.type;
shapeCoordinates = gm.coordinates;
convertor._bbox = {
xmin : 360,
xmax : -360,
ymin : 180,
ymax : -180
xmin: 360,
xmax: -360,
ymin: 180,
ymax: -180
};
str = convertor[shapeType](shapeCoordinates);
pathArray.push({
//type : shapeType,
path : str,
cp : shape.properties.cp
? convertor.makePoint(shape.properties.cp)
: convertor.makePoint([
(convertor._bbox.xmin + convertor._bbox.xmax) / 2,
(convertor._bbox.ymin + convertor._bbox.ymax) / 2
]),
properties : shape.properties,
id : shape.id
// type: shapeType,
path: str,
cp: shape.properties.cp
? convertor.makePoint(shape.properties.cp)
: convertor.makePoint([
(convertor._bbox.xmin + convertor._bbox.xmax) / 2,
(convertor._bbox.ymin + convertor._bbox.ymax) / 2
]),
properties: shape.properties,
id: shape.id
});
}
......@@ -276,9 +276,9 @@ define(function() {
}
return {
getBbox : getBbox,
geoJson2Path : geoJson2Path,
pos2geo : pos2geo,
geo2pos : geo2pos
getBbox: getBbox,
geoJson2Path: geoJson2Path,
pos2geo: pos2geo,
geo2pos: geo2pos
};
});
\ No newline at end of file
......@@ -25,10 +25,10 @@ define(function(require) {
var width = toFloat(svgNode.getAttribute('width'));
var height = toFloat(svgNode.getAttribute('height'));
return {
left : x,
top : y,
width : width,
height : height
left: x,
top: y,
width: width,
height: height
};
}
......@@ -44,7 +44,7 @@ define(function(require) {
// Common attributes
obj.scale = scale;
obj.properties = {
name : root.getAttribute('name') || ''
name: root.getAttribute('name') || ''
};
obj.id = root.id;
extendCommonAttributes(obj, root);
......@@ -126,11 +126,11 @@ define(function(require) {
var shapeBuilders = {
path: function(xmlNode, scale) {
var path = xmlNode.getAttribute('d');
var rect = PathShape.prototype.getRect({path : path});
var rect = PathShape.prototype.getRect({ path : path });
return {
shapeType: 'path',
path : path,
cp : [
path: path,
cp: [
(rect.x + rect.width / 2) * scale[0],
(rect.y + rect.height / 2) * scale[1]
]
......@@ -149,7 +149,7 @@ define(function(require) {
y: y,
width: width,
height: height,
cp : [
cp: [
(x + width / 2) * scale[0],
(y + height / 2) * scale[1]
]
......@@ -168,7 +168,7 @@ define(function(require) {
yStart: y1,
xEnd: x2,
yEnd: y2,
cp : [
cp: [
(x1 + x2) * 0.5 * scale[0],
(y1 + y2) * 0.5 * scale[1]
]
......@@ -231,7 +231,7 @@ define(function(require) {
return {
shapeType: 'polygon',
pointList: points,
cp : [
cp: [
(min[0] + max[0]) / 2 * scale[0],
(min[1] + max[1]) / 2 * scale[0]
]
......@@ -246,9 +246,9 @@ define(function(require) {
};
return {
getBbox : getBbox,
geoJson2Path : geoJson2Path,
pos2geo : pos2geo,
geo2pos : geo2pos
getBbox: getBbox,
geoJson2Path: geoJson2Path,
pos2geo: pos2geo,
geo2pos: geo2pos
};
});
\ No newline at end of file
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册