0

I have created a line chart in which I am setting the width and height of the line chart depending on the size of the container

"style": {
                "width": Math.round($('#' + container).width()) + "px",
                "height": Math.round($('#' + container).height()) + "px",
                "border": "1px solid silver",
                "position": "relative",
                "top": "0px"
            },

Initially the height and width of the container is 0 and hence the height of the svg is set with some default height and width

        defaultHeigth = 500;
        defaultWidth = 1163;
        chartConfiguration.chart.style.height = defaultHeigth;
        chartConfiguration.chart.style.width = defaultWidth;

Then while creating the svg I am setting the viewbox as

svgEle.setAttribute("viewBox", "0 0 " + chartConfigOptions.chart.style.width + " " + chartConfigOptions.chart.style.height);

svgEle.setAttribute("width", "100%");
svgEle.setAttribute("height", "100%");
svgEle.setAttribute("preserveAspectRatio", "none");

I have tried all sorts of preserveAspectRatio like xMidYMid meet

But in firefox on default load it throws NS_ERROR_FAILURE: and when re-sizing the window size the chart gets rendered perfectly inside the container In other browsers the chart is rendering but its somewhat distorted(like axis points and values are overlapping) and on resizing the window it renders fine.

0 Answers0