【发布时间】:2016-05-18 08:12:35
【问题描述】:
我正在寻找带有 Angular2 的 Highcharts (highcharts.com) CandleSticks 示例。 谁能解释或提供如何在 Angular2 RC 中使用 typescript 的示例?
干杯 卫生巾
【问题讨论】:
标签: highcharts angular
我正在寻找带有 Angular2 的 Highcharts (highcharts.com) CandleSticks 示例。 谁能解释或提供如何在 Angular2 RC 中使用 typescript 的示例?
干杯 卫生巾
【问题讨论】:
标签: highcharts angular
这里是示例
import { Component } from '@angular/core';
import {JSONP_PROVIDERS, Jsonp} from '@angular/http';
import { CHART_DIRECTIVES } from 'angular2-highcharts';
@Component({
selector: 'high-chart',
directives: [CHART_DIRECTIVES],
providers: [JSONP_PROVIDERS],
template: `
<h2> This is HighChart CandleStick component </h2>
<chart type="StockChart" [options]="options3"></chart>
`
})
export class HighChartsComponent {
options3: Object;
constructor(jsonp : Jsonp) {
jsonp.request('https://www.highcharts.com/samples/data/jsonp.php?a=e&filename=aapl-ohlc.json&callback=JSONP_CALLBACK').subscribe(res => {
this.options3 = {
title : { text : 'CandleSticks' },
rangeSelector : {
selected : 1
},
series : [{
type : 'candlestick',
name : 'CandleSticks',
data : res.json(),
dataGrouping : {
units : [
[
'week', // unit name
[1] // allowed multiples
], [
'month',
[1, 2, 3, 4, 6]
]
]
},
tooltip: {
valueDecimals: 2
}
}]
};
});
}
【讨论】: