提交 280d1827 编写于 作者: L lang

Use coord to specify the marker's position

上级 d476554e
...@@ -37,7 +37,7 @@ define(function (require) { ...@@ -37,7 +37,7 @@ define(function (require) {
var lineData = new List(['value'], this); var lineData = new List(['value'], this);
function geoCoordGetter(item, dim, dataIndex, dimIndex) { function geoCoordGetter(item, dim, dataIndex, dimIndex) {
return item.geoCoord && item.geoCoord[dimIndex]; return item.coord && item.coord[dimIndex];
} }
fromData.initData(fromDataArr, null, geoCoordGetter); fromData.initData(fromDataArr, null, geoCoordGetter);
......
...@@ -191,7 +191,7 @@ define(function (require) { ...@@ -191,7 +191,7 @@ define(function (require) {
}, },
// 也是选中样式 // 也是选中样式
emphasis: { emphasis: {
areaColor: 'rgba(255,215,0,0.8)' areaColor: 'rgba(255,215, 0, 0.8)'
} }
} }
} }
......
...@@ -48,7 +48,6 @@ define(function (require) { ...@@ -48,7 +48,6 @@ define(function (require) {
mlFrom[valueAxisKey] = mlTo[valueAxisKey] = value; mlFrom[valueAxisKey] = mlTo[valueAxisKey] = value;
item = [mlFrom, mlTo, { // Extra option for tooltip and label item = [mlFrom, mlTo, { // Extra option for tooltip and label
__rawValue: value,
type: mlType type: mlType
}]; }];
} }
...@@ -81,11 +80,6 @@ define(function (require) { ...@@ -81,11 +80,6 @@ define(function (require) {
+ ((name ? encodeHTML(name) + ' : ' : '') + formattedValue); + ((name ? encodeHTML(name) + ' : ' : '') + formattedValue);
}, },
getRawValue: function (idx) {
var option = this._data.getItemModel(idx).option;
return zrUtil.retrieve(option && option.__rawValue, option && option.value, '');
},
getRawDataArray: function () { getRawDataArray: function () {
return this.option.data; return this.option.data;
}, },
...@@ -257,10 +251,14 @@ define(function (require) { ...@@ -257,10 +251,14 @@ define(function (require) {
zrUtil.curry(markLineFilter, coordSys) zrUtil.curry(markLineFilter, coordSys)
); );
fromData.initData( fromData.initData(
zrUtil.map(optData, function (item) { return item[0]; }) zrUtil.map(optData, function (item) { return item[0]; }),
null,
markerHelper.dimValueGetter
); );
toData.initData( toData.initData(
zrUtil.map(optData, function (item) { return item[1]; }) zrUtil.map(optData, function (item) { return item[1]; }),
null,
markerHelper.dimValueGetter
); );
lineData.initData( lineData.initData(
zrUtil.map(optData, function (item) { return item[2]; }) zrUtil.map(optData, function (item) { return item[2]; })
......
...@@ -29,11 +29,6 @@ define(function (require) { ...@@ -29,11 +29,6 @@ define(function (require) {
+ ((name ? encodeHTML(name) + ' : ' : '') + formattedValue); + ((name ? encodeHTML(name) + ' : ' : '') + formattedValue);
}, },
getRawValue: function (idx) {
var option = this._data.getItemModel(idx).option;
return zrUtil.retrieve(option.__rawValue, option.value, '');
},
getData: function () { getData: function () {
return this._data; return this._data;
}, },
...@@ -153,7 +148,9 @@ define(function (require) { ...@@ -153,7 +148,9 @@ define(function (require) {
markerHelper.dataTransform, seriesData, coordSys markerHelper.dataTransform, seriesData, coordSys
)), )),
zrUtil.curry(markerHelper.dataFilter, coordSys) zrUtil.curry(markerHelper.dataFilter, coordSys)
) ),
null,
markerHelper.dimValueGetter
); );
} }
......
...@@ -20,20 +20,20 @@ define(function (require) { ...@@ -20,20 +20,20 @@ define(function (require) {
function markerTypeCalculatorWithExtent(percent, data, baseAxisDim, valueAxisDim, valueIndex) { function markerTypeCalculatorWithExtent(percent, data, baseAxisDim, valueAxisDim, valueIndex) {
var extent = data.getDataExtent(valueAxisDim); var extent = data.getDataExtent(valueAxisDim);
var valueArr = []; var coordArr = [];
var min = extent[0]; var min = extent[0];
var max = extent[1]; var max = extent[1];
var val = (max - min) * percent + min; var val = (max - min) * percent + min;
var dataIndex = data.indexOfNearest(valueAxisDim, val); var dataIndex = data.indexOfNearest(valueAxisDim, val);
valueArr[1 - valueIndex] = data.get(baseAxisDim, dataIndex); coordArr[1 - valueIndex] = data.get(baseAxisDim, dataIndex);
valueArr[valueIndex] = data.get(valueAxisDim, dataIndex, true); coordArr[valueIndex] = data.get(valueAxisDim, dataIndex, true);
var precision = getPrecision(data, valueAxisDim, dataIndex); var precision = getPrecision(data, valueAxisDim, dataIndex);
if (precision >= 0) { if (precision >= 0) {
valueArr[valueIndex] = +valueArr[valueIndex].toFixed(precision); coordArr[valueIndex] = +coordArr[valueIndex].toFixed(precision);
} }
return valueArr; return coordArr;
} }
var curry = zrUtil.curry; var curry = zrUtil.curry;
...@@ -65,7 +65,7 @@ define(function (require) { ...@@ -65,7 +65,7 @@ define(function (require) {
/** /**
* Transform markPoint data item to format used in List by do the following * Transform markPoint data item to format used in List by do the following
* 1. Calculate statistic like `max`, `min`, `average` * 1. Calculate statistic like `max`, `min`, `average`
* 2. Convert `item.xAxis`, `item.yAxis` to `item.value` array * 2. Convert `item.xAxis`, `item.yAxis` to `item.coord` array
* @param {module:echarts/data/List} data * @param {module:echarts/data/List} data
* @param {module:echarts/coord/*} [coordSys] * @param {module:echarts/coord/*} [coordSys]
* @param {Object} item * @param {Object} item
...@@ -73,9 +73,9 @@ define(function (require) { ...@@ -73,9 +73,9 @@ define(function (require) {
*/ */
var dataTransform = function (data, coordSys, item) { var dataTransform = function (data, coordSys, item) {
// 1. If not specify the position with pixel directly // 1. If not specify the position with pixel directly
// 2. If value is not a data array. Which uses xAxis, yAxis to specify the value on each dimension // 2. If `coord` is not a data array. Which uses `xAxis`, `yAxis` to specify the coord on each dimension
if ((isNaN(item.x) || isNaN(item.y)) if ((isNaN(item.x) || isNaN(item.y))
&& !zrUtil.isArray(item.value) && !zrUtil.isArray(item.coord)
&& coordSys && coordSys
) { ) {
var valueAxisDim; var valueAxisDim;
...@@ -101,26 +101,17 @@ define(function (require) { ...@@ -101,26 +101,17 @@ define(function (require) {
// Transform the properties xAxis, yAxis, radiusAxis, angleAxis, geoCoord to value // Transform the properties xAxis, yAxis, radiusAxis, angleAxis, geoCoord to value
item = zrUtil.extend({}, item); item = zrUtil.extend({}, item);
if (item.type && markerTypeCalculator[item.type] && baseAxis && valueAxis) { if (item.type && markerTypeCalculator[item.type] && baseAxis && valueAxis) {
var value = markerTypeCalculator[item.type]( item.coord = markerTypeCalculator[item.type](
data, baseAxis.dim, valueAxisDim, valueIndex data, baseAxis.dim, valueAxisDim, valueIndex
); );
if (item.value != null) {
value.push(+item.value);
}
item.value = value;
} }
else { else {
var originalValue = item.value;
// FIXME Only has one of xAxis and yAxis. // FIXME Only has one of xAxis and yAxis.
item.value = [ item.coord = [
item.xAxis != null ? item.xAxis : item.radiusAxis, item.xAxis != null ? item.xAxis : item.radiusAxis,
item.yAxis != null ? item.yAxis : item.angleAxis item.yAxis != null ? item.yAxis : item.angleAxis
]; ];
if (originalValue != null) {
item.value.push(+originalValue);
}
} }
item.__rawValue = item.value[valueIndex];
} }
return item; return item;
}; };
...@@ -135,12 +126,23 @@ define(function (require) { ...@@ -135,12 +126,23 @@ define(function (require) {
*/ */
var dataFilter = function (coordSys, item) { var dataFilter = function (coordSys, item) {
// Alwalys return true if there is no coordSys // Alwalys return true if there is no coordSys
return (coordSys && item.value && (item.x == null || item.y == null)) return (coordSys && item.coord && (item.x == null || item.y == null))
? coordSys.containData(item.value) : true; ? coordSys.containData(item.coord) : true;
};
var dimValueGetter = function (item, dimName, dataIndex, dimIndex) {
// x, y, radius, angle
if (dimIndex < 2) {
return item.coord && item.coord[dimIndex];
}
else {
item.value;
}
}; };
return { return {
dataTransform: dataTransform, dataTransform: dataTransform,
dataFilter: dataFilter dataFilter: dataFilter,
dimValueGetter: dimValueGetter
}; };
}); });
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册