jQWidgets Forums
jQuery UI Widgets › Forums › Angular › JQXChart not resizing when window resize Angular2
Tagged: JQXChart angular2 webpack
This topic contains 19 replies, has 3 voices, and was last updated by Ivo Zhulev 8 years, 2 months ago.
-
Author
-
Hello,
I am experiencing the following problem. When i resize my window the chart won’t resize itself. I thought this worked in Angular 1.5, so why i am not getting this to work in my Angular2 app. Am i doing something wrong?
component.html
<jqxChart [width]='"100%"' [height]='400' [source]='ecverloop' [description]='false' [auto-create]='false' #chartReferenceEng></jqxChart>' part of my component.ts:
export class StudieStatusComponent implements AfterViewInit{
@ViewChild(‘chartReference’) myChart: jqxChartComponent;
@ViewChild(‘chartReferenceEng’) myChartEng: jqxChartComponent;public ecverloop: ECVerloop[];
public studiestatus: StudieStatus[];
public toetsresultaten: ToetsResultaten[];
public userinfo: UserInfo;
public titelEngels: string = “Overview achieved and determined EC”;
public titel: string = “Verloop behalen en toekennen van EC’s vanaf start opleiding”;constructor(
private ecverloopService: ECVerloopService,
private studiestatusService: StudieStatusService,
private toetsresultatenService: ToetsResultatenService,
private userInfoService: UserInfoService) { }
ngAfterViewInit(): void {
this.getECVerloop();
this.getStudieStatus();
this.getToetsresultaten();
this.getuserInfo();
this.myChart.createComponent(this.chartsettings);
this.myChartEng.createComponent(this.chartsettingsEng);}
chartsettings: jqwidgets.ChartOptions = {
enableAnimations: true,
showLegend: true,
borderLineWidth: 0,
padding: { left: 25, top: 25, right: 35, bottom: 25 },
titlePadding: { left: 15, top: 15, right: 15, bottom: 25 },
title: this.titel,
xAxis:
{
dataField: ‘datum’,
type: ‘date’
},
colorScheme: ‘scheme01’,
seriesGroups:
[
{
type: ‘area’,
series: [{
dataField: ‘toegekendewaardecumm’,
displayText: ‘Toegekende waarde’,
opacity: 0.7
}]
},
{
type: ‘spline’,
series: [
{
dataField: ‘virtuelewaardecumm’,
displayText: ‘Virtuele waarde’,
opacity: 0.7
}
]
},
{
type: ‘spline’,
series: [
{
dataField: ‘compensatiewaardecumm’,
displayText: ‘Compensatie waarde’,
opacity: 0.7
}
]
}]
}`
Do i need to do something else to make this to work?
Also i saw some ‘advertisement’ link to jqwidgets.com in the chart is this something new?
Hi rjwijnen,
1. The Chart’s width and height should be in percentages if you want it’s size to be responsive/fluid. That is not related to Angular, but with the general way any widget should be used.
2. The link to our website is not something new. That link is not displayed if the production or source code builds are used.
Best Regards,
Peter StoevDear Peter,
As you can see in my example i am using a width of: <jqxChart [width]='”100%”‘ [height]=’400’
On load it works, but when i resize the window the graph is at its old width and not resized to the 100% of the new window size.Hi rjwijnen,
This is an issue and it will be fixed in the next release.
Sorry for the inconvenience.Best Regards,
IvojQWidgets Team
http://www.jqwidgets.com/Thanks for the response. But when is the next version to be released? Is this within 1-2 weeks or more like month(s)?
I just updated to 4.5.1 in the hope this problem would be fixed. Unfortunately it was still not resizing. Will this be fixed soon or do we need to wait a few months? (this is kind of a showstopper for us at the moment)
Hi rjwijnen,
It should work. Can you please tell me the widget config (the settings you initialize the chart with).
Best Regards,
IvojQWidgets Team
http://www.jqwidgets.com/Component:
export class StudieStatusComponent implements AfterViewInit, OnInit { @ViewChild('chartReference') myChart: jqxChartComponent; @ViewChild('chartReferenceEng') myChartEng: jqxChartComponent; public ecverloop: ECVerloop[]; public userinfo: UserInfo; public titel: string = "Verloop behalen en toekennen van EC's vanaf start opleiding"; constructor( private ecverloopService: ECVerloopService, private studiestatusService: StudieStatusService, private toetsresultatenService: ToetsResultatenService, private userInfoService: UserInfoService ) { } ngOnInit() { this.getECVerloop(); this.getStudieStatus(); this.getToetsresultaten(); this.getuserInfo(); } ngAfterViewInit(): void { this.myChart.createComponent(this.chartsettings); this.myChartEng.createComponent(this.chartsettingsEng); } chartsettings: jqwidgets.ChartOptions = { enableAnimations: true, showLegend: true, borderLineWidth: 0, padding: { left: 25, top: 25, right: 35, bottom: 25 }, titlePadding: { left: 15, top: 15, right: 15, bottom: 25 }, title: this.titel, xAxis: { dataField: 'datum', type: 'date' }, colorScheme: 'scheme01', seriesGroups: [ { type: 'area', series: [{ dataField: 'toegekendewaardecumm', displayText: 'Toegekende waarde', opacity: 0.7 }] }, { type: 'spline', series: [ { dataField: 'virtuelewaardecumm', displayText: 'Virtuele waarde', opacity: 0.7 } ] }, { type: 'spline', series: [ { dataField: 'compensatiewaardecumm', displayText: 'Compensatie waarde', opacity: 0.7 } ] } ] }
HTML:
<div class="hidden-xs hidden-sm"> <div [hidden]="userinfo?.taalid != '2'" class="hidden-xs hidden-sm"> <jqxChart [width]='"100%"' [height]='400' [source]='ecverloop' [description]='false' [auto-create]='false' #chartReferenceEng></jqxChart> </div> <div [hidden]="userinfo?.taalid != '1'" class="hidden-xs hidden-sm"> <jqxChart [width]='"100%"' [height]='400' [source]='ecverloop' [description]='false' [auto-create]='false' #chartReference></jqxChart> </div> </div>
Hi rjwijnen,
I tried your config with just other data and it works fine. Here is the code i used:
import { Component, AfterViewInit, ViewChild } from '@angular/core'; import { jqxChartComponent } from '../assets/jqwidgets-ts/angular_jqxChart'; @Component({ selector: 'app-root', template: <code><jqxChart [width]='"100%"' [height]='400' [auto-create]='false' #chartReference></jqxChart></code> }) export class AppComponent { @ViewChild('chartReference') myChart: jqxChartComponent; ngAfterViewInit() { this.myChart.createComponent(this.chartsettings) } source: any = { datatype: "csv", datafields: [ { name: 'Date' }, { name: 'S&P 500' }, { name: 'NASDAQ' } ], url: '../assets/nasdaq_vs_sp500.txt' }; dataAdapter: any = new $.jqx.dataAdapter(this.source, { async: false, autoBind: true, loadError: (xhr: any, status: any, error: any) => { alert('Error loading "' + this.source.url + '" : ' + error); } }); chartsettings: jqwidgets.ChartOptions = { enableAnimations: true, showLegend: true, borderLineWidth: 0, source: this.dataAdapter, padding: { left: 25, top: 25, right: 35, bottom: 25 }, titlePadding: { left: 15, top: 15, right: 15, bottom: 25 }, title: 'asd', xAxis: { dataField: 'Date', type: 'date', baseUnit: 'month', valuesOnTicks: true, minValue: '01-01-2014', maxValue: '01-01-2015', tickMarks: { visible: true, interval: 1, color: '#BCBCBC' }, unitInterval: 1, gridLines: { visible: true, interval: 3, color: '#BCBCBC' }, labels: { angle: -45, rotationPoint: 'topright', offset: { x: 0, y: -25 } } }, colorScheme: 'scheme01', seriesGroups: [ { type: 'line', series: [ { dataField: 'S&P 500', displayText: 'S&P 500' }, { dataField: 'NASDAQ', displayText: 'NASDAQ' } ] } ] } }
Best Regards,
IvojQWidgets Team
http://www.jqwidgets.com/I did some more testing this evening. As you can see in my example i am hidding one graph based on the ‘taalid’ (stands for langauge). When i don’t use this and just show both graphs only one of the graphs resizes and the other one don’t. I checked this with a brand new Angluar-CLI project with just jqwidgets. As soon as i add the second graph on the page only one of them resizes and the other one don’t.
Hi rjwijnen,
I guess you want to show only the needed chart for the person. So both chart won`t exist together ever.
Could you try just with one chart and make it visible from start. Will it work?
Awaiting your feedback.Best Regards,
IvojQWidgets Team
http://www.jqwidgets.com/When i remove one chart then it does work. But i need to change serveral display text based on the language settings of the user. (different chartsettings)
Hi rjwijnen,
Why don`t you just have one chart in the DOM and have its changeable properties bind to some variables that hold that texts.
So you have only one chart with only one chartSettings. Just the settings will change based on the user.Best Regards,
IvojQWidgets Team
http://www.jqwidgets.com/That is possible, but on other pages whe want to show two different charts. Then we still have these problems. So i was hoping this could be fixed.
-
AuthorPosts
You must be logged in to reply to this topic.