-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PLAY-236] Rebuild Charts to Use React-Highcharts (#2191)
* PLAY-236- replaced plugin with wrapper for bar chart * refactored circle chart react * refactored treemap chart react + rails * refactored line graph react + rails * refactored gauge react + rails, added rails for circle chart * Circle chart fixes, tooltip for treemap * Tooltip for ciecle chart * Fixed gauge issue with theming not applying to first item * minor fixes * Fixes for pointFormat * Fixed linestroke isseu with guage kit * Fixed complex example for gauge kit * Fixed treemap pointformat issue * circle chart block issue * Fixes for circle chart block content * Remove pbChart plugin, clean up code * trying to fix CI errors
- Loading branch information
Showing
29 changed files
with
929 additions
and
1,051 deletions.
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
111 changes: 0 additions & 111 deletions
111
playbook/app/pb_kits/playbook/pb_bar_graph/_bar_graph.jsx
This file was deleted.
Oops, something went wrong.
145 changes: 145 additions & 0 deletions
145
playbook/app/pb_kits/playbook/pb_bar_graph/_bar_graph.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,145 @@ | ||
import React, { useState, useEffect } from "react"; | ||
import { globalProps } from "../utilities/globalProps"; | ||
import { buildAriaProps, buildDataProps } from "../utilities/props"; | ||
|
||
import HighchartsReact from "highcharts-react-official"; | ||
import Highcharts from "highcharts"; | ||
import { highchartsTheme } from "../pb_dashboard/pbChartsLightTheme"; | ||
import { highchartsDarkTheme } from "../pb_dashboard/pbChartsDarkTheme"; | ||
import mapColors from "../pb_dashboard/pbChartsColorsHelper"; | ||
|
||
import classnames from "classnames"; | ||
|
||
type BarGraphProps = { | ||
align?: "left" | "right" | "center"; | ||
axisTitle: string; | ||
dark?: Boolean; | ||
xAxisCategories: []; | ||
yAxisMin: number; | ||
yAxisMax: number; | ||
chartData: { name: string; data: number[] }[]; | ||
className?: string; | ||
id: any; | ||
pointStart: number | any; | ||
subTitle?: string; | ||
title: string; | ||
type?: string; | ||
legend?: boolean; | ||
toggleLegendClick?: boolean; | ||
height?: string; | ||
colors: string[]; | ||
layout?: "horizontal" | "vertical" | "proximate"; | ||
verticalAlign?: "top" | "middle" | "bottom"; | ||
x?: number; | ||
y?: number; | ||
aria?: { [key: string]: string }; | ||
data?: { [key: string]: string }; | ||
}; | ||
|
||
|
||
const BarGraph = ({ | ||
aria = {}, | ||
data = {}, | ||
align = "center", | ||
axisTitle, | ||
dark = false, | ||
chartData, | ||
className = "pb_bar_graph", | ||
colors, | ||
id, | ||
pointStart, | ||
subTitle, | ||
type = "column", | ||
title = "Title", | ||
xAxisCategories, | ||
yAxisMin, | ||
yAxisMax, | ||
legend = false, | ||
toggleLegendClick = true, | ||
height, | ||
layout = "horizontal", | ||
verticalAlign = "bottom", | ||
x = 0, | ||
y = 0, | ||
...props | ||
}: BarGraphProps) => { | ||
const ariaProps = buildAriaProps(aria); | ||
const dataProps = buildDataProps(data); | ||
const setupTheme = () => { | ||
dark | ||
? Highcharts.setOptions(highchartsDarkTheme) | ||
: Highcharts.setOptions(highchartsTheme); | ||
}; | ||
setupTheme(); | ||
|
||
const staticOptions = { | ||
title: { | ||
text: title, | ||
}, | ||
chart: { | ||
height: height, | ||
type: type, | ||
}, | ||
subtitle: { | ||
text: subTitle, | ||
}, | ||
yAxis: { | ||
min: yAxisMin, | ||
max: yAxisMax, | ||
title: { | ||
text: axisTitle, | ||
}, | ||
}, | ||
xAxis: { | ||
categories: xAxisCategories, | ||
}, | ||
legend: { | ||
enabled: legend, | ||
align: align, | ||
verticalAlign: verticalAlign, | ||
layout: layout, | ||
x: x, | ||
y: y, | ||
}, | ||
colors: | ||
colors !== undefined && colors.length > 0 | ||
? mapColors(colors) | ||
: highchartsTheme.colors, | ||
plotOptions: { | ||
series: { | ||
pointStart: pointStart, | ||
events: {}, | ||
dataLabels: { | ||
enabled: false, | ||
}, | ||
}, | ||
}, | ||
series: chartData, | ||
credits: false, | ||
}; | ||
|
||
if (!toggleLegendClick) { | ||
staticOptions.plotOptions.series.events = { legendItemClick: () => false }; | ||
} | ||
|
||
const [options, setOptions] = useState({}); | ||
|
||
useEffect(() => { | ||
setOptions({ ...staticOptions }); | ||
}, [chartData]); | ||
|
||
return ( | ||
<HighchartsReact | ||
containerProps={{ | ||
className: classnames(globalProps(props), className), | ||
id: id, | ||
...ariaProps, | ||
...dataProps, | ||
}} | ||
highcharts={Highcharts} | ||
options={options} | ||
/> | ||
); | ||
}; | ||
|
||
export default BarGraph; |
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,2 @@ | ||
declare module "*.scss" | ||
declare module "highcharts-react-official" |
Oops, something went wrong.