File tree Expand file tree Collapse file tree 3 files changed +31
-0
lines changed
packages/charts/react-charts/library/src/components/DeclarativeChart Expand file tree Collapse file tree 3 files changed +31
-0
lines changed Original file line number Diff line number Diff line change 1+ {
2+ "type" : " patch" ,
3+ "comment" : " add support for scatter polar trace type" ,
4+ "packageName" : " @fluentui/react-charts" ,
5+ "email" : " anushgupta@microsoft.com" ,
6+ "dependentChangeType" : " patch"
7+ }
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ import {
2727 transformPlotlyJsonToGaugeProps ,
2828 transformPlotlyJsonToGVBCProps ,
2929 transformPlotlyJsonToVBCProps ,
30+ projectPolarToCartesian ,
3031} from './PlotlySchemaAdapter' ;
3132import { DonutChart } from '../DonutChart/index' ;
3233import { VerticalStackedBarChart } from '../VerticalStackedBarChart/index' ;
@@ -306,6 +307,11 @@ export const DeclarativeChart: React.FunctionComponent<DeclarativeChartProps> =
306307 case 'area' :
307308 case 'line' :
308309 case 'fallback' :
310+ case 'scatterpolar' :
311+ if ( chart . type === 'scatterpolar' ) {
312+ const cartesianProjection = projectPolarToCartesian ( plotlyInputWithValidData ) ;
313+ plotlyInputWithValidData . data = cartesianProjection . data ;
314+ }
309315 // Need recheck for area chart as we don't have ability to check for valid months in previous step
310316 const isAreaChart = plotlyInputWithValidData . data . some (
311317 ( series : PlotData ) => series . fill === 'tonexty' || series . fill === 'tozeroy' || ! ! series . stackgroup ,
Original file line number Diff line number Diff line change @@ -808,6 +808,24 @@ export const transformPlotlyJsonToGaugeProps = (
808808 } ;
809809} ;
810810
811+ export const projectPolarToCartesian = ( input : PlotlySchema ) : PlotlySchema => {
812+ const projection : PlotlySchema = { ...input } ;
813+ for ( let sindex = 0 ; sindex < input . data . length ; sindex ++ ) {
814+ const series : PlotData = input . data [ sindex ] as PlotData ;
815+ series . x = [ ] ;
816+ series . y = [ ] ;
817+ for ( let ptindex = 0 ; ptindex < series . r . length ; ptindex ++ ) {
818+ const thetaRad = ( ( series . theta [ ptindex ] as number ) * Math . PI ) / 180 ;
819+ const radius = series . r [ ptindex ] as number ;
820+ series . x [ ptindex ] = radius * Math . cos ( thetaRad ) ;
821+ series . y [ ptindex ] = radius * Math . sin ( thetaRad ) ;
822+ }
823+ projection . data [ sindex ] = series ;
824+ }
825+
826+ return projection ;
827+ } ;
828+
811829function isPlainObject ( obj : any ) {
812830 return (
813831 Object . prototype . toString . call ( obj ) === '[object Object]' &&
You can’t perform that action at this time.
0 commit comments