From 1be0144b3780006cde7072549c7985209abac510 Mon Sep 17 00:00:00 2001 From: sushuang Date: Sun, 14 Jan 2018 12:20:40 +0800 Subject: [PATCH] Fix parallels and candlestick. --- src/chart/helper/whiskerBoxCommon.js | 20 +- src/chart/parallel/ParallelView.js | 2 +- src/coord/parallel/Parallel.js | 5 +- src/data/helper/completeDimensions.js | 4 + test/dataset-charts.html | 308 ++++++++++++++++++++++++++ 5 files changed, 331 insertions(+), 8 deletions(-) diff --git a/src/chart/helper/whiskerBoxCommon.js b/src/chart/helper/whiskerBoxCommon.js index e2251e98e..f6b71fe9b 100644 --- a/src/chart/helper/whiskerBoxCommon.js +++ b/src/chart/helper/whiskerBoxCommon.js @@ -2,6 +2,7 @@ import createListSimply from '../helper/createListSimply'; import WhiskerBoxDraw from '../helper/WhiskerBoxDraw'; import * as zrUtil from 'zrender/src/core/util'; +import {getDimensionTypeByAxis} from '../../data/helper/dimensionHelper'; export var seriesModelMixin = { @@ -19,7 +20,7 @@ export var seriesModelMixin = { // needed to be specified by user. Otherwise, layout can be // judged by which axis is category. - var categories; + var ordinalMeta; var xAxisModel = ecModel.getComponent('xAxis', this.get('xAxisIndex')); var yAxisModel = ecModel.getComponent('yAxis', this.get('yAxisIndex')); @@ -32,12 +33,12 @@ export var seriesModelMixin = { if (xAxisType === 'category') { option.layout = 'horizontal'; - categories = xAxisModel.getCategories(); + ordinalMeta = xAxisModel.getOrdinalMeta(); addOrdinal = true; } else if (yAxisType === 'category') { option.layout = 'vertical'; - categories = yAxisModel.getCategories(); + ordinalMeta = yAxisModel.getOrdinalMeta(); addOrdinal = true; } else { @@ -48,8 +49,12 @@ export var seriesModelMixin = { var baseAxisDimIndex = option.layout === 'horizontal' ? 0 : 1; var baseAxisDim = this._baseAxisDim = coordDims[baseAxisDimIndex]; var otherAxisDim = coordDims[1 - baseAxisDimIndex]; + var axisModels = [xAxisModel, yAxisModel]; + var baseAxisType = axisModels[baseAxisDimIndex].get('type'); + var otherAxisType = axisModels[1 - baseAxisDimIndex].get('type'); var data = option.data; + // ??? FIXME make a stage to perform data transfrom. addOrdinal && zrUtil.each(data, function (item, index) { if (item.value && zrUtil.isArray(item.value)) { item.value.unshift(index); @@ -65,17 +70,20 @@ export var seriesModelMixin = { { coordDimensions: [{ name: baseAxisDim, + type: getDimensionTypeByAxis(baseAxisType), + ordinalMeta: ordinalMeta, otherDims: { - tooltip: false + tooltip: false, + itemName: 0 }, dimsDef: ['base'] }, { name: otherAxisDim, + type: getDimensionTypeByAxis(otherAxisType), dimsDef: defaultValueDimensions.slice() }], dimensionsCount: defaultValueDimensions.length + 1 - }, - categories && categories.slice() + } ); }, diff --git a/src/chart/parallel/ParallelView.js b/src/chart/parallel/ParallelView.js index 097a67f9c..398b0bfc9 100644 --- a/src/chart/parallel/ParallelView.js +++ b/src/chart/parallel/ParallelView.js @@ -164,7 +164,7 @@ function createLinePoints(data, dataIndex, dimensions, coordSys) { var points = []; for (var i = 0; i < dimensions.length; i++) { var dimName = dimensions[i]; - var value = data.get(dimName, dataIndex); + var value = data.get(data.mapDimension(dimName), dataIndex); if (!isEmptyValue(value, coordSys.getAxis(dimName).type)) { points.push(coordSys.dataToPoint(value, dimName)); } diff --git a/src/coord/parallel/Parallel.js b/src/coord/parallel/Parallel.js index b783404c9..52a19a7c0 100644 --- a/src/coord/parallel/Parallel.js +++ b/src/coord/parallel/Parallel.js @@ -339,11 +339,14 @@ Parallel.prototype = { */ eachActiveState: function (data, callback, context) { var dimensions = this.dimensions; + var dataDimensions = zrUtil.map(dimensions, function (axisDim) { + return data.mapDimension(axisDim); + }); var axesMap = this._axesMap; var hasActiveSet = this.hasAxisBrushed(); for (var i = 0, len = data.count(); i < len; i++) { - var values = data.getValues(dimensions, i); + var values = data.getValues(dataDimensions, i); var activeState; if (!hasActiveSet) { diff --git a/src/data/helper/completeDimensions.js b/src/data/helper/completeDimensions.js index b78d23016..94a8f1361 100644 --- a/src/data/helper/completeDimensions.js +++ b/src/data/helper/completeDimensions.js @@ -22,6 +22,7 @@ import {OTHER_DIMENSIONS} from './dimensionHelper'; * properties: 'name', 'type', 'displayName'. * `name` of each item provides default coord name. * [{dimsDef: [string...]}, ...] can be specified to give names. + * [{ordinalMeta}] can be specified. * @param {module:echarts/data/Source|Array|Object} source or data (for compatibal with pervious) * @param {Object} [opt] * @param {Array.} [opt.dimsDef] option.series.dimensions User defined dimensions @@ -115,7 +116,10 @@ function completeDimensions(sysDims, source, opt) { } else { coordDim = sysDimItem.name; + var ordinalMeta = sysDimItem.ordinalMeta; + sysDimItem.ordinalMeta = null; sysDimItem = clone(sysDimItem); + sysDimItem.ordinalMeta = ordinalMeta; // `coordDimIndex` should not be set directly. sysDimItemDimsDef = sysDimItem.dimsDef; sysDimItemOtherDims = sysDimItem.otherDims; diff --git a/test/dataset-charts.html b/test/dataset-charts.html index 67e0083c9..082798f99 100644 --- a/test/dataset-charts.html +++ b/test/dataset-charts.html @@ -4,6 +4,7 @@ + @@ -29,6 +30,10 @@
+
+
+
+
@@ -76,6 +81,27 @@ [55.2, 5312, 67.1, 3266, 69.2, 1354] ]; + var errorData = [ + ['name', 'Price', 'Prime cost', 'Prime cost min', 'Prime cost max', 'Price min', 'Price max'], + ['Blouse "Blue Viola"', 101.88, 99.75, 76.75, 116.75, 69.88, 119.88], + ['Dress "Daisy"', 155.8, 144.03, 126.03, 156.03, 129.8, 188.8], + ['Trousers "Cutesy Classic"', 203.25, 173.56, 151.56, 187.56, 183.25, 249.25], + ['Dress "Morning Dew"', 256, 120.5, 98.5, 136.5, 236, 279], + ['Turtleneck "Dark Chocolate"', 408.89, 294.75, 276.75, 316.75, 385.89, 427.89], + ['Jumper "Early Spring"', 427.36, 430.24, 407.24, 452.24, 399.36, 461.36], + ['Breeches "Summer Mood"', 356, 135.5, 123.5, 151.5, 333, 387], + ['Dress "Mauve Chamomile"', 406, 95.5, 73.5, 111.5, 366, 429], + ['Dress "Flying Tits"', 527.36, 503.24, 488.24, 525.24, 485.36, 551.36], + ['Dress "Singing Nightingales"', 587.36, 543.24, 518.24, 555.24, 559.36, 624.36], + ['Sundress "Cloudy weather"', 603.36, 407.24, 392.24, 419.24, 581.36, 627.36], + ['Sundress "East motives"', 633.36, 477.24, 445.24, 487.24, 594.36, 652.36], + ['Sweater "Cold morning"', 517.36, 437.24, 416.24, 454.24, 488.36, 565.36], + ['Trousers "Lavender Fields"', 443.36, 387.24, 370.24, 413.24, 412.36, 484.36], + ['Jumper "Coffee with Milk"', 543.36, 307.24, 288.24, 317.24, 509.36, 574.36], + ['Blouse "Blooming Cactus"', 790.36, 277.24, 254.24, 295.24, 764.36, 818.36], + ['Sweater "Fluffy Comfort"', 790.34, 678.34, 660.34, 690.34, 762.34, 824.34] + ]; + // No 北京 上海 江苏 var nameValueGeo0 = [ {name: '天津', value: 514}, @@ -401,5 +427,287 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file -- GitLab