renderer.text不适用于gevgeny / angular2-highcharts [英] renderer.text not working in gevgeny/angular2-highcharts

查看:143
本文介绍了renderer.text不适用于gevgeny / angular2-highcharts的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 gevgeny / angular2-highcharts 来使用高图在角度项目。我正在尝试使用 Highcharts.SVGRenderer#text



通常在高仓位工作

Woking小提琴



如果我在angular2-highcharts中使用相同的代码,它不起作用



检查 Plunker

 图表:{
events:{
load:function(){
var charts = this;
charts.renderer.text('Series 1',10,11)
.attr({
rotation:-25
})
.css({
color:'#4572A7',
fontSize:'16px'
})
.add();



$ / code $ / pre

如何使用 renderer.text in angular2 highcharts?

解决方案

最后,我从 chart-events 并修改了我的代码。

  class AppComponent {
构造函数(private http:Http){
http.get('https://cdn.rawgit.com/gevgeny/angular2-highcharts/99c6324d/examples/aapl.json').subscribe( res => {
this.options = {
图表:{
},
标题:{text:'AAPL股价'},
系列:[ {
name:'AAPL',
data:res.json(),
tooltip:{
valueDecimals:2
}
}]
};
});
}
options:Object;
onChartload(e){
e.context.renderer.text('Series 1',100,170)
.attr({
rotation:-25
})
.css({
color:'#4572A7',
fontSize:'16px'
})
.add();


$ b


I am using gevgeny/angular2-highcharts to use highchart in angular project. I am trying to use Highcharts.SVGRenderer#text.

It work in highstock normally

Woking Fiddle

If same code I use in angular2-highcharts it is not working

Check Plunker

Snippet

chart:{
    events:{
       load:function(){
              var charts=this;
               charts.renderer.text('Series 1', 10, 11)
              .attr({
                  rotation: -25
              })
              .css({
                  color: '#4572A7',
                  fontSize: '16px'
              })
              .add();
             }
          }
    },

How I can use renderer.text in angular2 highcharts?

解决方案

Finally I got idea from chart-events and modified my code.

class AppComponent {
    constructor(private http: Http) {
        http.get('https://cdn.rawgit.com/gevgeny/angular2-highcharts/99c6324d/examples/aapl.json').subscribe(res => {
            this.options = {
              chart:{
                  },
                title : { text : 'AAPL Stock Price' },   
                series : [{
                    name : 'AAPL', 
                    data : res.json(), 
                    tooltip: {
                        valueDecimals: 2 
                    }
                }]
            };
        });
    }
    options: Object;
    onChartload (e) {
      e.context.renderer.text('Series 1', 100, 170)
              .attr({
                  rotation: -25
              })
              .css({
                  color: '#4572A7',
                  fontSize: '16px'
              })
              .add();

    }
}

https://plnkr.co/edit/m9Jkg4RrGYvYGrPM64vl?p=preview

这篇关于renderer.text不适用于gevgeny / angular2-highcharts的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆