This is a migrated thread and some comments may be shown as answers.

Chart width doesn't fill container

5 Answers 955 Views
Charts
This is a migrated thread and some comments may be shown as answers.
Sam
Top achievements
Rank 1
Sam asked on 04 Feb 2016, 01:42 AM

I am using Angularjs in combination with bootstrap. The chart displays after the data has been retrieved using the ng-show="hasData()" option. I want the chart to fill the width of the parent element.

When the chart displays: the "g" element is only 400px wide while the "svg" has 100% width. In the controller constructor I resize the containing element when the window is resized, however, this doesn't happen until the window is resized.

I attached two pictures showing what I'm talking about.

5 Answers, 1 is accepted

Sort by
0
Iliana Dyankova
Telerik team
answered on 08 Feb 2016, 08:25 AM
Hi Sam,

Apologies for the delayed reply.

In order to achieve the expected result you should call kendo.resize. For more details check the corresponding documentation.

Regards,
Iliana Nikolova
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Sam
Top achievements
Rank 1
answered on 08 Feb 2016, 09:05 PM
I call kendo.resize on the parent container just as below. The problem is that the window.resize event does not occur on initial load.
$(window).on("resize", function() {
  kendo.resize($(".chart-wrapper"));
});
0
Iliana Dyankova
Telerik team
answered on 11 Feb 2016, 07:50 AM
Hi Sam,

You could try resizing the chart in the widget created event. If this suggestion does not help, please provide a dojo example which demonstrates your exact setup - this way I would be able to provide concrete recommendations and advice you further. 

Regards,
Iliana Nikolova
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Sam
Top achievements
Rank 1
answered on 21 Feb 2016, 01:25 AM

This person has the same problem here: http://stackoverflow.com/questions/26463613/kendo-ui-chart-not-using-whole-available-space-when-shown-if-created-hidden

An example of the problem here: http://codepen.io/albireo/pen/AeHui/?editors=101

An example of their 'hack' solution here: http://codepen.io/anon/pen/pJewrE

Using the 'hack' solution posted above my chart loads to full width. However, there is a flicker from it resizing, which doesn't look great. Now that you can better understand the problem, is there a solution that I can add which will work better than the one above?

0
Iliana Dyankova
Telerik team
answered on 24 Feb 2016, 07:58 AM
Hi Sam,

Both examples use an outdated version of Kendo UI (2014.2.1008) - upgrading to Q1 2016 (v2016.1.112) and using the resize method seems to fix the problem (dojo).

Regards,
Iliana Nikolova
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Charts
Asked by
Sam
Top achievements
Rank 1
Answers by
Iliana Dyankova
Telerik team
Sam
Top achievements
Rank 1
Share this question
or