简体   繁体   English

谷歌图表改变侧边框的颜色

[英]Google Charts change color on side box

So I'm using Google Charts and using the Column charts ( https://developers.google.com/chart/interactive/docs/gallery/columnchart ) specifically and I have a question regarding colors on charts.所以我正在使用谷歌图表并使用柱形图https://developers.google.com/chart/interactive/docs/gallery/columnchart ),我对图表上的 colors 有疑问。

Here are two questions :这里有两个问题

  1. Does anyone know how to change the color on the outer box?有谁知道如何改变外包装的颜色? I was able to change the color on the bars to the orange color, but I can't target the outer box.我能够将条上的颜色更改为橙色,但我无法定位外框。

在此处输入图像描述

  1. I am using 'Aug', 7283, 'color: #ff8a73' to define the hex colors on each bar, does anyone know a better way to define colors or is this the proper way?我正在使用'Aug', 7283, 'color: #ff8a73'在每个条上定义十六进制 colors,有谁知道定义 colors 的更好方法还是这是正确的方法?

Here is the JS code:这是JS代码:

google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(sle_interactions);

function sle_interactions() {
    var data = google.visualization.arrayToDataTable([
        ['Year', 'Interactions', { role: 'style' }],
        ['Aug',  7283, 'color: #ff8a73'],
        ['Sep',  8263, 'color: #ff8a73'],
        ['Oct',  9827, 'color: #ff8a73'],
        ['Nov',  9362, 'color: #ff8a73'],
        ['Dec',  10625, 'color: #ff8a73']
    ]);

    var options = {
        title: 'Interactions',
        is3D: true,
        backgroundColor: 'transparent',
        hAxis: {
            title: 'Timeframe',
        }
    };

    var chart = new google.visualization.ColumnChart(document.getElementById('sle_interactions'));
    chart.draw(data, options);
}

document.addEventListener('DOMContentLoaded', sle_interactions);

Both of the questions have been resolved using this:这两个问题都已使用以下方法解决:

var options = {
    title: 'Age Range',
    is3D: true,
    backgroundColor: 'transparent',
    hAxis: {
        title: 'Followers',
    },
    vAxis: {
        minValue: 0,
        maxValue: 100,
        format: "#.#'%'",
    },
    colors: ['#ff8a73'],
};

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

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