2016-11-01 4 views
2

Google Charts를 사용하여 대화 형 위젯을 제작하고 있습니다.Google Charts : 파이 차트로 산점도를 대체 할 수 있습니까?

지금은 아래에서 볼 수 있듯이 원형 차트와 산점도가 있습니다.

like this

이 산점도에 대신 파란색 작은 점의 파이 차트를 가지고 싶다,하지만 (심지어 이미지가 될 수 있습니다.

이 작업을 수행하는 방법에 어떤 생각을?

는 연구를하고 4 시간 보내고 내가 그것을 할 수 있도록 할 수있는 모든 작업을 찾지 못했습니다.

+0

저는 금융에 관해서는 전혀 알지 못하지만 공통점이없는 것 같습니다 ...? – zer00ne

+0

그들은 실제로 그 점을 이미지로 대체 할 수는 없지만 어쩌면 그럴 수 있습니까? – brotherperes

+0

분산 형 차트의 [포인트] (https://developers.google.com/chart/interactive/docs/points)는 사각형 및 별처럼 크기와 모양이 수정 될 수 있습니다. – zer00ne

답변

1

일부 디버그?

SCRIPT

<script src="https://www.gstatic.com/charts/loader.js"></script> 

////Callback that draws the scatter 

     function draw0RiskChart() { 
    var data = google.visualization.arrayToDataTable([ 
     ['Risk in %', 'Return in %'], 
     [ 9.87,  6.53] 
    ]); 

    var options = { 
     title: 'Risk vs. Return with 0% Hedge Fund', 
     hAxis: {title: 'Risk', minValue: 5, maxValue: 10}, 
     vAxis: {title: 'Return', minValue: 5, maxValue: 10}, 
     width:400, 
     height:300 
    }; 

    var container = new google.visualization.ScatterChart(document.getElementById('0risk_chart_div')); 
    var chart = new google.visualization.ScatterChart(container); 


    // Wait for the chart to finish drawing before calling the getImageURI() method. 

     google.visualization.events.addListener(chart, 'ready', function() { 
      var layout = chart.getChartLayoutInterface(); 

      container.innerHTML = '<img src="' + chart.getImageURI() + '">'; 

      for (var i = 0; i < data.getNumberOfRows(); i++) { 

      // add image above in every element 

       var xPos = layout.getXLocation(data.getValue(i, 0)); 
       var yPos = layout.getYLocation(data.getValue(i, 1)); 

       var whiteHat = container.appendChild(document.createElement('img')); 
       whiteHat.src = 'http://findicons.com/files/icons/512/star_wars/16/clone_old.png'; 
       whiteHat.className = 'whiteHat'; 

       // 16x16 (image size in this example) 
       whiteHat.style.top = (yPos - 16) + 'px'; 
       whiteHat.style.left = (xPos) + 'px'; 

      } 

      console.log(container.innerHTML); 
     }); 



    chart.draw(data, options); 
    } 

STYLE

.whiteHat { 
    border: none; 
    position: absolute; 
} 

BODY

<div id="0risk_chart_div"></div> 
+0

for (if = i) , 그것은 당신에게 하나의 img와 stop 만 허용 할 것입니다. – zer00ne

+0

제거한 후에도 여전히 작동하지 않습니다. – brotherperes

+0

제거하면 문제가 해결되지는 않지만 깨진 상태로 유지됩니다. – zer00ne

관련 문제