提交 bcea9b40 编写于 作者: S sushuang

Fix map on dimension.

上级 5ddb32ef
......@@ -66,7 +66,7 @@ var MapSeries = SeriesModel.extend({
// Shallow clone
// option = zrUtil.extend({}, option);
option.data = geoCreator.getFilledRegions(option.data, mapName, option.nameMap);
// option.data = geoCreator.getFilledRegions(option.data, mapName, option.nameMap);
// return option;
},
......
......@@ -10,6 +10,7 @@ import DataDiffer from './DataDiffer';
import Source from './Source';
import {defaultDimValueGetters, DefaultDataProvider} from './helper/dataProvider';
import {summarizeDimensions} from './helper/dimensionHelper';
import OrdinalMeta from './OrdinalMeta';
var isObject = zrUtil.isObject;
......@@ -103,6 +104,7 @@ var List = function (dimensions, hostModel) {
dimensionInfo.coordDimIndex = 0;
}
}
dimensionInfo.otherDims = dimensionInfo.otherDims || {};
dimensionNames.push(dimensionName);
dimensionInfos[dimensionName] = dimensionInfo;
......@@ -522,9 +524,13 @@ listProto._getNameFromStore = function (rawIndex) {
var chunkOffset = rawIndex % chunkSize;
var dim = this.dimensions[nameDimIdx];
var ordinalMeta = this._dimensionInfos[dim].ordinalMeta;
return ordinalMeta
? ordinalMeta.categories[rawIndex]
: this._storage[dim][chunkIndex][chunkOffset];
if (ordinalMeta) {
return ordinalMeta.categories[rawIndex];
}
else {
var chunk = this._storage[dim][chunkIndex];
return chunk && chunk[chunkOffset];
}
}
};
......
......@@ -5,7 +5,7 @@ import {createHashMap, isObject, map} from 'zrender/src/core/util';
* @param {Object} [opt]
* @param {Object} [opt.categories=[]]
* @param {Object} [opt.needCollect=false]
* @param {Object} [opt.preventDeduplication=false]
* @param {Object} [opt.deduplication=false]
*/
function OrdinalMeta(opt) {
......@@ -25,7 +25,7 @@ function OrdinalMeta(opt) {
* @private
* @type {boolean}
*/
this._preventDeduplication = opt.preventDeduplication;
this._deduplication = opt.deduplication;
/**
* @private
......@@ -46,7 +46,8 @@ OrdinalMeta.createByAxisModel = function (axisModel) {
return new OrdinalMeta({
categories: categories,
needCollect: !categories,
preventDeduplication: option.dedplication === false
// deduplication is default in axis.
deduplication: option.dedplication !== false
});
};
......@@ -76,7 +77,7 @@ proto.parseAndCollect = function (category) {
// (set axis.deduplication = false), because echarts do not know whether
// the values in the category dimension has duplication (consider the
// parallel-aqi example)
if (needCollect && this._preventDeduplication) {
if (needCollect && !this._deduplication) {
index = this.categories.length;
this.categories[index] = category;
return index;
......@@ -99,7 +100,7 @@ proto.parseAndCollect = function (category) {
return index;
};
// Do not create map until needed.
// Consider big data, do not create map until needed.
function getOrCreateMap(ordinalMeta) {
return ordinalMeta._map || (
ordinalMeta._map = createHashMap(ordinalMeta.categories)
......
......@@ -294,7 +294,8 @@ function objectRowsCollectDimensions(data) {
}
// ??? TODO merge to completedimensions, where also has
// default encode making logic.
// default encode making logic. And the default rule
// should depends on series? consider 'map'.
function makeDefaultEncode(
seriesModel, datasetModel, data, sourceFormat, seriesLayoutBy, completeResult
) {
......@@ -306,17 +307,25 @@ function makeDefaultEncode(
var encodeSeriesName = [];
var seriesType = seriesModel.subType;
// ??? TODO refactor: provide by series itself.
// Consider the case: 'map' series is based on geo coordSys,
// 'graph', 'heatmap' can be based on cartesian. But can not
// give default rule simply here.
var nSeriesMap = createHashMap(['pie', 'map', 'funnel']);
var cSeriesMap = createHashMap([
'line', 'bar', 'pictorialBar', 'scatter', 'effectScatter', 'candlestick', 'boxplot'
]);
// Usually in this case series will use the first data
// dimension as the "value" dimension, or other default
// processes respectively.
if (coordSysDefine) {
if (coordSysDefine && cSeriesMap.get(seriesType) != null) {
var ecModel = seriesModel.ecModel;
var datasetMap = inner(ecModel).datasetMap;
var key = datasetModel.uid + '_' + seriesLayoutBy;
var datasetRecord = datasetMap.get(key)
|| datasetMap.set(key, {categoryWayDim: 1, valueWayDim: 0});
// ??? TODO refactor: provide by series itself.
each(coordSysDefine.coordSysDims, function (coordDim) {
// In value way.
if (coordSysDefine.firstCategoryDimIndex == null) {
......@@ -342,7 +351,7 @@ function makeDefaultEncode(
}
// ??? TODO refactor: provide by series itself.
// [{name: ..., value: ...}, ...] like:
else if (seriesType === 'pie' || seriesType === 'map' || seriesType === 'funnel') {
else if (nSeriesMap.get(seriesType) != null) {
// Find the first not ordinal. (5 is an experience value)
var firstNotOrdinal;
for (var i = 0; i < 5 && firstNotOrdinal == null; i++) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册