renderer.text not working in gevgeny/angular2-high

2019-08-28 20:23发布

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?

1条回答
相关推荐>>
2楼-- · 2019-08-28 20:56

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

查看更多
登录 后发表回答