위젯 미니차트 수정
This commit is contained in:
@@ -24,6 +24,7 @@ import {
|
||||
import type { WidgetSlot } from '../../types/widgetDashboard';
|
||||
import FloatingWidgetLayoutPicker from './FloatingWidgetLayoutPicker';
|
||||
import FloatingWidgetWindow from './FloatingWidgetWindow';
|
||||
import '../../styles/paperDashboard.css';
|
||||
import '../../styles/widgetDashboard.css';
|
||||
import '../../styles/floatingWidget.css';
|
||||
|
||||
|
||||
@@ -69,7 +69,10 @@ const PaperMiniChart: React.FC<Props> = ({
|
||||
useEffect(() => {
|
||||
if (!containerRef.current) return undefined;
|
||||
const t = readChartTheme(containerRef.current);
|
||||
const chart = createChart(containerRef.current, {
|
||||
const el = containerRef.current;
|
||||
const chart = createChart(el, {
|
||||
width: el.clientWidth || undefined,
|
||||
height: el.clientHeight || undefined,
|
||||
layout: {
|
||||
background: { type: ColorType.Solid, color: t.bgColor },
|
||||
textColor: t.textColor,
|
||||
@@ -103,7 +106,18 @@ const PaperMiniChart: React.FC<Props> = ({
|
||||
});
|
||||
ro.observe(containerRef.current);
|
||||
|
||||
const onLayoutSync = () => {
|
||||
if (containerRef.current && chartRef.current) {
|
||||
chartRef.current.applyOptions({
|
||||
width: containerRef.current.clientWidth,
|
||||
height: containerRef.current.clientHeight,
|
||||
});
|
||||
}
|
||||
};
|
||||
window.addEventListener('gc-widget-layout-sync', onLayoutSync);
|
||||
|
||||
return () => {
|
||||
window.removeEventListener('gc-widget-layout-sync', onLayoutSync);
|
||||
ro.disconnect();
|
||||
chart.remove();
|
||||
chartRef.current = null;
|
||||
|
||||
Reference in New Issue
Block a user