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

fix(polar): barWidth calculation when stack on multiple polars #9626 #9917

Merged
merged 1 commit into from
Feb 14, 2019
Merged
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
12 changes: 7 additions & 5 deletions src/layout/barPolar.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ function getSeriesStackId(seriesModel) {
|| '__ec_stack_' + seriesModel.seriesIndex;
}

function getAxisKey(axis) {
return axis.dim;
function getAxisKey(polar, axis) {
return axis.dim + polar.model.componentIndex;
}

/**
Expand Down Expand Up @@ -60,10 +60,11 @@ function barLayoutPolar(seriesType, ecModel, api) {
var data = seriesModel.getData();
var polar = seriesModel.coordinateSystem;
var baseAxis = polar.getBaseAxis();
var axisKey = getAxisKey(polar, baseAxis);

var stackId = getSeriesStackId(seriesModel);
var columnLayoutInfo
= barWidthAndOffset[getAxisKey(baseAxis)][stackId];
= barWidthAndOffset[axisKey][stackId];
var columnOffset = columnLayoutInfo.offset;
var columnWidth = columnLayoutInfo.width;
var valueAxis = polar.getOtherAxis(baseAxis);
Expand Down Expand Up @@ -185,13 +186,14 @@ function calRadialBar(barSeries, api) {
var polar = seriesModel.coordinateSystem;

var baseAxis = polar.getBaseAxis();
var axisKey = getAxisKey(polar, baseAxis);

var axisExtent = baseAxis.getExtent();
var bandWidth = baseAxis.type === 'category'
? baseAxis.getBandWidth()
: (Math.abs(axisExtent[1] - axisExtent[0]) / data.count());

var columnsOnAxis = columnsMap[getAxisKey(baseAxis)] || {
var columnsOnAxis = columnsMap[axisKey] || {
bandWidth: bandWidth,
remainedWidth: bandWidth,
autoWidthCount: 0,
Expand All @@ -200,7 +202,7 @@ function calRadialBar(barSeries, api) {
stacks: {}
};
var stacks = columnsOnAxis.stacks;
columnsMap[getAxisKey(baseAxis)] = columnsOnAxis;
columnsMap[axisKey] = columnsOnAxis;

var stackId = getSeriesStackId(seriesModel);

Expand Down