在角度4中使用highcharts SvgRenderer类

问题描述 投票:0回答:2

如何在角度4打字稿项目中使用HighCharts SvgRenderer类来在高图表中渲染图像?

angular highcharts angular2-highcharts
2个回答
0
投票

就像常规的Highcharts一样:

var chart = this.chart = Highcharts.chart(this.container.nativeElement, {
  series: [{
    data: [1,2,3,4,5]
  }]
})

chart.renderer.image('https://www.highcharts.com/samples/graphics/sun.png', 100, 100, 30, 30)
.add();

这是在Angular 4项目中使用SVGRenderer的实际工作示例:http://plnkr.co/edit/tZIGkSXoogeCyUReARaP?p=preview


0
投票

使用angular2-highcharts你必须更新chart-events

import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { NgModule, Component }    from '@angular/core';
import { BrowserModule }          from '@angular/platform-browser';
import { ChartModule }            from 'angular2-highcharts'; 

@Component({
    selector: 'my-app',
    styles: [`
      chart {
        display: block;
      }
    `],
    template: `<chart [options]="options" (load)="onChartload($event)"></chart>`
})
class AppComponent {
    constructor() { 
        this.options = {
            title : { text : 'simple chart' },
            series: [{
                data: [29.9, 71.5, 106.4, 129],
            }]
        };
    }
    options: Object;
    onChartload (e) {
      e.context.renderer.image('https://www.highcharts.com/samples/graphics/sun.png', 100, 100, 30, 30)
              .add();

    }
}

@NgModule({
  imports:      [BrowserModule, ChartModule.forRoot(require('highcharts'))],
  declarations: [AppComponent],
  bootstrap:    [AppComponent]
})
class AppModule { }


platformBrowserDynamic().bootstrapModule(AppModule);

Z zxswい但是

© www.soinside.com 2019 - 2024. All rights reserved.