Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Zingchart chart not filling parent div's width

So I am initializing a zingChart with the following code.

barChartData = 
        "type":"bar"
        "series":[
            "values":[11,16,7,-14,11,24,-42,26,]
        ]


    $("#performance-bar-chart").zingchart(
        data: barChartData
    )

The barchart is rendered correctly but the width doesn't seem to much the parent div. I've checked if anything is setting the height and width but nothing is.

When I zoom in or out on the page (ctrl + mouse scroll) the chart automatically expands to fill the parent div!

Thank you,

like image 398
SegFaultDev Avatar asked Jul 24 '15 20:07

SegFaultDev


1 Answers

To resolve your problem (sudden change of width) you should style your div using

CSS:

#myChart {
    width:100%;
    height:300px;
}

and here is your JS and HTML in case the fiddle is gone.

HTML:

 <div id="myChart"></div>

JS:

 // Data for the chart
var barChartData = {
    type: "bar",
    series: [{  values: [3,7,10,2,6,5]} ]
};

// Make your chart
$("#myChart").zingchart({
    data: barChartData
});
like image 74
Eugen Sunic Avatar answered Nov 14 '22 21:11

Eugen Sunic