【问题标题】:How do I show x axis labels in a Google LinChart如何在 Google LinChart 中显示 x 轴标签
【发布时间】:2015-07-01 03:36:34
【问题描述】:

我正在尝试使用 Google 图表为我的应用呈现折线图。事情大多有效,我得到以下信息:

剩下的一个问题是我只得到一个 x 轴标签。 (12:00)。

我想显示更多的 x 轴标签,所以我尝试添加一个网格线属性:

    // Line chart visualization
    var myLine = new google.visualization.ChartWrapper({
        'chartType': 'LineChart',
        'containerId': 'line_div'
    });

    myLine.setOptions({
        'title': 'My Chart',
        lineWidth: 1,
        colors: ['#006600', '#FF0000'],
        vAxes: [
            {title: 'AAA', titleTextStyle: {color: '#000000'}}, // Left axis
            {title: 'BBB', titleTextStyle: {color: '#000000'}} // Right axis
        ],
        hAxis: {
            format: 'hh:mm',
            gridlines: {count: 20}
        },
        series: [
            {targetAxisIndex: 1},
            {targetAxisIndex: 0}
        ]
    });

但运气不好,它仍然只显示一个标签,没有 x 轴网格线。

如何获得更多的 x 轴标签?

【问题讨论】:

    标签: javascript google-visualization


    【解决方案1】:

    问题原来是我如何填充我的数据表。我正在使用:

    dataTable.addColumn({type: 'date', label: 'Date'})
    

    因为在我看来 new Date() 是一个日期。谷歌图表有不同的意见,所以我需要做的是:

    dataTable.addColumn({type: 'datetime', label: 'Date'})
    

    然后排序。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-01-08
      • 1970-01-01
      • 2015-11-05
      • 2021-01-04
      • 1970-01-01
      • 2020-11-20
      • 1970-01-01
      • 2020-10-24
      相关资源
      最近更新 更多