Skip to content

Commit

Permalink
Merge pull request #14243 from apache/feat-visualMap-itemSymbol
Browse files Browse the repository at this point in the history
fix(visualMap): use itemSymbol as default symbol type and fix #5719
  • Loading branch information
pissang authored Apr 7, 2021
2 parents 304685d + a95ff6a commit 98ee07d
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 11 deletions.
7 changes: 7 additions & 0 deletions src/component/visualMap/PiecewiseModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,13 @@ class PiecewiseModel extends VisualMapModel<PiecewiseVisualMapOption> {
// thisOption.selectedMode === 'multiple', default: all selected.
}

/**
* @public
*/
getItemSymbol(): string {
return this.get('itemSymbol');
}

/**
* @public
*/
Expand Down
15 changes: 12 additions & 3 deletions src/component/visualMap/VisualMapModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,13 @@ class VisualMapModel<Opts extends VisualMapOption = VisualMapOption> extends Com
);
}

/**
* @public
*/
getItemSymbol(): string {
return null;
}

/**
* @protected
* @return {Array.<number>} An array of series indices.
Expand Down Expand Up @@ -483,6 +490,8 @@ class VisualMapModel<Opts extends VisualMapOption = VisualMapOption> extends Com
const symbolSizeExists = (controller.inRange || {}).symbolSize
|| (controller.outOfRange || {}).symbolSize;
const inactiveColor = this.get('inactiveColor');
const itemSymbol = this.getItemSymbol();
const defaultSymbol = itemSymbol || 'roundRect';

each(this.stateList, function (state: VisualState) {

Expand All @@ -501,17 +510,17 @@ class VisualMapModel<Opts extends VisualMapOption = VisualMapOption> extends Com
if (visuals.symbol == null) {
visuals.symbol = symbolExists
&& zrUtil.clone(symbolExists)
|| (isCategory ? 'roundRect' : ['roundRect']);
|| (isCategory ? defaultSymbol : [defaultSymbol]);
}
if (visuals.symbolSize == null) {
visuals.symbolSize = symbolSizeExists
&& zrUtil.clone(symbolSizeExists)
|| (isCategory ? itemSize[0] : [itemSize[0], itemSize[0]]);
}

// Filter square and none.
// Filter none
visuals.symbol = mapVisual(visuals.symbol, function (symbol) {
return (symbol === 'none' || symbol === 'square') ? 'roundRect' : symbol;
return symbol === 'none' ? defaultSymbol : symbol;
});

// Normalize symbolSize
Expand Down
4 changes: 0 additions & 4 deletions src/component/visualMap/VisualMapView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import GlobalModel from '../../model/Global';
import ExtensionAPI from '../../core/ExtensionAPI';
import VisualMapModel from './VisualMapModel';
import { VisualOptionUnit, ColorString } from '../../util/types';
import PiecewiseModel from './PiecewiseModel';

type VisualState = VisualMapModel['stateList'][number];

Expand Down Expand Up @@ -117,9 +116,6 @@ class VisualMapView extends ComponentView {
const visualObj: {[key in typeof visualCluster]?: VisualOptionUnit[key]} = {};

// Default values.
if (visualCluster === 'symbol') {
visualObj.symbol = (visualMapModel as PiecewiseModel).get('itemSymbol');
}
if (visualCluster === 'color') {
const defaultColor = visualMapModel.get('contentColor');
visualObj.color = defaultColor as ColorString;
Expand Down
11 changes: 7 additions & 4 deletions test/visualMap-scatter-colorAndSymbol.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 98ee07d

Please sign in to comment.