0

我似乎无法让这个 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);
4

1 回答 1

1

来自Google Visualization API Group中的用户asgalant

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

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

jqPlot可能是一个可接受的替代方案。

于 2013-02-27T00:33:47.257 回答