Reputation: 313
I am changing My SPA application from Javascript to typeScript. In this project I have used Fusionchart JQuery plugin. Now I have to integrate FusionChart in this type Script project. i have Added jquery.d.ts in my project but not able to figure out how can I use that to integrate.
Is there any way to that?
Upvotes: 4
Views: 1610
Reputation: 313
Firstly thanks to all.
I have done as follows:
I declared a class Names FusionChart in a separate ts file as follows:
declare class FusionCharts {
constructor(ChartType: string, ChartName: string, height: string, width: string);
constructor(ChartType: string, ChartName: string, height: string, width: string, other: string);
public setXMLData(ChartValues: string): any;
public render(renderId: string): any;
public static setCurrentRenderer(renderName: string): any;
}
after that I used the constructor of this class in my ViewModel backend .ts file as follows:
My code is as follows:
export class FinancialView
{
public column3DChart: FusionCharts;
constructor() {
this.column3DChart = new FusionCharts("Column3D", "myChartId", "300", "200");
this.column3DChart.setXMLData("XML data");
}
compositionComplete() {
FusionCharts.setCurrentRenderer('javascript');
this.column3DChart.render("chartdivId");
}
}
Upvotes: 2
Reputation: 616
There are two ways in which you can get and use TypeScript.
Simply put TypeScript compiles all .ts files to .js files. It doesn't matter even if .ts files contain only JavaScript and no TypeScript at all, as it is a superset to JavaScript.
So just rename your JavaScript files to .ts and your app will work as it should. The added benefit is that you can use the power of TypeScript.
Upvotes: 2