2012-12-03 2 views
2
<script> 
    $(function() { 


     var chart = new Highcharts.Chart({ 
      chart: { 
       renderTo: 'container', 
       type: 'funnel', 
       marginRight: 100 
      }, 
      title: { 
       text: 'Sales funnel' 
      }, 
      plotArea: { 
       shadow: null, 
       borderWidth: null, 
       backgroundColor: null 
      }, 
      plotOptions: { 
       series: { 
        dataLabels: { 
         enabled: true, 
         format: '<b>{point.name}</b> ({point.y:,.0f})', 
         color: 'black', 
         softConnector: true 
        }, 
        neckWidth: '30%', 
        neckHeight: '25%' 

        //-- Other available options 
        // height: pixels or percent 
        // width: pixels or percent 
       } 
      }, 
      legend: { 
       enabled: false 
      }, 
      series: [{ 
       name: 'Unique users', 
       data: [ 
        ['Website visits', 15654], 
        ['Downloads',  4064], 
        ['Requested price list', 1987], 
        ['Invoice sent', 976], 
        ['Finalized', 846] 
       ] 
      }] 
     }); 

     // Add the jQuery UI resizin 
     var container = $('#container')[0]; 
     $('#resizer').resizable({ 
      // On resize, set the chart size to that of the 
      // resizer minus padding. If your chart has a lot of data or other 
      // content, the redrawing might be slow. In that case, we recommend 
      // that you use the 'stop' event instead of 'resize'. 
      resize: function() { 
       chart.setSize(
        this.offsetWidth - 20, 
        this.offsetHeight - 20, 
        false 
       ); 
      } 
     }); 
    });​ 
    </script> 

하이 차트를 사용하여 샘플 깔때기 형 차트를 만들었으므로 하이 차트 내보내기 기능을 사용하고 싶지 않습니다. div id를 사용하여 아래 차트의 svg를 가져와야합니다.
아래 코드는이 div의 차트를 렌더링하는 차트의 div 부분입니다. div id를 사용하여 하이 차트 svg를 얻는 방법은 무엇입니까?

<div id="container" style="height: 400px;"> 
    </div> 



    using div id "container" i need to get svg of the chart. 

답변

3

당신이 당신의 chart 인스턴스가있는 경우 사용할 수 있습니다 getSVG라는 방법이있다.

var svg = chart.getSVG();

참조

+0

을 누군가가, 당신은 아마 Highcharts가 getSVG 기능이 없기 때문에 오류가있어 놓치고받을 경우 [ 수출 모듈] (http://www.highcharts.com/docs/export-module/export-module-overview). –

0

사용하여 간단하게 얻을 수 있습니다 $ ('# 컨테이너 .highcharts 컨테이너') HTML().;

이렇게하면 재생할 수있는 전체 svg가 문자열로 제공됩니다.

당신은 또한 highcharts 수출 JS 확장 얻을 다음과 같은 기능

http://api.highcharts.com/highcharts#Chart.getSVG()

1

당신은 컨테이너를 사용 highcharts의 인스턴스를 얻고 다음에 getSVG() 메소드를 호출 할 수 있습니다. 귀하의 질문에 샘플에서, 아래처럼 보일 것이다 :

$('#container').highcharts().getSVG();

참조 http://api.highcharts.com/highcharts#Chart.getSVG

관련 문제