Highstock on angular cli
See original GitHub issueI try to implement highstock in angular cli but it seems it doesn’t work. The simple charts works fine but with highstock I get the error- “StockChart is unknown chart type”
app.commponent.ts `import { Component } from ‘@angular/core’; import {Jsonp} from ‘@angular/http’;
@Component({
selector: ‘app-root’,
styles: [ chart { display: block; }
],
template: <chart type="StockChart" [options]="options"></chart>
})
export class AppComponent {
constructor(jsonp : Jsonp) {
jsonp.request(‘https://www.highcharts.com/samples/data/jsonp.php?filename=aapl-c.json&callback=JSONP_CALLBACK’).subscribe(res => {
this.options = {
title : { text : ‘AAPL Stock Price’ },
series : [{
name : ‘AAPL’,
data : res.json(),
tooltip: {
valueDecimals: 2
}
}]
};
});
}
options: Object;
}`
app.module.ts `import { BrowserModule } from ‘@angular/platform-browser’; import { NgModule } from ‘@angular/core’; import { FormsModule } from ‘@angular/forms’; import { HttpModule,Jsonp,JsonpModule } from ‘@angular/http’; import { ChartModule } from ‘angular2-highcharts’; import { AppComponent } from ‘./app.component’;
@NgModule({ declarations: [ AppComponent ], imports: [ BrowserModule, FormsModule, ChartModule, JsonpModule, HttpModule ], providers: [], bootstrap: [AppComponent] }) export class AppModule { }`
Issue Analytics
- State:
- Created 7 years ago
- Comments:40 (10 by maintainers)
Hi,
I found that you can alias highstock.js in tsconfig.ts file as following:
Not sure why this issue is closed. It still persist on the latest angular-cli (1.0.0-beta.20-4). Currently still on angular2-highcharts 0.3.4 since the 0.4.1 breaks the charts with the following error:
inline template:121:7 caused by: StockChart is unknown chart type
The examples provided don’t work on angular-cli. Don’t really see how the solution of @zawars solves anything. Think he just removed the “type” from the chart-tag and the angular2-highcharts is falling back to a regular chart which happens to work with his config.