javascript - 谷歌图表 - 图例

标签 javascript google-visualization

我想更改我的图例,我必须删除分页并将所有标题放在一两行中。我想更改图标。

现在是这个样子

我想要这样的东西

enter image description here

我输入了 scrollArrows: 'none' 但它不起作用。 这是我在 Controller 中的代码:

var optionsMobile = {
width: '100%',
height: '100%',
pointSize: 5,
series: {
    pointShape: 'circle'
},
chartArea: {
    width: '80%',
    height: '70%'
},
legend: {
    position: 'bottom',
    textStyle: {
        color: 'white'
    },
    pagingTextStyle: { color: '#666' },
    scrollArrows: 'none'
},
backgroundColor: 'transparent',
titleTextStyle: {
    color: 'white',
    height: "40px"
},
hAxis: {
    textStyle: {
        color: 'white'
    }
},
vAxis: {
    textStyle: {
        color: 'white'
    }
},
};

最佳答案

根据configuration options ...

Set legend.maxLines to a number greater than one to add lines to your legend.
This option currently works only with legend.position: 'top'
Note: The exact logic used to determine the actual number of lines rendered is still in flux.

var options = {
  legend: {
    maxLines: 2,
    position: 'top'
  }
};

请参阅以下工作片段...

google.charts.load('current', {
    packages: ['corechart']
}).then(function () {
  var data = google.visualization.arrayToDataTable([
    ['x', 'NYCLS 2016 Boys', 'NYCLS 2016 Girls', 'NYCLS 2017 Boys', 'NYCLS 2017 Girls'],
    [1, 10, 15, 20, 25],
    [2, 12, 18, 24, 30],
    [3, 14, 21, 28, 35],
    [4, 16, 24, 32, 40]
  ]);

  var options = {
    legend: {
      maxLines: 2,
      position: 'top'
    },
    width: 360
  };

  var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
  chart.draw(data, options);
});
<script src="https://www.gstatic.com/charts/loader.js"></script>
<div id="chart_div"></div>

关于javascript - 谷歌图表 - 图例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46724606/

相关文章:

javascript - 仅消除双斜线和附加斜线并用一个斜线替换

angular - Google 图表无法在 Materialise Accordion 中工作

javascript - 谷歌图表趋势线

javascript - 在元素属性中像函数一样使用 AngularJS 2 Component

javascript - 是否可以在不刷新页面/使用和更新面板的情况下在转发器中填充更新的数据?

javascript - 计算特定 div 中表中的可见行数

jquery - 带选项卡的 Google 图表 - 图表区域不正确

javascript - 使用 googleVis 和 R 的基于订阅的网站的 Web 开发建议

javascript - 在 Google 折线图中将单个点设置为事件/显示点和工具提示

javascript - 是否可以从用户那里获取最后 2 个、甚至 3 个 URL?类似于 document.referrer