提交 48a625b8 编写于 作者: L lang

dimension config can be ordinal number

上级 6c5b7f2b
......@@ -259,8 +259,7 @@ define(function(require) {
getDataDimension: function (list) {
var optDim = this.option.dimension;
return optDim != null
? optDim
: list.dimensions[list.dimensions.length - 1];
? optDim : list.dimensions.length - 1;
},
/**
......
......@@ -9,7 +9,6 @@ define(function(require) {
'use strict';
var zrUtil = require('zrender/core/util');
var Model = require('../model/Model');
/**
* @alias module:echarts/data/Graph
......@@ -285,7 +284,7 @@ define(function(require) {
edges[i].dataIndex = -1;
}
for (var i = 0, len = edgeData.count(); i < len; i++) {
edges[edgeData.getRawIndex(i)].dataIndex = i;
edges[edgeData.getRawIndex(i)].dataIndex = i;
}
};
......@@ -437,7 +436,8 @@ define(function(require) {
* @return {number}
*/
getValue: function (dimension) {
return this[hostName][dataName].get(dimension || 'value', this.dataIndex);
var data = this[hostName][dataName];
return data.get(data.getDimension(dimension || 'value'), this.dataIndex);
},
/**
......
......@@ -46,6 +46,7 @@ define(function (require) {
* @alias module:echarts/data/List
*
* @param {Array.<string>} dimensions
* Dimensions should be concrete names like x, y, z, lng, lat, angle, radius
* @param {module:echarts/model/Model} hostModel
*/
var List = function (dimensions, hostModel) {
......@@ -171,11 +172,26 @@ define(function (require) {
listProto.type = 'list';
/**
* Get dimension name
* @param {string|number} dim
* Dimension can be concrete names like x, y, z, lng, lat, angle, radius
* Or a ordinal number. For example getDimensionInfo(0) will return 'x' or 'lng' or 'radius'
*/
listProto.getDimension = function (dim) {
if (!isNaN(dim)) {
dim = this.dimensions[dim] || dim;
}
return dim;
};
/**
* Get type and stackable info of particular dimension
* @param {string|number} dim
* Dimension can be concrete names like x, y, z, lng, lat, angle, radius
* Or a ordinal number. For example getDimensionInfo(0) will return 'x' or 'lng' or 'radius'
*/
listProto.getDimensionInfo = function (dim) {
return this._dimensionInfos[dim];
return this._dimensionInfos[this.getDimension(dim)];
};
/**
......@@ -324,7 +340,7 @@ define(function (require) {
/**
* Get value
* @param {string} dim
* @param {string} dim Dim must be concrete name.
* @param {number} idx
* @param {boolean} stack
* @return {number}
......@@ -595,7 +611,9 @@ define(function (require) {
dimensions = [];
}
dimensions = normalizeDimensions(dimensions);
dimensions = zrUtil.map(
normalizeDimensions(dimensions), this.getDimension, this
);
var value = [];
var dimSize = dimensions.length;
......@@ -637,7 +655,9 @@ define(function (require) {
dimensions = [];
}
dimensions = normalizeDimensions(dimensions);
dimensions = zrUtil.map(
normalizeDimensions(dimensions), this.getDimension, this
);
var newIndices = [];
var value = [];
......@@ -706,7 +726,9 @@ define(function (require) {
* @return {Array}
*/
listProto.map = function (dimensions, cb, stack, context) {
dimensions = normalizeDimensions(dimensions);
dimensions = zrUtil.map(
normalizeDimensions(dimensions), this.getDimension, this
);
var allDimensions = this.dimensions;
var list = new List(
......
......@@ -196,11 +196,12 @@ define(function(require) {
},
/**
* @param {string=} [dimension='value'] Default 'value'. can be 'dim1', 'dim2', ...
* @param {string=} [dimension='value'] Default 'value'. can be 0, 1, 2, 3
* @return {number} Value.
*/
getValue: function (dimension) {
return this.hostTree.data.get(dimension || 'value', this.dataIndex);
var data = this.hostTree.data;
return data.get(data.getDimension(dimension || 'value'), this.dataIndex);
},
/**
......
......@@ -9,9 +9,10 @@ define(function (require) {
var value0 = retrieveValue(data[0]);
var dimSize = zrUtil.isArray(value0) && value0.length || 1;
defaultNames = defaultNames || [];
for (var i = 0; i < dimSize; i++) {
if (!dimensions[i]) {
var name = defaultNames && defaultNames[i] || ('dim' + i);
var name = defaultNames[i] || ('extra' + (i - defaultNames.length));
dimensions[i] = guessOrdinal(data, i)
? {type: 'ordinal', name: name}
: name;
......
......@@ -170,7 +170,7 @@
{
x: 'right',
y: 'bottom',
dimension: 'dim6',
dimension: 6,
min: 0,
max: 50,
itemHeight: 130,
......
......@@ -98,7 +98,7 @@
x: 'right',
// selectedMode: 'single',
selectedMode: 'multiple',
dimension: 'dim3',
dimension: 3,
backgroundColor: '#eee',
inRange: 'symbol'
}
......
......@@ -119,7 +119,7 @@
x: 'right',
// selectedMode: 'single',
selectedMode: 'multiple',
dimension: 'dim3',
dimension: 3,
text: ['', ''],
backgroundColor: '#eee',
visualSelected: {
......@@ -134,7 +134,7 @@
orient: 'horizontal',
// selectedMode: 'single',
selectedMode: 'multiple',
dimension: 'dim3',
dimension: 3,
text: ['', ''],
backgroundColor: '#eee',
visualSelected: {
......@@ -148,7 +148,7 @@
orient: 'horizontal',
// selectedMode: 'single',
selectedMode: 'multiple',
dimension: 'dim3',
dimension: 3,
text: ['', ''],
backgroundColor: '#eee',
visualSelected: {
......@@ -161,7 +161,7 @@
orient: 'horizontal',
// selectedMode: 'single',
selectedMode: 'multiple',
dimension: 'dim3',
dimension: 3,
text: ['', ''],
backgroundColor: '#eee',
visualSelected: {
......
......@@ -117,7 +117,7 @@
x: 'right',
// selectedMode: 'single',
selectedMode: 'multiple',
dimension: 'dim3',
dimension: 3,
backgroundColor: '#eee',
visualSelected: {
type: 'symbol',
......@@ -131,7 +131,7 @@
orient: 'horizontal',
// selectedMode: 'single',
selectedMode: 'multiple',
dimension: 'dim3',
dimension: 3,
backgroundColor: '#eee',
visualSelected: {
type: 'colorSaturation'
......@@ -144,7 +144,7 @@
orient: 'horizontal',
// selectedMode: 'single',
selectedMode: 'multiple',
dimension: 'dim3',
dimension: 3,
backgroundColor: '#eee',
visualSelected: {
type: 'colorLightness'
......@@ -156,7 +156,7 @@
orient: 'horizontal',
// selectedMode: 'single',
selectedMode: 'multiple',
dimension: 'dim3',
dimension: 3,
backgroundColor: '#eee',
visualSelected: {
type: 'colorAlpha'
......
......@@ -124,7 +124,7 @@
calculable: true,
// selectedMode: 'single',
selectedMode: 'multiple',
dimension: 'dim3',
dimension: 3,
backgroundColor: '#eee',
inRange: {
color: ['red', 'pink']
......@@ -140,7 +140,7 @@
// selectedMode: 'single',
selectedMode: 'multiple',
inverse: true,
dimension: 'dim3',
dimension: 3,
backgroundColor: '#eee',
inRange: 'colorSaturation'
},
......@@ -153,7 +153,7 @@
calculable: true,
// selectedMode: 'single',
selectedMode: 'multiple',
dimension: 'dim3',
dimension: 3,
backgroundColor: '#eee',
inRange: 'colorLightness'
},
......@@ -165,7 +165,7 @@
calculable: true,
// selectedMode: 'single',
selectedMode: 'multiple',
dimension: 'dim3',
dimension: 3,
backgroundColor: '#eee',
inRange: 'colorAlpha'
},
......@@ -178,7 +178,7 @@
calculable: true,
// selectedMode: 'single',
selectedMode: 'multiple',
dimension: 'dim3',
dimension: 3,
backgroundColor: '#eee',
inRange: 'colorAlpha'
}
......
......@@ -121,7 +121,7 @@
calculable: true,
// selectedMode: 'single',
selectedMode: 'multiple',
dimension: 'dim3',
dimension: 3,
backgroundColor: '#eee',
inRange: {
color: ['red', 'pink']
......@@ -136,7 +136,7 @@
// selectedMode: 'single',
selectedMode: 'multiple',
inverse: true,
dimension: 'dim3',
dimension: 3,
backgroundColor: '#eee',
inRange: 'colorSaturation'
},
......@@ -148,7 +148,7 @@
calculable: true,
// selectedMode: 'single',
selectedMode: 'multiple',
dimension: 'dim3',
dimension: 3,
backgroundColor: '#eee',
inRange: 'colorLightness'
},
......@@ -159,7 +159,7 @@
calculable: true,
// selectedMode: 'single',
selectedMode: 'multiple',
dimension: 'dim3',
dimension: 3,
backgroundColor: '#eee',
inRange: 'colorAlpha'
},
......@@ -171,7 +171,7 @@
calculable: true,
// selectedMode: 'single',
selectedMode: 'multiple',
dimension: 'dim3',
dimension: 3,
backgroundColor: '#eee',
inRange: 'colorAlpha'
}
......
......@@ -94,8 +94,8 @@
tooltip : {
trigger: 'axis',
formatter: function(params) {
return params.name + '<br/>'
+ params.seriesName + ' : ' + params.value + ' (m^3/s)<br/>';
return params[0].name + '<br/>'
+ params[0].seriesName + ' : ' + params[0].value + ' (m^3/s)<br/>';
}
},
legend: {
......
......@@ -36,23 +36,10 @@
var days = ['Saturday', 'Friday', 'Thursday',
'Wednesday', 'Tuesday', 'Monday', 'Sunday'];
var usedMap = {};
var data = [];
for (var i = 0; i < 120; i++) {
do {
var x = Math.round(Math.random() * (hours.length - 1));
var y = Math.round(Math.random() * (days.length - 1));
var key = y * 100 + x;
} while(usedMap[key]);
usedMap[key] = true;
data.push([
x, y, Math.random() + 0.1
]);
}
var data = [[0,0,5],[0,1,1],[0,2,0],[0,3,0],[0,4,0],[0,5,0],[0,6,0],[0,7,0],[0,8,0],[0,9,0],[0,10,0],[0,11,2],[0,12,4],[0,13,1],[0,14,1],[0,15,3],[0,16,4],[0,17,6],[0,18,4],[0,19,4],[0,20,3],[0,21,3],[0,22,2],[0,23,5],[1,0,7],[1,1,0],[1,2,0],[1,3,0],[1,4,0],[1,5,0],[1,6,0],[1,7,0],[1,8,0],[1,9,0],[1,10,5],[1,11,2],[1,12,2],[1,13,6],[1,14,9],[1,15,11],[1,16,6],[1,17,7],[1,18,8],[1,19,12],[1,20,5],[1,21,5],[1,22,7],[1,23,2],[2,0,1],[2,1,1],[2,2,0],[2,3,0],[2,4,0],[2,5,0],[2,6,0],[2,7,0],[2,8,0],[2,9,0],[2,10,3],[2,11,2],[2,12,1],[2,13,9],[2,14,8],[2,15,10],[2,16,6],[2,17,5],[2,18,5],[2,19,5],[2,20,7],[2,21,4],[2,22,2],[2,23,4],[3,0,7],[3,1,3],[3,2,0],[3,3,0],[3,4,0],[3,5,0],[3,6,0],[3,7,0],[3,8,1],[3,9,0],[3,10,5],[3,11,4],[3,12,7],[3,13,14],[3,14,13],[3,15,12],[3,16,9],[3,17,5],[3,18,5],[3,19,10],[3,20,6],[3,21,4],[3,22,4],[3,23,1],[4,0,1],[4,1,3],[4,2,0],[4,3,0],[4,4,0],[4,5,1],[4,6,0],[4,7,0],[4,8,0],[4,9,2],[4,10,4],[4,11,4],[4,12,2],[4,13,4],[4,14,4],[4,15,14],[4,16,12],[4,17,1],[4,18,8],[4,19,5],[4,20,3],[4,21,7],[4,22,3],[4,23,0],[5,0,2],[5,1,1],[5,2,0],[5,3,3],[5,4,0],[5,5,0],[5,6,0],[5,7,0],[5,8,2],[5,9,0],[5,10,4],[5,11,1],[5,12,5],[5,13,10],[5,14,5],[5,15,7],[5,16,11],[5,17,6],[5,18,0],[5,19,5],[5,20,3],[5,21,4],[5,22,2],[5,23,0],[6,0,1],[6,1,0],[6,2,0],[6,3,0],[6,4,0],[6,5,0],[6,6,0],[6,7,0],[6,8,0],[6,9,0],[6,10,1],[6,11,0],[6,12,2],[6,13,1],[6,14,3],[6,15,4],[6,16,0],[6,17,0],[6,18,0],[6,19,0],[6,20,1],[6,21,2],[6,22,2],[6,23,6]];
data = data.map(function (item) {
return [item[1], item[0], item[2]];
});
chart.setOption({
legend: {
......@@ -61,6 +48,7 @@
polar: {},
tooltip: {
},
animation: false,
angleAxis: {
type: 'category',
data: hours,
......@@ -72,7 +60,6 @@
type: 'dashed'
}
},
startAngle: 0,
axisLine: {
show: false
}
......@@ -97,7 +84,7 @@
}
},
symbolSize: function (val) {
return val[2] * 20;
return val[2] * 2;
},
data: data
}]
......
......@@ -78,9 +78,9 @@
borderColor: '#777',
borderWidth: 1,
formatter: function (obj) {
var value = obj[0].value;
var value = obj.value;
return '<div style="border-bottom: 1px solid rgba(255,255,255,.3); font-size: 18px;padding-bottom: 7px;margin-bottom: 7px">'
+ obj[0].seriesName + ' ' + value[0] + '日:'
+ obj.seriesName + ' ' + value[0] + '日:'
+ value[7]
+ '</div>'
+ schema[1].text + '' + value[1] + '<br>'
......@@ -136,13 +136,13 @@
textStyle: {
color: '#fff'
}
},
}
},
dataRange: [
{
x: 'right',
y: 'top',
dimension: 'dim7',
dimension: 7,
categories: ['', '', '轻度污染', '中度污染', '重度污染', '严重污染'],
calculable: true,
precision: 0.1,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册