-
Notifications
You must be signed in to change notification settings - Fork 25
Arranger Charts Docs #1083
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
base: main
Are you sure you want to change the base?
Arranger Charts Docs #1083
Changes from all commits
4e496fc
9e61254
d587a07
c57a508
f2a2c55
74272ea
702e907
4b26afa
8db94c9
baf3f6e
d6211c5
2e4ff37
013aefe
b512ba0
92a0be8
2cbbd40
b81f1ae
434e684
b20b4ae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # Overview | ||
|
|
||
| **Arranger Charts** is a plugin for Arranger UIs for adding interactive aggregated data charts to React applications. It currently supports Bar and Sunburst charts. Arranger Charts also uses a React context provider to request data from Arranger Server for all charts on the page. Interacting with the charts can update the filters for data requested from Arranger Server. | ||
|
|
||
| ## Key Features | ||
|
|
||
| - Leverages the [Nivo charts](https://github.com/plouc/nivo) library. | ||
| - Integrates with Arranger theming for configuring colour schemes. | ||
| - **ChartsProvider:** React context provider that requests all the data for all charts inside the provider. | ||
| - **Bar chart:** Responsive, horizontal bar chart with configurable colours, tooltips, and sorting. | ||
| - **Sunburst chart:** Responsive sunburst chart showing relationships between broad and specific categories. | ||
|
|
||
| ## Note About Arranger 3.1 and Multiple Catalogues/Indices | ||
|
|
||
| Although Arranger 3.1 has been updated to support multiple catalogues (that is, Elasticsearch indices), currently the Arranger Charts library does not support this. | ||
|
|
||
| Arranger Charts will only support one index/catalogue, with the document type `file`. | ||
|
|
||
| [Arranger Charts issue for allowing multiple indices](https://github.com/overture-stack/arranger/issues/1084) | ||
|
|
||
| ## Dashboard Example | ||
|
|
||
|  | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| # Setup | ||
|
|
||
| For adding Arranger Charts in a React application. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - Node 24 or higher | ||
| - React 18 | ||
| - Arranger Components 3 (for the data context provider) | ||
|
|
||
| ## Developer Setup | ||
|
|
||
| This guide will walk you through installing Arranger Charts in your React application, and adding it to a page or component. | ||
|
|
||
| ### Installation | ||
|
|
||
| ```bash | ||
| npm i @overture-stack/arranger-charts @overture-stack/arranger-components | ||
| ``` | ||
|
|
||
| ### Quick Start | ||
|
Contributor
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. Not really a quick start more of an implementation guide which is great, should think about how we can flesh this out a bit more, "building a discovery page" |
||
|
|
||
| Wrap a charts in required providers: `ArrangerDataProvider`,`ChartsProvider` and `ChartsThemeProvider`. | ||
|
|
||
| Chart component is responsive to its parent container's dimensions. | ||
|
|
||
| ```jsx | ||
| import { ChartsProvider, ChartsThemeProvider, BarChart, SunburstChart } from '@overture-stack/arranger-charts'; | ||
| import { ArrangerDataProvider } from '@overture-stack/arranger-components'; | ||
|
|
||
| function App() { | ||
| return ( | ||
| <ArrangerDataProvider | ||
| apiUrl={YOUR_ARRANGER_API_URL} | ||
| documentType="file" // must be "file" for Arranger Charts | ||
| > | ||
| <ChartsProvider> | ||
| <ChartsThemeProvider> | ||
| <BarChart | ||
| fieldName="gender" | ||
| maxBars={10} | ||
| handlers={{ onClick: (data) => console.log(data) }} | ||
| /> | ||
| </ChartsThemeProvider> | ||
| </ChartsProvider> | ||
| </ArrangerDataProvider> | ||
| ); | ||
| } | ||
| ``` | ||
|
|
||
| ### Dependencies | ||
|
|
||
| Arranger Charts requires an `ArrangerDataProvider` from `@overture-stack/arranger-components` as a parent component to handle data fetching and SQON state management. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,174 @@ | ||
| # Usage | ||
|
|
||
| This guide covers how to use Arranger Charts, what components are available, and React props for each component. | ||
|
|
||
| ## Components | ||
|
|
||
| ### ChartsProvider | ||
|
|
||
| The main provider that manages chart registration and data fetching, and coordinates multiple charts. | ||
|
|
||
| #### Props | ||
|
|
||
| | Name | Type | Required | Description | | ||
| | ----------------------- | --------- | -------- | -------------------------------------- | | ||
| | `debugMode` | `boolean` | No | Enable verbose logging for development | | ||
| | `disableIncludeMissing` | `boolean` | No | Hide properties with "No Data" | | ||
| | `loadingDelay` | `number` | No | Delay network results by milliseconds | | ||
|
justincorrigible marked this conversation as resolved.
|
||
|
|
||
| #### Example | ||
|
|
||
| ```jsx | ||
| <ChartsProvider | ||
| debugMode | ||
| disableIncludeMissing={false} | ||
| loadingDelay={250} | ||
| > | ||
| {/* ChartsThemeProvider */} | ||
| </ChartsProvider> | ||
| ``` | ||
|
|
||
| ### ChartsThemeProvider | ||
|
|
||
| Provides theme configuration and custom components to all child charts. You can nest multiple `<ChartsThemeProvider>` components under a single `<ChartsProvider>`. | ||
|
|
||
| #### Props | ||
|
|
||
| | Name | Type | Required | Description | | ||
| | ---------------------- | ---------------- | -------- | ------------------------------------- | | ||
| | `colors` | `string[]` | No | Array of hex colors for chart theming | | ||
| | `components` | `object` | No | Custom fallback components | | ||
| | `components.EmptyData` | `ReactComponent` | No | Custom empty state component | | ||
| | `components.ErrorData` | `ReactComponent` | No | Custom error component | | ||
| | `components.Loader` | `ReactComponent` | No | Custom loading component | | ||
|
justincorrigible marked this conversation as resolved.
|
||
|
|
||
| #### Example | ||
|
|
||
| ```jsx | ||
| <ChartsThemeProvider | ||
| colors={['#ff6b6b', '#4ecdc4', '#45b7d1']} | ||
| components={{ | ||
| EmptyData: NoDataMessage, | ||
| ErrorData: CustomError, | ||
| Loader: CustomSpinner, | ||
| }} | ||
| > | ||
| {/* Charts */} | ||
| </ChartsThemeProvider> | ||
| ``` | ||
|
|
||
| ### BarChart | ||
|
|
||
| Renders a horizontal bar chart for aggregation data. | ||
|
Contributor
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. If introducing a visual component please include a screenshot of the component. |
||
|
|
||
| #### Props | ||
|
|
||
| | Name | Type | Required | Description | | ||
| | -------------------------------------- | ---------- | -------- | --------------------------------------------------------------------------------------------------- | | ||
| | `disableTopBarsCount` | `boolean` | No | Disables the "Top `bars` of `totalBars`" flag at the top right of charts. | | ||
| | `fieldName` | `string` | Yes | GraphQL field name to visualize | | ||
| | `handlers` | `object` | No | Event handlers | | ||
| | `handlers.onClick` | `function` | No | Callback when clicking a bar segment | | ||
| | `maxBars` | `number` | Yes | Maximum number of bars to display | | ||
| | `ranges` | `Range[]` | No | For numeric fields, specify value ranges. A `Range` is `{ key: string, from: number, to: number }`. | | ||
| | `theme` | `object` | Yes | Chart configuration options | | ||
| | `theme.sortByKey` | `string[]` | No | Array of keys to sort the data by. | | ||
| | `theme.axisBottom.customTickValueSize` | `number` | `No` | For setting a custom step size for the bottom (X) axis | | ||
|
|
||
| #### Example | ||
|
|
||
| ```jsx | ||
| <ArrangerDataProvider | ||
| apiUrl={YOUR_ARRANGER_API_URL} | ||
| documentType="file" // must be "file" for Arranger Charts | ||
| > | ||
| <ChartsProvider> | ||
| <ChartsThemeProvider> | ||
| <BarChart | ||
| fieldName="primary_site" | ||
| handlers={{ | ||
| onClick: (data) => { | ||
| console.log('Clicked', data.label, data.value); | ||
| }, | ||
| }} | ||
| maxBars={15} | ||
| theme={{ | ||
| sortByKey: ['Brain', 'Lung', 'Breast', '__missing__'], | ||
| }} | ||
| /> | ||
| </ChartsThemeProvider> | ||
| </ChartsProvider> | ||
| </ArrangerDataProvider> | ||
| ``` | ||
|
|
||
| #### Screenshot | ||
|
|
||
|  | ||
|
|
||
| ### SunburstChart | ||
|
|
||
| Creates a sunburst chart showing relationships between broad and specific categories. | ||
|
|
||
| #### Props | ||
|
|
||
| | Name | Type | Required | Description | | ||
| | ------------------ | ---------- | -------- | ----------------------------------------------- | | ||
| | `fieldName` | `string` | Yes | GraphQL field name to visualize | | ||
| | `maxSegments` | `number` | Yes | Maximum number of segments to display | | ||
| | `mapper` | `function` | Yes | Maps outer ring values to inner ring categories | | ||
| | `handlers` | `object` | No | Event handlers | | ||
| | `handlers.onClick` | `function` | No | Callback when clicking a segment | | ||
| | `theme` | `object` | No | Chart configuration options | | ||
|
|
||
| #### Example | ||
|
|
||
| ```jsx | ||
| <ArrangerDataProvider | ||
| apiUrl={YOUR_ARRANGER_API_URL} | ||
| documentType="file" // must be "file" for Arranger Charts | ||
| > | ||
| <ChartsProvider> | ||
| <ChartsThemeProvider> | ||
| <SunburstChart | ||
| fieldName="primary_diagnosis" | ||
| maxSegments={12} | ||
| mapper={(value) => { | ||
| if (value.startsWith('C78')) return 'Metastatic'; | ||
| if (value.startsWith('C50')) return 'Breast Cancer'; | ||
| return value; | ||
| }} | ||
| handlers={{ | ||
| onClick: (data) => { | ||
| console.log('Selected category:', data); | ||
| }, | ||
| }} | ||
| /> | ||
| </ChartsThemeProvider> | ||
| </ChartsProvider> | ||
| </ArrangerDataProvider> | ||
| ``` | ||
|
|
||
| #### Screenshot | ||
|
|
||
|  | ||
|
|
||
| ## Field Types | ||
|
|
||
| Charts automatically detect field types from Arranger's extended mapping: | ||
|
|
||
| - **Aggregations**: Categorical fields | ||
| - **NumericAggregations**: Numeric fields that require range specifications | ||
|
|
||
| For numeric fields, provide ranges: | ||
|
|
||
| ```jsx | ||
| <BarChart | ||
| fieldName="age_at_diagnosis" | ||
| ranges={[ | ||
| { key: '0-18', from: 0, to: 18 }, | ||
| { key: '19-65', from: 19, to: 65 }, | ||
| { key: '65+', from: 65 }, | ||
| ]} | ||
| maxBars={10} | ||
| /> | ||
| ``` | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| # Development | ||
|
|
||
| This guide covers how to develop or contribute to Arranger Charts. For using Arranger Charts in a React application, see [Guides/Usage](01-Usage.md). | ||
|
|
||
| ## Local Development | ||
|
|
||
| ```bash | ||
| # Install dependencies | ||
| npm install | ||
|
|
||
| # Build and watch for changes | ||
| npm run dev | ||
| ``` | ||
|
|
||
| ## Using Local Versions of Arranger Charts & Arranger Components | ||
|
|
||
| To develop Arranger modules and see changes in your React app in real-time, you can use `npm link`: | ||
|
|
||
| ```bash | ||
| # in your local Arranger folder | ||
| cd modules/charts | ||
| npm link | ||
| cd ../.. | ||
| cd modules/components | ||
| npm link | ||
| ``` | ||
|
Comment on lines
+19
to
+26
Member
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. note to self @justincorrigible: make this a batch/make command |
||
|
|
||
| Then link these packages in your consumer React project: | ||
|
|
||
| ```bash | ||
| # in your local React app | ||
| npm link @overture-stack/arranger-charts | ||
| npm link @overture-stack/arranger-components | ||
| ``` | ||
|
|
||
| To remove these links: | ||
|
|
||
| ```bash | ||
| # in your local React app | ||
| npm unlink @overture-stack/arranger-charts | ||
| npm unlink @overture-stack/arranger-components | ||
| ``` | ||
|
|
||
| ## Debug Mode | ||
|
|
||
| Enable verbose logging by setting the `debugMode` prop on `ChartsProvider`. | ||
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.
Please include a screen shot of the charts within a discovery page