({ id, config }: { id: string; config: ChartConfig })
| 88 | } |
| 89 | |
| 90 | const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => { |
| 91 | const colorConfig = Object.entries(config).filter(([, config]) => config.theme ?? config.color); |
| 92 | |
| 93 | if (!colorConfig.length) { |
| 94 | return null; |
| 95 | } |
| 96 | |
| 97 | return ( |
| 98 | <style |
| 99 | dangerouslySetInnerHTML={{ |
| 100 | __html: Object.entries(THEMES) |
| 101 | .map( |
| 102 | ([theme, prefix]) => ` |
| 103 | ${prefix} [data-chart=${id}] { |
| 104 | ${colorConfig |
| 105 | .map(([key, itemConfig]) => { |
| 106 | const color = itemConfig.theme?.[theme as keyof typeof itemConfig.theme] ?? itemConfig.color; |
| 107 | const variableName = chartCssVariableName(key); |
| 108 | const colorValue = color ? chartCssColorValue(color) : null; |
| 109 | return variableName && colorValue ? ` ${variableName}: ${colorValue};` : null; |
| 110 | }) |
| 111 | .filter((line): line is string => line !== null) |
| 112 | .join("\n")} |
| 113 | } |
| 114 | `, |
| 115 | ) |
| 116 | .join("\n"), |
| 117 | }} |
| 118 | /> |
| 119 | ); |
| 120 | }; |
| 121 | |
| 122 | const ChartTooltip = RechartsPrimitive.Tooltip; |
| 123 |
nothing calls this directly
no test coverage detected