无法在Google Scatter Chart中显示标签

时间:2013-02-26 16:59:07

标签: javascript google-visualization scatter-plot

我似乎无法获得此Google Chart Scatter Plot以将score.partner显示为标签。我只能将它们显示为工具提示。

我做错了什么?

drawChart: function() {
    var self = this;

    var gdpMin = parseFloat(self.scores[0].gdpScore);
    var gdpMax = gdpMin;
    var teaMin = parseFloat(self.scores[0].teaScore);
    var teaMax = teaMin;

    var data = new google.visualization.DataTable();
    data.addColumn('number', 'GDP Score');
    data.addColumn('number', 'TEA Score');
    data.addColumn({type:'string', role:'label'});

    $.each(self.scores, function(i, score) {
        gdpScore = parseFloat(score.gdpScore);
        teaScore = parseFloat(score.teaScore);
        data.addRows([[gdpScore, teaScore, score.partner]]);

if (gdpScore < gdpMin) gdpMin = gdpScore;
        if (gdpScore > gdpMax) gdpMax = gdpScore;

if (teaScore < teaMin) teaMin = teaScore;
        if (teaScore > teaMax) teaMax = teaScore;
    });

    var options = {
      title: 'GDP and TEA Scores',
      hAxis: {title: 'GDP', minValue: gdpMin, maxValue: gdpMax},
      vAxis: {title: 'TEA', minValue: teaMin, maxValue: teaMax},
      legend: 'none',
      colors: ['#3B7CBF']
    };

    var chart = new google.visualization.ScatterChart(document.getElementById('chart_div'));
    chart.draw(data, options);

1 个答案:

答案 0 :(得分:1)

来自Google Visualization API Group中的用户 asgallant

  

您想在ScatterChart上标记各个点吗? 不是   支持。根据您的数据结构,您可能会   以类似于ScatterChart的方式使用LineChart。见   例如:jsfiddle.net/asgallant/YFMga /

你有它。使用Google Visualization API的散点图不支持标签。

jqPlot可能是一种可接受的选择。