简体   繁体   English

Google图表-更改“更多”链接的颜色

[英]Google Charts - Change the color of the 'more' link

I've made a couple of charts (pie and bar) and due to space limitations they needed to be re-sized which resulted in the addition of a "1/2 ▼" for the legend part. 我制作了几张图表(饼图和条形图),由于篇幅所限,它们需要重新调整大小,因此图例部分增加了“ 1/2▼”。

I added my code here: http://codepen.io/qtx/pen/EtHvi And in case my problem doesn't show up correctly here is a screenshot from my site, http://i.imgur.com/YJbm6jK.png with a circle around what I want to change. 我在这里添加了代码: http : //codepen.io/qtx/pen/EtHvi如果我的问题没有正确显示,这里是我网站http://i.imgur.com/YJbm6jK的屏幕截图围绕我要更改的圆圈的png (it also shows up in the bar chart if I go beyond 8 columns, like in the above example) (如果我超出了8列,它也会显示在条形图中,就像上面的示例一样)

So my question, is there any way I can change the color of that text/link? 所以我的问题是,有什么办法可以更改文本/链接的颜色? I can't seem to find anything online or in the api docs. 我似乎无法在线或在api文档中找到任何内容。

Any help would be greatly appreciated. 任何帮助将不胜感激。

    <script type="text/javascript">

      // Load the Visualization API and the piechart package.
      google.load('visualization', '1.0', {'packages':['corechart']});

      // Set a callback to run when the Google Visualization API is loaded.
      google.setOnLoadCallback(drawChart);

      // Callback that creates and populates a data table,
      // instantiates the pie chart, passes in the data and
      // draws it.
      function drawChart() {

        // Create the data table.
        var data = new google.visualization.arrayToDataTable([
        ['Task', 'Hours per Day'],
        ['Set 1', 215],
        ['Set 2', 83],
        ['Set 3', 132],
        ['Set 4', 72],
        ['Set 5', 260],
        ['Set 6', 34],
        ['Set 7', 9],
        ['Set 8', 24]
        ]);
        // Create the data table.
        var data2 = new google.visualization.arrayToDataTable([
        ['Genre', 'Set 1', 'Set 2', 'Set 3', 'Set 4', 'Set 5', 'Set 6', 'Set 7','Set 8',{ role: 'annotation' } ],
        ['18/7', 0, 0, 0, 0, 0, 0, 0, 2, ''],
        ['23/7', 0, 0, 0, 0, 0, 0, 0, 1, ''],
        ['24/7', 0, 0, 0, 0, 0, 0, 0, 4, ''],
        ['26/7', 0, 0, 0, 0, 0, 0, 0, 4, ''],
        ['29/7', 0, 0, 0, 0, 260, 0, 0, 0, ''],
        ['31/7', 0, 0, 0, 0, 0, 0, 0, 1, ''],
        ['2/8', 0, 0, 0, 0, 0, 0, 9, 0, ''],
        ['3/8', 0, 0, 132, 0, 0, 0, 0, 0, ''],
        ['4/8', 0, 0, 0, 0, 0, 0, 0, 11, ''],
        ['8/8', 0, 0, 0, 0, 0, 0, 0, 0, ''],
        ['13/8', 0, 83, 0, 0, 0, 0, 0, 0, ''],
        ['14/8', 215, 0, 0, 0, 0, 0, 0, 0, ''],
        ['15/8', 0, 0, 0, 72, 0, 0, 0, 0, ''],
        ['16/8', 0, 0, 0, 0, 0, 34, 0, 0, ''],
        ]);

        // Set chart options
        var options = {
        title: '% of photos', fontSize: '12', backgroundColor: "transparent",
        colors: ['#F56363', '#eda15f', '#40C1A0', '#FFD586', '#81CFE0', '#fcfcfc', '#A06C90', '#FFCAD1'],
        };
        // Set chart options
        var options2 = {
        title: '# of photos', backgroundColor: "transparent",
        colors: ['#F56363', '#eda15f', '#40C1A0', '#FFD586', '#81CFE0', '#fcfcfc', '#A06C90', '#FFCAD1'],
        legend: { position: 'bottom', maxLines: 3 },
        bar: { groupWidth: '99%' },
        isStacked: true,
        };

        // Instantiate and draw our chart, passing in some options.
        var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
        chart.draw(data, options);
        var chart2 = new google.visualization.ColumnChart(document.getElementById('chart_div2'));
        chart2.draw(data2, options2);

      }
    </script>

Thank you for your time. 感谢您的时间。

While there's probably a way to do it programmatically, you can target the element with CSS: 尽管可能有一种编程方式可以实现,但是您可以使用CSS定位元素:

<style>
    path[d="M811,150L823,150L817,162Z"] {fill: purple;}

or simply 或简单地

    path[d^="M811"] {fill: purple;}
</style>

You can use legend.scrollArrows.activeColor and legend.scrollArrows.inactiveColor to set these. 您可以使用legend.scrollArrows.activeColorlegend.scrollArrows.inactiveColor进行设置。 legend.pagingTextStyle.color is also available. legend.pagingTextStyle.color也可用。

In your case it would be something like: 在您的情况下,它将类似于:

var options2 = {
        title: '# of photos', backgroundColor: "transparent",
        colors: ['#F56363', '#eda15f', '#40C1A0', '#FFD586', '#81CFE0', '#fcfcfc', '#A06C90', '#FFCAD1'],
        legend: { position: 'bottom', maxLines: 3, scrollArrows: { inactiveColor: "red", activeColor: "red" } },
        bar: { groupWidth: '99%' },
        isStacked: true
};

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM