Conditional re-size of chart

  • 1
  • Question
  • Updated 3 years ago
  • Answered
I am relatively new to highchart API and need some assistance with re-size the chart image based on certain condition. Following is the code snippet I am using. But it is not having any impact on the size of the chart:

var chartObj = arguments[0],$ = skuid.$;
if(some condition...) {
$.extend(true, chartObj.chart[0],{
    width:100,
    height:100
});
}
Photo of Riju Chakraborty

Riju Chakraborty

  • 284 Points 250 badge 2x thumb

Posted 3 years ago

  • 1
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
You may need to add 'px' or '%'... 100px.

If that doesn't work...
 I occasionally have had trouble with the $.extend syntax (probably just my own mistakes). But I think you can just set the width and height directly:

chartObj.chart[0].width = 100px;
chartObj.chart[0].height = 100px;
Photo of J.

J., Official Rep

  • 7,470 Points 5k badge 2x thumb
Riju,

I think it should be chartObj.chart, not chartObj.chart[0]. Both of them are numbers (highcharts interprets them as px), so you shouldn't need to specify "px" either. 
Photo of Riju Chakraborty

Riju Chakraborty

  • 284 Points 250 badge 2x thumb
Thanks for your responses. But it still does not have any impact on the image. This is however working if I try it on a standalone highchart image. I need to spend some more time on it and check if I am missing something.