Skip to content

Commit

Permalink
fix(axis): unexpected radius in polar (#4850)
Browse files Browse the repository at this point in the history
  • Loading branch information
pearmini authored and hustcc committed Mar 29, 2023
1 parent c44c222 commit 5d97254
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 1 deletion.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions __tests__/plots/static/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,4 @@ export { soldIntervalCustomShape } from './sold-interval-custom-shape';
export { gaugeDefault } from './gauge-default';
export { gaugeCustomColor } from './gauge-custom-color';
export { gaugeCustomShape } from './gauge-custom-shape';
export { scoreByItemAreaRadarSize } from './score-by-item-area-radar-size';
40 changes: 40 additions & 0 deletions __tests__/plots/static/score-by-item-area-radar-size.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { G2Spec } from '../../../src';
import { scoreByItem } from '../../data/score-by-item';

export function scoreByItemAreaRadarSize(): G2Spec {
return {
type: 'view',
data: scoreByItem,
width: 400,
height: 600,
coordinate: { type: 'polar' },
axis: {
x: { grid: true },
y: {
zIndex: 1,
title: false,
direction: 'center',
style: {
gridStrokeWidth: 10,
},
},
},
scale: {
x: { padding: 0.5, align: 0 },
y: { tickCount: 5, domainMax: 80 },
},
legend: { color: { layout: { justifyContent: 'flex-start' } } },
children: [
{
type: 'area',
encode: { x: 'item', y: 'score', color: 'type' },
style: { fillOpacity: 0.5 },
},
{
type: 'line',
encode: { x: 'item', y: 'score', color: 'type' },
style: { lineWidth: 2 },
},
],
};
}
2 changes: 1 addition & 1 deletion src/component/axis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ function inferAxisLinearOverrideStyle(
const [cx, cy] = coordinate.getCenter();
const [innerRadius, outerRadius] = radiusOf(coordinate);
const [startAngle, endAngle] = angleOf(coordinate);
const r = height / 2;
const r = Math.min(width, height) / 2;

const innerR = innerRadius * r;
const outerR = outerRadius * r;
Expand Down

0 comments on commit 5d97254

Please sign in to comment.