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

AG-12034 Corner radius fixes for sectors #1968

Draft
wants to merge 11 commits into
base: latest
Choose a base branch
from
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 @@ -825,12 +825,9 @@ export class DonutSeries extends PolarSeries<DonutNodeDatum, DonutSeriesProperti
sector.lineDashOffset = format.lineDashOffset;
sector.cornerRadius = format.cornerRadius;
sector.fillShadow = this.properties.shadow;
const inset = Math.max(
(this.properties.sectorSpacing + (format.stroke != null ? format.strokeWidth : 0)) / 2,
0
);
const inset = Math.max(this.properties.sectorSpacing, 0) / 2;
sector.inset = inset;
sector.lineJoin = this.properties.sectorSpacing >= 0 || inset > 0 ? 'miter' : 'round';
sector.lineJoin = inset >= 0 ? 'miter' : 'round';
};

this.itemSelection.each((node, datum, index) => updateSectorFn(node, datum, index, false));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -768,12 +768,9 @@ export class PieSeries extends PolarSeries<PieNodeDatum, PieSeriesProperties, Se
sector.lineDashOffset = format.lineDashOffset;
sector.cornerRadius = format.cornerRadius;
sector.fillShadow = this.properties.shadow;
const inset = Math.max(
(this.properties.sectorSpacing + (format.stroke != null ? format.strokeWidth : 0)) / 2,
0
);
sector.inset = inset;
sector.lineJoin = this.properties.sectorSpacing >= 0 || inset > 0 ? 'miter' : 'round';
const radialEdgeInset = Math.max(this.properties.sectorSpacing, 0) / 2;
sector.radialEdgeInset = radialEdgeInset;
sector.lineJoin = radialEdgeInset >= 0 ? 'miter' : 'round';
};

this.itemSelection.each((node, datum, index) => updateSectorFn(node, datum, index, false));
Expand Down
221 changes: 139 additions & 82 deletions packages/ag-charts-community/src/scene/shape/sector.ts

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ export class AngleCrossLine extends PolarCrossLine {

sector.centerX = 0;
sector.centerY = 0;
sector.strokeAlign = 'middle';
sector.innerRadius = axisInnerRadius;
sector.outerRadius = axisOuterRadius;
sector.startAngle = angles[0] - padding;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export class RadiusCrossLine extends PolarCrossLine {

sector.visible = true;

sector.strokeAlign = 'middle';
sector.startAngle = 0;
sector.endAngle = 2 * Math.PI;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,6 @@ export class ChordSeries extends FlowProportionSeries<
sector.strokeWidth = highlightStyle?.strokeWidth ?? format?.strokeWidth ?? strokeWidth;
sector.lineDash = highlightStyle?.lineDash ?? format?.lineDash ?? lineDash;
sector.lineDashOffset = highlightStyle?.lineDashOffset ?? format?.lineDashOffset ?? lineDashOffset;
sector.inset = sector.strokeWidth / 2;
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,6 @@ export class RadialBarSeries extends _ModuleSupport.PolarSeries<
node.lineDash = format?.lineDash ?? lineDash;
node.lineDashOffset = format?.lineDashOffset ?? lineDashOffset;
node.lineJoin = 'round';
node.inset = stroke != null ? (format?.strokeWidth ?? strokeWidth) / 2 : 0;
node.startInnerCornerRadius = datum.reversed ? format?.cornerRadius ?? cornerRadius : 0;
node.startOuterCornerRadius = datum.reversed ? format?.cornerRadius ?? cornerRadius : 0;
node.endInnerCornerRadius = datum.reversed ? 0 : format?.cornerRadius ?? cornerRadius;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -798,8 +798,7 @@ export class RadialGaugeSeries
sector.endOuterCornerRadius = endCornerRadius;
sector.endInnerCornerRadius = endCornerRadius;

sector.radialEdgeInset = (sectorSpacing + sector.strokeWidth) / 2;
sector.concentricEdgeInset = sector.strokeWidth / 2;
sector.radialEdgeInset = sectorSpacing / 2;

if (animationDisabled || sector.previousDatum == null) {
sector.setProperties(resetRadialGaugeSeriesResetSectorFunction(sector, datum));
Expand Down Expand Up @@ -841,8 +840,7 @@ export class RadialGaugeSeries
sector.endOuterCornerRadius = endCornerRadius;
sector.endInnerCornerRadius = endCornerRadius;

sector.radialEdgeInset = (sectorSpacing + sector.strokeWidth) / 2;
sector.concentricEdgeInset = sector.strokeWidth / 2;
sector.radialEdgeInset = sectorSpacing / 2;

sector.setProperties(resetRadialGaugeSeriesResetSectorFunction(sector, datum));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ export class SunburstSeries extends _ModuleSupport.HierarchySeries<
this.highlightGroup.translationX = width / 2;
this.highlightGroup.translationY = height / 2;

const baseInset = sectorSpacing * 0.5;
const inset = sectorSpacing * 0.5;
const radius = Math.min(width, height) / 2;
const radiusScale = radius / (maxDepth + 1);
const angleOffset = -Math.PI / 2;
Expand Down Expand Up @@ -244,7 +244,7 @@ export class SunburstSeries extends _ModuleSupport.HierarchySeries<
sector.outerRadius = (depth + 1) * radiusScale;
sector.startAngle = angleDatum.start + angleOffset;
sector.endAngle = angleDatum.end + angleOffset;
sector.inset = baseInset + strokeWidth * 0.5;
sector.inset = inset;
sector.cornerRadius = cornerRadius;
};

Expand All @@ -268,10 +268,10 @@ export class SunburstSeries extends _ModuleSupport.HierarchySeries<
return;
}

const innerRadius = depth * radiusScale + baseInset;
const outerRadius = (depth + 1) * radiusScale - baseInset;
const innerAngleOffset = innerRadius > baseInset ? baseInset / innerRadius : baseInset;
const outerAngleOffset = outerRadius > baseInset ? baseInset / outerRadius : baseInset;
const innerRadius = depth * radiusScale + inset;
const outerRadius = (depth + 1) * radiusScale - inset;
const innerAngleOffset = innerRadius > inset ? inset / innerRadius : inset;
const outerAngleOffset = outerRadius > inset ? inset / outerRadius : inset;
const innerStartAngle = angleData.start + innerAngleOffset;
const innerEndAngle = angleData.end + innerAngleOffset;
const deltaInnerAngle = innerEndAngle - innerStartAngle;
Expand Down