【问题标题】:How to use candlestick highchart in Angular2?如何在 Angular2 中使用烛台高图?
【发布时间】:2016-05-18 08:12:35
【问题描述】:

我正在寻找带有 Angular2 的 Highcharts (highcharts.com) CandleSticks 示例。 谁能解释或提供如何在 Angular2 RC 中使用 typescript 的示例?

干杯 卫生巾

【问题讨论】:

    标签: highcharts angular


    【解决方案1】:

    这里是示例

    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
                        }
                    }]
                };
    
            });
    
    
    }
    

    【讨论】:

    • 嗨@Sanket,我试图集成到角度4,但没有工作。你能帮帮我吗?
    • @M.Deepak,请提出一个详细的新问题(即到目前为止您尝试了什么,遇到了什么错误,代码示例等)
    猜你喜欢
    • 2011-06-07
    • 1970-01-01
    • 2014-04-10
    • 2023-03-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-06
    • 1970-01-01
    相关资源
    最近更新 更多