1
1
/** @jsxImportSource @emotion /react */
2
2
import { css , SerializedStyles } from '@emotion/react' ;
3
- import React , { useEffect } from 'react' ;
3
+ import React , { useEffect , useState } from 'react' ;
4
4
import Highcharts from 'highcharts' ;
5
5
import HighchartsReact from 'highcharts-react-official' ;
6
6
import { useTheme } from '../context/ThemeContext' ;
7
- import { themeGlobalDark , themeGlobalLight } from './charts/ChartTheme' ;
8
7
9
8
interface IMusicChartProps {
10
9
styles ?: SerializedStyles ;
@@ -14,15 +13,14 @@ interface IMusicChartProps {
14
13
15
14
export const MusicChart : React . FC < IMusicChartProps > = ( props ) => {
16
15
const appTheme = useTheme ( ) ;
16
+ const [ classTheme , setClassTheme ] = useState ( '' ) ;
17
17
18
18
useEffect ( ( ) => {
19
- const themeConfig = appTheme . darkMode ? themeGlobalDark : themeGlobalLight ;
20
- const newOptions = {
21
- ...props . options ,
22
- ...themeConfig ,
23
- } ;
24
- props . chartComponent . current ?. chart ?. update ( newOptions ) ;
25
- } , [ props . chartComponent , props . options , appTheme ] ) ;
19
+ const themeClass = appTheme . darkMode
20
+ ? 'highcharts-dark'
21
+ : 'highcharts-light' ;
22
+ setClassTheme ( themeClass ) ;
23
+ } , [ appTheme ] ) ;
26
24
27
25
return (
28
26
< div
@@ -39,7 +37,7 @@ export const MusicChart: React.FC<IMusicChartProps> = (props) => {
39
37
>
40
38
< HighchartsReact
41
39
containerProps = { {
42
- className : ' react-highcharts-container' ,
40
+ className : ` react-highcharts-container ${ classTheme } ` ,
43
41
style : { width : '100%' , height : '100%' } ,
44
42
} }
45
43
highcharts = { Highcharts }
0 commit comments