Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(pie): support specifying coordinate system for pie series. #17132

Merged
merged 2 commits into from
Aug 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions extension-src/bmap/BMapCoordSys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ function BMapCoordSys(bmap, api) {
this._projection = new BMap.MercatorProjection();
}

BMapCoordSys.prototype.type = 'bmap';

BMapCoordSys.prototype.dimensions = ['lng', 'lat'];

BMapCoordSys.prototype.setZoom = function (zoom) {
Expand Down Expand Up @@ -107,6 +109,15 @@ BMapCoordSys.prototype.prepareCustoms = function () {
};
};

BMapCoordSys.prototype.convertToPixel = function (ecModel, finder, value) {
// here we ignore finder as only one bmap component is allowed
return this.dataToPoint(value);
};

BMapCoordSys.prototype.convertFromPixel = function (ecModel, finder, value) {
return this.pointToData(value);
};

function dataToCoordSize(dataSize, dataItem) {
dataItem = dataItem || [0, 0];
return zrUtil.map([0, 1], function (dimIdx) {
Expand Down Expand Up @@ -229,6 +240,9 @@ BMapCoordSys.create = function (ecModel, api) {
seriesModel.coordinateSystem = bmapCoordSys;
}
});

// return created coordinate systems
return bmapCoordSys && [bmapCoordSys];
};

export default BMapCoordSys;
17 changes: 15 additions & 2 deletions src/chart/pie/pieLayout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,23 @@ export function getBasicPieLayout(seriesModel: PieSeriesModel, api: ExtensionAPI
const width = parsePercent(viewRect.width, api.getWidth());
const height = parsePercent(viewRect.height, api.getHeight());
const size = Math.min(width, height);
const cx = parsePercent(center[0], width) + viewRect.x;
const cy = parsePercent(center[1], height) + viewRect.y;
const r0 = parsePercent(radius[0], size / 2);
const r = parsePercent(radius[1], size / 2);

let cx: number;
let cy: number;
const coordSys = seriesModel.coordinateSystem;
if (coordSys) {
// percentage is not allowed when coordinate system is specified
const point = coordSys.dataToPoint(center);
cx = point[0] || 0;
cy = point[1] || 0;
}
else {
cx = parsePercent(center[0], width) + viewRect.x;
cy = parsePercent(center[1], height) + viewRect.y;
}

return {
cx,
cy,
Expand Down
Loading