Skip to content
Snippets Groups Projects
Unverified Commit 805b4f79 authored by Timothy Carambat's avatar Timothy Carambat Committed by GitHub
Browse files

Enable consistent styling on chart items (#3126)

parent a5ee6121
No related branches found
No related tags found
No related merge requests found
...@@ -46,9 +46,9 @@ export default function Tooltip({ legendColor, ...props }) { ...@@ -46,9 +46,9 @@ export default function Tooltip({ legendColor, ...props }) {
{...props} {...props}
content={({ active, payload, label }) => { content={({ active, payload, label }) => {
return active && payload ? ( return active && payload ? (
<div className="bg-white text-sm rounded-md border shadow-lg"> <div className="bg-theme-bg-primary text-sm rounded-md border shadow-lg">
<div className="border-b py-2 px-4"> <div className="border-b py-2 px-4">
<p className="text-elem text-gray-700 font-medium">{label}</p> <p className="text-theme-bg-primary font-medium">{label}</p>
</div> </div>
<div className="space-y-1 py-2 px-4"> <div className="space-y-1 py-2 px-4">
{payload.map(({ value, name }, idx) => ( {payload.map(({ value, name }, idx) => (
...@@ -58,7 +58,7 @@ export default function Tooltip({ legendColor, ...props }) { ...@@ -58,7 +58,7 @@ export default function Tooltip({ legendColor, ...props }) {
> >
<div className="flex items-center space-x-2"> <div className="flex items-center space-x-2">
<span <span
className="shrink-0 h-3 w-3 border-white rounded-md rounded-full border-2 shadow-md" className="shrink-0 h-3 w-3 border-theme-bg-primary rounded-md rounded-full border-2 shadow-md"
style={{ backgroundColor: legendColor }} style={{ backgroundColor: legendColor }}
/> />
<p <p
......
...@@ -75,8 +75,10 @@ export function Chartable({ props, workspace }) { ...@@ -75,8 +75,10 @@ export function Chartable({ props, workspace }) {
switch (chartType) { switch (chartType) {
case "area": case "area":
return ( return (
<div className="bg-zinc-900 p-8 rounded-xl text-white"> <div className="bg-theme-bg-primary p-8 rounded-xl text-white light:border light:border-theme-border-primary">
<h3 className="text-lg font-medium">{title}</h3> <h3 className="text-lg text-theme-text-primary font-medium">
{title}
</h3>
<AreaChart <AreaChart
className="h-[350px]" className="h-[350px]"
data={data} data={data}
...@@ -90,8 +92,10 @@ export function Chartable({ props, workspace }) { ...@@ -90,8 +92,10 @@ export function Chartable({ props, workspace }) {
); );
case "bar": case "bar":
return ( return (
<div className="bg-zinc-900 p-8 rounded-xl text-white"> <div className="bg-theme-bg-primary p-8 rounded-xl text-white light:border light:border-theme-border-primary">
<h3 className="text-lg font-medium">{title}</h3> <h3 className="text-lg text-theme-text-primary font-medium">
{title}
</h3>
<BarChart <BarChart
className="h-[350px]" className="h-[350px]"
data={data} data={data}
...@@ -107,8 +111,10 @@ export function Chartable({ props, workspace }) { ...@@ -107,8 +111,10 @@ export function Chartable({ props, workspace }) {
); );
case "line": case "line":
return ( return (
<div className="bg-zinc-900 p-8 pb-12 rounded-xl text-white h-[500px] w-full"> <div className="bg-theme-bg-primary p-8 pb-12 rounded-xl text-white h-[500px] w-full light:border light:border-theme-border-primary">
<h3 className="text-lg font-medium">{title}</h3> <h3 className="text-lg text-theme-text-primary font-medium">
{title}
</h3>
<LineChart <LineChart
className="h-[400px]" className="h-[400px]"
data={data} data={data}
...@@ -122,8 +128,10 @@ export function Chartable({ props, workspace }) { ...@@ -122,8 +128,10 @@ export function Chartable({ props, workspace }) {
); );
case "composed": case "composed":
return ( return (
<div className="bg-zinc-900 p-8 rounded-xl text-white"> <div className="bg-theme-bg-primary p-8 rounded-xl text-white light:border light:border-theme-border-primary">
<h3 className="text-lg font-medium">{title}</h3> <h3 className="text-lg text-theme-text-primary font-medium">
{title}
</h3>
{showLegend && ( {showLegend && (
<Legend <Legend
categories={[value]} categories={[value]}
...@@ -178,8 +186,10 @@ export function Chartable({ props, workspace }) { ...@@ -178,8 +186,10 @@ export function Chartable({ props, workspace }) {
); );
case "scatter": case "scatter":
return ( return (
<div className="bg-zinc-900 p-8 rounded-xl text-white"> <div className="bg-theme-bg-primary p-8 rounded-xl text-white light:border light:border-theme-border-primary">
<h3 className="text-lg font-medium">{title}</h3> <h3 className="text-lg text-theme-text-primary font-medium">
{title}
</h3>
{showLegend && ( {showLegend && (
<div className="flex justify-end"> <div className="flex justify-end">
<Legend <Legend
...@@ -224,8 +234,10 @@ export function Chartable({ props, workspace }) { ...@@ -224,8 +234,10 @@ export function Chartable({ props, workspace }) {
); );
case "pie": case "pie":
return ( return (
<div className="bg-zinc-900 p-8 rounded-xl text-white"> <div className="bg-theme-bg-primary p-8 rounded-xl text-white light:border light:border-theme-border-primary">
<h3 className="text-lg font-medium">{title}</h3> <h3 className="text-lg text-theme-text-primary font-medium">
{title}
</h3>
<DonutChart <DonutChart
data={data} data={data}
category={value} category={value}
...@@ -248,8 +260,10 @@ export function Chartable({ props, workspace }) { ...@@ -248,8 +260,10 @@ export function Chartable({ props, workspace }) {
); );
case "radar": case "radar":
return ( return (
<div className="bg-zinc-900 p-8 rounded-xl text-white"> <div className="bg-theme-bg-primary p-8 rounded-xl text-white light:border light:border-theme-border-primary">
<h3 className="text-lg font-medium">{title}</h3> <h3 className="text-lg text-theme-text-primary font-medium">
{title}
</h3>
{showLegend && ( {showLegend && (
<div className="flex justify-end"> <div className="flex justify-end">
<Legend <Legend
...@@ -282,8 +296,10 @@ export function Chartable({ props, workspace }) { ...@@ -282,8 +296,10 @@ export function Chartable({ props, workspace }) {
); );
case "radialbar": case "radialbar":
return ( return (
<div className="bg-zinc-900 p-8 rounded-xl text-white"> <div className="bg-theme-bg-primary p-8 rounded-xl text-white light:border light:border-theme-border-primary">
<h3 className="text-lg font-medium">{title}</h3> <h3 className="text-lg text-theme-text-primary font-medium">
{title}
</h3>
{showLegend && ( {showLegend && (
<div className="flex justify-end"> <div className="flex justify-end">
<Legend <Legend
...@@ -317,8 +333,10 @@ export function Chartable({ props, workspace }) { ...@@ -317,8 +333,10 @@ export function Chartable({ props, workspace }) {
); );
case "treemap": case "treemap":
return ( return (
<div className="bg-zinc-900 p-8 rounded-xl text-white"> <div className="bg-theme-bg-primary p-8 rounded-xl text-white light:border light:border-theme-border-primary">
<h3 className="text-lg font-medium">{title}</h3> <h3 className="text-lg text-theme-text-primary font-medium">
{title}
</h3>
{showLegend && ( {showLegend && (
<div className="flex justify-end"> <div className="flex justify-end">
<Legend <Legend
...@@ -343,8 +361,10 @@ export function Chartable({ props, workspace }) { ...@@ -343,8 +361,10 @@ export function Chartable({ props, workspace }) {
); );
case "funnel": case "funnel":
return ( return (
<div className="bg-zinc-900 p-8 rounded-xl text-white"> <div className="bg-theme-bg-primary p-8 rounded-xl text-white light:border light:border-theme-border-primary">
<h3 className="text-lg font-medium">{title}</h3> <h3 className="text-lg text-theme-text-primary font-medium">
{title}
</h3>
{showLegend && ( {showLegend && (
<div className="flex justify-end"> <div className="flex justify-end">
<Legend <Legend
...@@ -413,7 +433,7 @@ const customTooltip = (props) => { ...@@ -413,7 +433,7 @@ const customTooltip = (props) => {
const categoryPayload = payload?.[0]; const categoryPayload = payload?.[0];
if (!categoryPayload) return null; if (!categoryPayload) return null;
return ( return (
<div className="w-56 bg-zinc-400 rounded-lg border p-2 text-white"> <div className="w-56 bg-theme-bg-primary rounded-lg border p-2 text-white">
<div className="flex flex-1 space-x-2.5"> <div className="flex flex-1 space-x-2.5">
<div <div
className={`flex w-1.5 flex-col bg-${categoryPayload?.color}-500 rounded`} className={`flex w-1.5 flex-col bg-${categoryPayload?.color}-500 rounded`}
...@@ -447,13 +467,13 @@ function DownloadGraph({ onClick }) { ...@@ -447,13 +467,13 @@ function DownloadGraph({ onClick }) {
<div className="p-1 rounded-full border-none"> <div className="p-1 rounded-full border-none">
{loading ? ( {loading ? (
<CircleNotch <CircleNotch
className="text-white/50 w-5 h-5 animate-spin" className="text-theme-text-primary w-5 h-5 animate-spin"
aria-label="Downloading image..." aria-label="Downloading image..."
/> />
) : ( ) : (
<DownloadSimple <DownloadSimple
weight="bold" weight="bold"
className="text-white/50 w-5 h-5 hover:text-white" className="text-theme-text-primary w-5 h-5 hover:text-theme-text-primary"
onClick={handleClick} onClick={handleClick}
aria-label="Download graph image" aria-label="Download graph image"
/> />
......
...@@ -836,6 +836,10 @@ does not extend the close button beyond the viewport. */ ...@@ -836,6 +836,10 @@ does not extend the close button beyond the viewport. */
fill: #fff; fill: #fff;
} }
[data-theme="light"] .recharts-text > * {
fill: #000;
}
.recharts-legend-wrapper { .recharts-legend-wrapper {
margin-bottom: 10px; margin-bottom: 10px;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment