Skip to content

Commit

Permalink
fix(partition): single slice wrong text positioning (#643)
Browse files Browse the repository at this point in the history
This commit fix the partition chart avoiding filling a single slice
if the inner radius is nonzero.

fix #637
  • Loading branch information
monfera authored and markov00 committed Apr 22, 2020
1 parent 3aa235e commit 6298d36
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ export function ringSectorConstruction(config: Config, innerRadius: Radius, ring
fillRectangleWidth,
fillRectangleHeight,
} = config;
const innerR =
(fillOutside ? ringSectorOuterRadius : ringSectorInnerRadius)(innerRadius, ringThickness)(ringSector) +
circlePadding * 2;
const radiusGetter = fillOutside ? ringSectorOuterRadius : ringSectorInnerRadius;
const geometricInnerRadius = radiusGetter(innerRadius, ringThickness)(ringSector);
const innerR = geometricInnerRadius + circlePadding * 2;
const outerR = Math.max(
innerR,
ringSectorOuterRadius(innerRadius, ringThickness)(ringSector) - circlePadding + (fillOutside ? radiusOutside : 0),
Expand All @@ -110,7 +110,7 @@ export function ringSectorConstruction(config: Config, innerRadius: Radius, ring
const sectorEndCircle = angleToCircline(midRadius, endAngle + radialPadding, 1);
const outerRadiusFromRectangleWidth = fillRectangleWidth / 2;
const outerRadiusFromRectanglHeight = fillRectangleHeight / 2;
const fullCircle = ringSector.x0 === 0 && ringSector.x1 === TAU;
const fullCircle = ringSector.x0 === 0 && ringSector.x1 === TAU && geometricInnerRadius === 0;
const sectorCirclines = [
...(fullCircle && innerRadius === 0 ? [] : [innerCircline]),
outerCircline,
Expand Down
4 changes: 2 additions & 2 deletions stories/sunburst/15_single_sunburst.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const example = () => (
},
{
groupByRollup: (d: Datum) => countryLookup[d.dest].continentCountry.substr(0, 2),
nodeLabel: (d: any) => regionLookup[d].regionName,
nodeLabel: (d: any) => regionLookup[d].regionName.replace(/\s/g, '\u00A0'),
shape: {
fillColor: (d: ShapeTreeNode) => {
return categoricalFillColor(colorBrewerCategoricalStark9, 0.5)(d.parent.sortIndex);
Expand All @@ -58,7 +58,7 @@ export const example = () => (
},
{
groupByRollup: (d: Datum) => d.dest,
nodeLabel: (d: any) => countryLookup[d].name,
nodeLabel: (d: any) => countryLookup[d].name.replace(/\s/g, '\u00A0'),
shape: {
fillColor: (d: ShapeTreeNode) => {
return categoricalFillColor(colorBrewerCategoricalStark9, 0.3)(d.parent.parent.sortIndex);
Expand Down

0 comments on commit 6298d36

Please sign in to comment.