-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Draft changes for a declarative chart using plotly json schema #33348
Draft
AtishayMsft
wants to merge
23
commits into
master
Choose a base branch
from
charting/declarativeCharts
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 21 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
f194a8f
Create declarative chart component
AtishayMsft 8902f85
Update data processing
AtishayMsft 99e2c23
Add examples for test schema
AtishayMsft 1c25e07
Fix vertical bar histogram schema
AtishayMsft 5f68f16
Update donut chart plotly adapter (#33337)
krkshitij d336150
Line chart plotly adapter (#33334)
srmukher c515b12
Add heatmap chart plotly adapter (#33343)
krkshitij 1cc9936
Add Sankey chart Plotly Adapter (#33345)
Anush2303 cfb35bf
Fix format
AtishayMsft 9fb2512
Add change file
AtishayMsft d262be4
Update name
AtishayMsft 3ccae08
Fix build
AtishayMsft 80076f4
Add declarative chart to docsite
AtishayMsft 6fa2476
Update tsconfig for examples
AtishayMsft 3d6b38d
Applying styles to horizontal bar chart with axis using plotly data (…
srmukher 54db5ea
Fix tslint
AtishayMsft bcd2da9
Add gauge chart plotly adapter and example (#33352)
krkshitij 45bd286
Merge branch 'charting/declarativeCharts' of https://github.com/micro…
AtishayMsft 40ae2ac
Change relative imports to absolute
AtishayMsft 4aba25e
Rename schema files to test
AtishayMsft 4f58b97
Allow deep imports
AtishayMsft 4f4f60f
Update schema files
AtishayMsft 71c1ed2
Update example path
AtishayMsft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
apps/public-docsite-resources/src/components/pages/Charting/DeclarativeChartPage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import * as React from 'react'; | ||
import { DemoPage } from '../../DemoPage'; | ||
|
||
import { DeclarativeChartPageProps } from '@fluentui/react-examples/lib/react-charting/DeclarativeChart/DeclarativeChart.doc'; | ||
|
||
export const DeclarativeChartPage = (props: { isHeaderVisible: boolean }) => ( | ||
<DemoPage | ||
jsonDocs={require('../../../../dist/api/react-charting/DeclarativeChart.page.json')} | ||
{...{ ...DeclarativeChartPageProps, ...props }} | ||
/> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
apps/public-docsite/src/pages/Controls/DeclarativeChartPage/DeclarativeChartPage.doc.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { TFabricPlatformPageProps } from '../../../interfaces/Platforms'; | ||
import { DeclarativeChartPageProps as ExternalProps } from '@fluentui/react-examples/lib/react-charting/DeclarativeChart/DeclarativeChart.doc'; | ||
|
||
export const DeclarativeChartPageProps: TFabricPlatformPageProps = { | ||
web: { | ||
...(ExternalProps as any), | ||
}, | ||
}; |
8 changes: 8 additions & 0 deletions
8
apps/public-docsite/src/pages/Controls/DeclarativeChartPage/DeclarativeChartPage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import * as React from 'react'; | ||
import { ControlsAreaPage, IControlsPageProps } from '../ControlsAreaPage'; | ||
import { DeclarativeChartPageProps } from './DeclarativeChartPage.doc'; | ||
|
||
export const DeclarativeChartPage: React.FunctionComponent<IControlsPageProps> = props => { | ||
const { platform } = props; | ||
return <ControlsAreaPage {...props} {...DeclarativeChartPageProps[platform!]} />; | ||
}; |
7 changes: 7 additions & 0 deletions
7
change/@fluentui-react-charting-1fd94ef3-bdd1-4473-b5cf-5a5f67f3a547.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "patch", | ||
"comment": "Create declarative chart component", | ||
"packageName": "@fluentui/react-charting", | ||
"email": "[email protected]", | ||
"dependentChangeType": "patch" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | |||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -119,6 +119,14 @@ export const DataVizPalette: { | ||||||||||||||||||||||||||||
highSuccess: string; | |||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🕵🏾♀️ visual regressions to review in the fluentuiv8 Visual Regression ReportCallout 6 screenshots
react-charting-VerticalBarChart 1 screenshots
|
|||||||||||||||||||||||||||||
}; | |||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||
// @public | |||||||||||||||||||||||||||||
export const DeclarativeChart: React_2.FunctionComponent<DeclarativeChartProps>; | |||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||
// @public | |||||||||||||||||||||||||||||
export interface DeclarativeChartProps extends React_2.RefAttributes<HTMLDivElement> { | |||||||||||||||||||||||||||||
chartSchema: any; | |||||||||||||||||||||||||||||
} | |||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||
// @public | |||||||||||||||||||||||||||||
export const DonutChart: React_2.FunctionComponent<IDonutChartProps>; | |||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './components/DeclarativeChart/DeclarativeChart'; |
79 changes: 79 additions & 0 deletions
79
packages/charts/react-charting/src/components/DeclarativeChart/DeclarativeChart.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* eslint-disable @typescript-eslint/naming-convention */ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
import * as React from 'react'; | ||
import { DonutChart } from '../DonutChart/index'; | ||
import { VerticalStackedBarChart } from '../VerticalStackedBarChart/index'; | ||
import { | ||
transformPlotlyJsonToDonutProps, | ||
transformPlotlyJsonToColumnProps, | ||
transformPlotlyJsonToScatterChartProps, | ||
transformPlotlyJsonToHorizontalBarWithAxisProps, | ||
isDateArray, | ||
isNumberArray, | ||
transformPlotlyJsonToHeatmapProps, | ||
transformPlotlyJsonToSankeyProps, | ||
transformPlotlyJsonToGaugeProps, | ||
} from './PlotlySchemaAdapter'; | ||
import { LineChart } from '../LineChart/index'; | ||
import { HorizontalBarChartWithAxis } from '../HorizontalBarChartWithAxis/index'; | ||
import { AreaChart } from '../AreaChart/index'; | ||
import { HeatMapChart } from '../HeatMapChart/index'; | ||
import { SankeyChart } from '../SankeyChart/SankeyChart'; | ||
import { GaugeChart } from '../GaugeChart/index'; | ||
|
||
/** | ||
* DeclarativeChart props. | ||
* {@docCategory DeclarativeChart} | ||
*/ | ||
export interface DeclarativeChartProps extends React.RefAttributes<HTMLDivElement> { | ||
/** | ||
* The schema representing the chart | ||
*/ | ||
chartSchema: any; | ||
} | ||
|
||
/** | ||
* DeclarativeChart component. | ||
* {@docCategory DeclarativeChart} | ||
*/ | ||
export const DeclarativeChart: React.FunctionComponent<DeclarativeChartProps> = React.forwardRef< | ||
HTMLDivElement, | ||
DeclarativeChartProps | ||
>((props, forwardedRef) => { | ||
const xValues = props.chartSchema.data[0].x; | ||
const isXDate = isDateArray(xValues); | ||
const isXNumber = isNumberArray(xValues); | ||
|
||
switch (props.chartSchema.data[0].type) { | ||
case 'pie': | ||
return <DonutChart {...transformPlotlyJsonToDonutProps(props.chartSchema)} />; | ||
case 'bar': | ||
const orientation = props.chartSchema.data[0].orientation; | ||
if (orientation === 'h') { | ||
return <HorizontalBarChartWithAxis {...transformPlotlyJsonToHorizontalBarWithAxisProps(props.chartSchema)} />; | ||
} else { | ||
return <VerticalStackedBarChart {...transformPlotlyJsonToColumnProps(props.chartSchema)} />; | ||
} | ||
case 'scatter': | ||
const isAreaChart = props.chartSchema.data.some((series: any) => series.fill === 'tonexty'); | ||
if (isXDate || isXNumber) { | ||
if (isAreaChart) { | ||
return <AreaChart {...transformPlotlyJsonToScatterChartProps(props.chartSchema, true)} />; | ||
} | ||
return <LineChart {...transformPlotlyJsonToScatterChartProps(props.chartSchema, false)} />; | ||
} | ||
return <VerticalStackedBarChart {...transformPlotlyJsonToColumnProps(props.chartSchema)} />; | ||
case 'heatmap': | ||
return <HeatMapChart {...transformPlotlyJsonToHeatmapProps(props.chartSchema)} />; | ||
case 'sankey': | ||
return <SankeyChart {...transformPlotlyJsonToSankeyProps(props.chartSchema)} />; | ||
case 'indicator': | ||
if (props.chartSchema?.data?.[0]?.mode?.includes('gauge')) { | ||
return <GaugeChart {...transformPlotlyJsonToGaugeProps(props.chartSchema)} />; | ||
} | ||
return <div>Unsupported Schema</div>; | ||
default: | ||
return <div>Unsupported Schema</div>; | ||
} | ||
}); | ||
DeclarativeChart.displayName = 'DeclarativeChart'; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🕵🏾♀️ visual regressions to review in the fluentuiv9 Visual Regression Report
Avatar Converged 2 screenshots