2017-12-13 13 views
0

각도 프로젝트에서 하이 차트를 사용하려면 gevgeny/angular2-highcharts을 사용하고 있습니다. Highcharts.SVGRenderer#text을 사용하려고합니다. 일반적으로 내가 angular2-highcharts에서 사용하는 동일한 코드 그것이renderer.text가 gevgeny/angular2-highcharts에서 작동하지 않습니다.

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

어떻게

확인 Plunker

코드 조각을

Woking Fiddle

작동하지 않는 경우

그것은 highstock에서 작동 나는 우리 수있다. angular2 highcharts에 e renderer.text?

답변

0

마지막으로 나는 chart-events에서 아이디어를 얻었고 코드를 수정했습니다.

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