Skip to content

Commit

Permalink
refactor(geo): change option name to echartsStyle and enable more s…
Browse files Browse the repository at this point in the history
…tyle options
  • Loading branch information
plainheart committed Dec 5, 2024
1 parent cdb0ebc commit 8f39773
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 42 deletions.
10 changes: 3 additions & 7 deletions src/component/helper/MapDraw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,13 +302,9 @@ class MapDraw {
? mapOrGeoModel.getRegionModel(regionName)
: (data ? data.getItemModel(dataIdx) as Model<MapDataItemOption> : null);

// allow specified itemStyle in GeoJSON data
const regionItemStyle = region.properties && region.properties.itemStyle;
if (regionItemStyle) {
const regionModelOption = regionModel.option;
const modelItemStyle = regionModelOption.itemStyle || (regionModelOption.itemStyle = {});
modelItemStyle && zrUtil.defaults(modelItemStyle, regionItemStyle);
}
// allow specified echarts style in GeoJSON data
const specifiedRegionStyle = region.properties && region.properties.echartsStyle;
specifiedRegionStyle && zrUtil.merge(regionModel.option, specifiedRegionStyle);

regionsInfoByName.set(regionName, { dataIdx, regionModel });
}
Expand Down
4 changes: 2 additions & 2 deletions src/coord/geo/Region.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { GeoJSON, GeoProjection, GeoSVGGraphicRoot } from './geoTypes';
import * as matrix from 'zrender/src/core/matrix';
import type Element from 'zrender/src/Element';
import { each } from 'zrender/src/core/util';
import type { GeoItemStyleOption } from './GeoModel';
import type { RegoinOption } from './GeoModel';

const TMP_TRANSFORM = [] as number[];

Expand Down Expand Up @@ -137,7 +137,7 @@ export class GeoJSONRegion extends Region {

// Injected outside.
properties: GeoJSON['features'][0]['properties'] & {
itemStyle?: GeoItemStyleOption
echartsStyle?: Omit<RegoinOption, 'name' | 'selected'>
};

constructor(
Expand Down
114 changes: 81 additions & 33 deletions test/geo-map.html

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

0 comments on commit 8f39773

Please sign in to comment.