Skip to content

feat(react-charting): Support marker shapes for scatter chart #34656

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

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

srmukher
Copy link
Contributor

@srmukher srmukher commented Jun 16, 2025

In Fluent chart:
image

In Plotly:
image

@srmukher srmukher requested a review from a team as a code owner June 16, 2025 15:14
@srmukher srmukher changed the title Users/srmukher/scatter marker shapes feat(react-charting): Support marker shapes for scatter chart Jun 16, 2025
Copy link

github-actions bot commented Jun 16, 2025

📊 Bundle size report

✅ No changes found

height={14}
viewBox={'-1 -1 14 14'}
{...getSecureProps(svgProps)}
transform={`rotate(${shape === Points[Points.diamond] ? 45 : shape === Points[Points.pyramid] ? 180 : 0}, 0, 0)`}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rotate(${shape === Points[Points.diamond] ? 45 : shape === Points[Points.pyramid] ? 180 : 0}, 0, 0)

this is not needed anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, since we have the exact shapes this transform was changing the legend shape

return '-1 -1 14 14';
}
// For plotly-based shapes, use centered viewBox
return '-7 -7 14 14';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'-7 -7 14 14';

why are you changing viewBox for existing shapes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because the plotly shape paths are centrally aligned and thus the view box had to be changed. otherwise the legend container was showing incomplete shapes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the margin and alignment for both old shapres and new shapes same. Other than dottedLine and pyramid, all are plotly provided shapes? What happened to the existing 8 shapes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes I have updated all others as they were existing in plotly shapes.

@AtishayMsft
Copy link
Contributor

Legend shapes have a special behavior of showing only the border on deselection and filling the entire shape on selection. Do your new shapes have this functionality.

@srmukher srmukher force-pushed the users/srmukher/scatter_marker_shapes branch from af6119e to 81a8169 Compare June 17, 2025 14:13
@srmukher
Copy link
Contributor Author

Legend shapes have a special behavior of showing only the border on deselection and filling the entire shape on selection. Do your new shapes have this functionality.

yes
image

@srmukher srmukher force-pushed the users/srmukher/scatter_marker_shapes branch from c588762 to 55d24dc Compare June 18, 2025 08:39
@AtishayMsft
Copy link
Contributor

what is the size bump for this PR

@srmukher srmukher force-pushed the users/srmukher/scatter_marker_shapes branch from 3760311 to 6016492 Compare June 18, 2025 09:45
@srmukher
Copy link
Contributor Author

srmukher commented Jun 18, 2025

what is the size bump for this PR

< 1 kB

image

Copy link

Pull request demo site: URL

@@ -950,7 +959,7 @@ export interface ILegend {
nativeButtonProps?: React_2.ButtonHTMLAttributes<HTMLButtonElement>;
onMouseOutAction?: (isLegendFocused?: boolean) => void;
opacity?: number;
shape?: LegendShape;
shape?: DataPointShape;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DataPointShape

we cannot change existing interface. It needs to be backward compatible. It can be LegendShape | DataPointShape

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

'2.26l-2.26,2.26l2.26,2.26Z',
// Additional shapes
star: 'M1.26,-1.73H5.33L2.03,0.66L3.29,4.53L0,2.14L-3.29,4.53L-2.03,0.66L-5.33,-1.73H-1.26L0,-5.6Z',
hexagram:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are all shapes now starting from viewpoint 0,0 to 14,14

Copy link
Contributor Author

@srmukher srmukher Jun 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no its '-7 -7 14 14'; means the SVG's coordinate system goes from -7 to +7 on both axes, with (0,0) at the center. The previous shapes were not centrally aligned thats why on hover, the line indicating the position was also distorted, starting from left. Now all shapes are centrally aligned.

Shapes Before:
image

Shapes now:
image

// Warning: (ae-forgotten-export) The symbol "CustomPoints" needs to be exported by the entry point index.d.ts
//
// @public
export type LegendShape = 'default' | 'triangle' | keyof typeof Points | keyof typeof CustomPoints;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LegendShape

where did the type definition of LegendShape go

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type definition was still there in legends.types but the export was overriden in index.ts. Fixed.

@@ -15,9 +15,9 @@ export type {
ILegendsProps,
ILegendsStyles,
IShapeProps,
LegendShape,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why stopped exporting LegendShape

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was overriden, fixed.

height: number;
}

export class ScatterChartShapesExample extends React.Component<{}, IScatterChartShapesState> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add few new shapes to the existing Legends shape example. Want to see how old and new shapes come side by side

shape={legend.shape as LegendShape}
shape={
String(legend.shape)?.includes('open')
? (String(legend.shape).replace('open', '') as DataPointShape)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This open tolowercase logic should be internal to shape. Not part of legends class.

@AtishayMsft
Copy link
Contributor

There are failures in the playwright report https://github.com/microsoft/fluentui-charting-contrib/actions/runs/15779003024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants