import React, { useState, useLayoutEffect, useRef } from "react";
import { ChartContainer } from "../../chart/components/chart-container";
const noop = () => { };
export const ChartWrapper = ({ attributes, dropdownMenu, id, style: styleOverride, chartMetadata, renderCustomElementForDygraph, onAttributesChange = noop, }) => {
    const chartContainerRef = useRef(null);
    const [chartContainerElement, setChartContainerElement] = useState();
    useLayoutEffect(() => {
        if (!chartContainerElement && chartContainerRef.current) {
            setChartContainerElement(chartContainerRef.current);
        }
    }, [chartContainerElement]);
    // const style = height
    //   ? { width: "100%", height: `${height}px` }
    //   : { width: "100%" }
    return (React.createElement("div", { ref: chartContainerRef, className: "dashboardjs-chart", id: id, role: "application", style: styleOverride }, chartContainerElement && (React.createElement(ChartContainer, { attributes: attributes, chartMetadata: chartMetadata, chartUuid: id, dropdownMenu: dropdownMenu, portalNode: chartContainerElement, renderCustomElementForDygraph: renderCustomElementForDygraph, onAttributesChange: onAttributesChange }))));
};
//# sourceMappingURL=chart-wrapper.js.map