2012-12-28 3 views
3

버블 차트의 버블 툴팁을 Google API에서 변경하려고합니다.Google Charts API에서 버블 차트의 툴팁 사용자 정의

내 문제를 해결하는 역할 : 툴팁이 이런 종류의 차트에서는 작동하지 않습니다.

지금 내 버블은 문서에 따라 올바른 행의 값에 대한 정보를 보여 주지만 그 정보 만 차트를 그리기 만하면 툴팁으로 문자열을 표시해야합니다. 이 문자열은 형식화해야하는 일부 값으로 구성됩니다.

이 작업을 수행 할 수 있습니까?

레코드의 경우 자바 스크립트로 JSON을 통해 데이터를 제공하기 위해 PHP를 사용하고 있으며 google (https://www.google.com/jsapi)의 최신 API를 사용하고 있습니다.

그들이 지금만큼이 내 열 정의입니다 : 사전에

$data['cols'][] = array('id' => 'ID', 'label' => 'ID', 'pattern' => "", 'type' => 'string'); 
$data['cols'][] = array('id' => 'Fecha', 'label' => 'Fecha', 'pattern' => "", 'type' => 'number'); 
$data['cols'][] = array('id' => 'h', 'label' => 'h', 'pattern' => "", 'type' => 'number'); 
$data['cols'][] = array('id' => 'stringRes', 'label' => 'Valor', 'pattern' => "", 'type' => 'string'); 
$data['cols'][] = array('id' => 'Resultado', 'label' => 'Resultado', 'pattern' => "", 'type' => 'number'); 

감사합니다!

편집 :

사람이 같은 질문을하는 경우, 난 그냥 보여주고 싶지 않았다 필드의 레이블을 삭제하여 내 문제를 해결

[해결] 그게 다야!

나는이 내 열 모델을 변경 :

$data['cols'][] = array('id' => 'ID', 'label' => 'Fecha', 'pattern' => "", 'type' => 'string'); 
$data['cols'][] = array('id' => 'Fecha', 'label' => '', 'pattern' => "", 'type' => 'number'); 
$data['cols'][] = array('id' => 'h', 'label' => '', 'pattern' => "", 'type' => 'number'); 
$data['cols'][] = array('id' => 'stringRes', 'label' => 'Resultado', 'pattern' => "", 'type' => 'string'); 
$data['cols'][] = array('id' => 'Resultado', 'label' => '', 'pattern' => "", 'type' => 'number'); 

감사 @jmac를 내 문제에 대한 몇 가지 접근 방식을 제공합니다.

+0

해결책을 아래 답변에 추가 한 다음 자신의 대답을 "해결 됨"으로 확인하면 문제가 해결 된 것으로 보이고 나중에 다른 사람이 질문/대답을 볼 수 있습니다. – jmac

답변

0

[솔루션]

사람이 같은 질문을하는 경우

, 난 그냥 보여주고 싶지 않았다 필드의 레이블을 삭제하여 내 문제를 해결, 그리고 그것을했다!

나는이 내 열 모델을 변경 :

$data['cols'][] = array('id' => 'ID', 'label' => 'Fecha', 'pattern' => "", 'type' => 'string'); 
$data['cols'][] = array('id' => 'Fecha', 'label' => '', 'pattern' => "", 'type' => 'number'); 
$data['cols'][] = array('id' => 'h', 'label' => '', 'pattern' => "", 'type' => 'number'); 
$data['cols'][] = array('id' => 'stringRes', 'label' => 'Resultado', 'pattern' => "", 'type' => 'string'); 
$data['cols'][] = array('id' => 'Resultado', 'label' => '', 'pattern' => "", 'type' => 'number'); 

감사 @jmac를 내 문제에 대한 몇 가지 접근 방식을 제공합니다.

1

데이터에 setFormattedValue()을 사용하여 값을 사용하여 차트를 그릴 수 있으며 마우스 오버시 다른 숫자가 표시 될 수 있습니다. 데이터를 가져 오는 우리는 형식을 볼 수 없기 때문에, 거기에 우리가 그것을 처리하는 방법을 정확하게 알려 할 수있는 정도가 아니라 여기에 예입니다 : 당신이거야 귀하의 경우에는

var drawVisualizations = function() { 
    // Create and populate a data table. 
    var data = new google.visualization.DataTable(); 
    data.addColumn('string', 'Force'); 
    data.addColumn('number', 'Level'); 

    // Add 2 rows. 
    // google.visualization.DataTable.addRows() can take a 2-dim array of values. 
    data.addRows([['Fire', 1], ['Water', 5]]); 

    // Add one more row. 
    data.addRow(['sand', 4]); 

    // Draw a table with this data table. 
    var originalVisualization = new google.visualization.Table(document.getElementById('original_data_table')); 
    originalVisualization.draw(data); 

    // Clone the data table and modify it a little. 
    var modifiedData = data.clone(); 

    // Modify existing cell. 
    modifiedData.setFormattedValue(1, 1, "one"); 

    // Draw a table with this data table. 
    var modifiedVisualization = new google.visualization.Table(document.getElementById('modified_data_table')); 
    modifiedVisualization.draw(modifiedData); 
} 

데이터 테이블을 순환하고 원하는대로 항목의 서식을 지정하는 함수를 만들어야하지만, 어느 경우이든 숫자로 구성된 것은 한 가지로 표시 할 수 있지만 다른 것으로 표시 할 수 있습니다.

관련 문제