VenkiArun
VenkiArun

Reputation: 199

Highchart data based to set div width and height dynamically

In my application I use highchart for report purpose.I set div height and width to be 100% but data to be hidden .So I need highchart data based to automatically set div width and height to be a possible? In below chart I have 40 user data but in chart even number user data to be a missing i.e user2,user4,user6 enter image description here

Upvotes: 0

Views: 461

Answers (1)

Anand MS
Anand MS

Reputation: 94

$(function() 
{
(function(H) 
{
H.wrap(H.Axis.prototype, 'setAxisSize', function(proceed) 
{
var chart = this.chart,
staticScale = this.options.staticScale,height,diff;
var defaultWidth=20;
// For each series destroy trackball
if (staticScale !== undefined) {
var widthDiff;
if (chart.xAxis[0].max !== null)
{
widthDiff = chart.xAxis[0].max * defaultWidth;
}
height = (this.max - this.min) * staticScale;
diff = height - chart.plotHeight;
chart.plotHeight = height;
if (Math.abs(diff) >= 1 && chart.xAxis[0].max !== null) {

chart.setSize(
chart.chartWidth + widthDiff,
chart.chartHeight + diff,
!chart.hasRendered
 );
}
}
proceed.call(this);
});
}(Highcharts));

Upvotes: 1

Related Questions