【问题标题】:How to change color of text when added column in google chart在谷歌图表中添加列时如何更改文本颜色
【发布时间】:2021-11-01 09:47:18
【问题描述】:

enter image description here

我尝试将文本颜色更改为在图片中用箭头指向的白色,尝试了 annotations.style,但它不起作用。我做错了什么?

    let dataTemperatures = google.visualization.arrayToDataTable([]);
    dataTemperatures.addColumn('datetime', 'Date');
    dataTemperatures.addColumn('number', 'External Temperature');
    dataTemperatures.addColumn('number', 'Dew Point');

    dataTemperatures.addRows(temperature_data);

    let temperature_options = {
        backgroundColor: chartBackgroundColor,
        titleTextStyle: {
            color: textChartColor,
            fontName: fontNameChart
        },
        annotations: {
           textStyle: {color: 'white'}
        },
        hAxis: {
            textStyle: { color: textChartColor },
        },
        vAxis: {
            title: "Temperatures (°C)",
            titleTextStyle: {
                color: textChartColor,
                fontName: fontNameChart
            },
            textStyle: { color: textChartColor },
        },
        series: {
            0: { type: 'line', color: '#1CACDC' },
            1: { type: 'line', color: '#00ffff'  }
        }
    };

【问题讨论】:

    标签: charts google-visualization


    【解决方案1】:

    使用以下选项更改图例

    的文本颜色
    legend: {
      textStyle: {
        color: textChartColor 
      }
    } 
    

    【讨论】:

    • 希望对您有所帮助...
    猜你喜欢
    • 1970-01-01
    • 2016-07-23
    • 1970-01-01
    • 2017-03-01
    • 2018-10-09
    • 1970-01-01
    • 2014-12-31
    • 1970-01-01
    相关资源
    最近更新 更多