提交 f27f50eb 编写于 作者: S sushuang

Fix #7733 (has value defect)

上级 e7e3cfe2
......@@ -56,7 +56,7 @@ function getStackedOnPoints(coordSys, data, dataCoordInfo) {
for (var idx = 0, len = data.count(); idx < len; idx++) {
points.push(getStackedOnPoint(dataCoordInfo, coordSys, data, idx));
}
console.log(JSON.stringify(points));
return points;
}
......
......@@ -8,7 +8,7 @@ export var OTHER_DIMENSIONS = createHashMap([
export function summarizeDimensions(data) {
var summary = {};
var encode = summary.encode = {};
var coordDimMap = summary.coordDimMap = createHashMap();
var notExtraCoordDimMap = createHashMap();
var defaultedLabel = [];
each(data.dimensions, function (dimName) {
......@@ -25,14 +25,16 @@ export function summarizeDimensions(data) {
}
coordDimArr[dimItem.coordDimIndex] = dimName;
if (!dimItem.isExtraCoord && mayLabelDimType(dimItem.type)) {
// Use the last coord dim (and label friendly) as default label,
// because both show x, y on label is not look good, and usually
// y axis is more focusd conventionally.
defaultedLabel[0] = dimName;
}
if (!dimItem.isExtraCoord) {
notExtraCoordDimMap.set(coordDim, 1);
coordDimMap.set(coordDim, 1);
if (mayLabelDimType(dimItem.type)) {
// Use the last coord dim (and label friendly) as default label,
// because both show x, y on label is not look good, and usually
// y axis is more focusd conventionally.
defaultedLabel[0] = dimName;
}
}
}
OTHER_DIMENSIONS.each(function (v, otherDim) {
......@@ -49,12 +51,21 @@ export function summarizeDimensions(data) {
});
var dataDimsOnCoord = [];
// ??? FIXME extra coord should not be set in dataDimsOnCoord.
// Fix the case that radar axes.
coordDimMap.each(function (v, coordDim) {
dataDimsOnCoord = dataDimsOnCoord.concat(encode[coordDim]);
var encodeFirstDimNotExtra = {};
notExtraCoordDimMap.each(function (v, coordDim) {
var dimArr = encode[coordDim];
// ??? FIXME extra coord should not be set in dataDimsOnCoord.
// But should fix the case that radar axes: simplify the logic
// of `completeDimension`, remove `extraPrefix`.
encodeFirstDimNotExtra[coordDim] = dimArr[0];
// Not necessary to remove duplicate, because a data
// dim canot on more than one coordDim.
dataDimsOnCoord = dataDimsOnCoord.concat(dimArr);
});
summary.dataDimsOnCoord = dataDimsOnCoord;
summary.encodeFirstDimNotExtra = encodeFirstDimNotExtra;
var encodeLabel = encode.label;
// FIXME `encode.label` is not recommanded, because formatter can not be set
......@@ -72,18 +83,6 @@ export function summarizeDimensions(data) {
encode.defaultedLabel = defaultedLabel;
encode.defaultedTooltip = defaultedTooltip;
var encodeFirstDimNotExtra = summary.encodeFirstDimNotExtra = {};
each(encode, function (coordDimArr, coordDim) {
for (var i = 0; i < (coordDimArr || []).length; i++) {
var dim = coordDimArr[i];
var dimInfo = data.getDimensionInfo(dim);
if (dimInfo && !dimInfo.isExtraCoord) {
encodeFirstDimNotExtra[coordDim] = dim;
break;
}
}
});
return summary;
}
......
......@@ -30,6 +30,10 @@
<div id="empty-data"></div>
<div id="dynamic-category"></div>
<div id="dynamic-time"></div>
<div id="dimension-but-no-column1"></div>
<div id="dimension-but-no-column2"></div>
<div id="dimension-but-no-column3"></div>
......@@ -753,8 +757,6 @@
<script>
require([
'echarts'
......@@ -819,5 +821,132 @@
<script>
require([
'echarts'
], function (echarts) {
var option = {
legend: {},
tooltip: {},
dataset: {
dimensions: ['product', '2015', '2016', '2017'],
source: [
{product: 'Matcha Latte', '2015': 43.3, '2016': 85.8},
{product: 'Milk Tea', '2015': 83.1, '2016': 73.4},
{product: 'Cheese Cocoa', '2015': 86.4, '2016': 65.2},
{product: 'Walnut Brownie', '2015': 72.4, '2016': 53.9}
]
},
xAxis: {type: 'category'},
yAxis: {},
series: [
{type: 'bar'},
{type: 'bar'}
]
};
var chart = testHelper.create(echarts, 'dimension-but-no-column1', {
title: '[obejct array] No 2017, but chart should be rendered',
dataTable: option.dataset.source,
option: option,
info: option.dataset.dimensions,
infoKey: 'dimensions'
});
});
</script>
<script>
require([
'echarts'
], function (echarts) {
var option = {
legend: {},
tooltip: {},
dataset: {
dimensions: ['product', '2015', '2016', '2017'],
source: [
['Matcha Latte', 43.3, 85.8],
['Milk Tea', 83.1, 73.4],
['Cheese Cocoa', 86.4, 65.2],
['Walnut Brownie', 72.4, 53.9]
]
},
xAxis: {type: 'category'},
yAxis: {},
series: [
{type: 'bar'},
{type: 'bar'}
]
};
var chart = testHelper.create(echarts, 'dimension-but-no-column2', {
title: '[2d-array] No 2017, but chart should be rendered',
dataTable: option.dataset.source,
option: option,
info: option.dataset.dimensions,
infoKey: 'dimensions'
});
});
</script>
<script>
require([
'echarts'
], function (echarts) {
var option = {
legend: {},
tooltip: {},
dataset: {
dimensions: ['product', '2015', '2016', '2017'],
source: {
'product': ['Matcha Latte', 'Milk Tea', 'Cheese Cocoa', 'Walnut Brownie'],
'2015': [43.3, 83.1, 86.4, 72.4],
'2016': [85.8, 73.4, 65.2, 53.9]
}
},
xAxis: {type: 'category'},
yAxis: {},
series: [
{type: 'bar'},
{type: 'bar'}
]
};
var chart = testHelper.create(echarts, 'dimension-but-no-column3', {
title: '[key columns] No 2017, but chart should be rendered',
dataTable: option.dataset.source,
option: option,
info: option.dataset.dimensions,
infoKey: 'dimensions'
});
});
</script>
</body>
</html>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册