Chart.js
1 month ago
ChartAreaChart.js
1 month ago
ChartContext.js
1 month ago
ChartDateFilter.js
1 month ago
ChartKPI.js
1 month ago
ChartSummary.js
1 month ago
ChartTabs.js
1 month ago
index.js
1 month ago
index.js
24 lines
| 1 | import ChartContext from "./ChartContext"; |
| 2 | import Chart from "./Chart"; |
| 3 | import useEngagementChartData from "../../hooks/useEngagementChartData"; |
| 4 | |
| 5 | const SelfManaged = ({ showAllTimeSummary, children }) => { |
| 6 | const value = useEngagementChartData({ showAllTimeSummary }); |
| 7 | return <ChartContext.Provider value={value}>{children}</ChartContext.Provider>; |
| 8 | }; |
| 9 | |
| 10 | // Pass `contextValue` to share the chart hook with sibling consumers |
| 11 | // (e.g. useTopPerforming on the Analytics page); omit it to let the |
| 12 | // component own its own hook instance. |
| 13 | const EngagementChart = ({ showAllTimeSummary = false, contextValue, children }) => { |
| 14 | if (contextValue) { |
| 15 | return <ChartContext.Provider value={contextValue}>{children}</ChartContext.Provider>; |
| 16 | } |
| 17 | return ( |
| 18 | <SelfManaged showAllTimeSummary={showAllTimeSummary}>{children}</SelfManaged> |
| 19 | ); |
| 20 | }; |
| 21 | |
| 22 | export { Chart }; |
| 23 | export default EngagementChart; |
| 24 |