javascript - 如何增加 Google Charts 中 y 轴的长度?

标签 javascript graph charts google-visualization

我正在使用 Google 图表。我正在使用的 JavaScript:

function drawChart3() {
    var data3 = google.visualization.arrayToDataTable([
        ['Day', 'Sales','exp'],
        ['4-APRIL-16', 1000,200],
        ['5-APRIL-16', 1170,300],
        ['6-APRIL-16', 660,400],
        ['7-APRIL-16', 1030,500],
        ['8-APRIL-16', 60,4100],
        ['9-APRIL-16', 130,5020],
        ['10-APRIL-16', 60,4100],
        ['11-APRIL-16', 130,5020],
    ]);

    var options3 = {
        title: 'Company Performance',
        curveType: 'function',
        legend: {
            position: 'bottom'
        }
    };

    var chart3 = new  google.visualization.LineChart(document.getElementById('curve_chart'));

    chart3.draw(data3, options3);

如果您看到页面图像,则日期的 y 轴标签未对齐。如何正确对齐它们?

enter image description here

最佳答案

您有两种选择。图表的尺寸将通过以下方式设置:

  • 包含元素的尺寸,或者:
  • 通过在图表选项中设置高度和宽度属性。

下面将向您展示根据您的代码改编的两种方法。

http://jsbin.com/televe/edit?html,css,js,console,output

或者:

#curve_chart {
  width: 200px;
}

var options4 = {
  title: 'Company Performance',
  curveType: 'function',
  height: 400,
  width: 300,
  legend: {
  position: 'bottom'
  }
};

宽度由您决定。

引用: https://developers.google.com/chart/interactive/docs/basic_customizing_chart#specify-options

关于javascript - 如何增加 Google Charts 中 y 轴的长度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37362646/

相关文章:

javascript - 如何基于 JSON 对象使 Vuetify 中的 @click 动态化

javascript - 循环进入 Javascript 对象并显示在表中

javascript - 谷歌图表 API : Add Blank Row to Timeline?

algorithm - 如何在退化树中找到所有从特定顶点开始的均等路径?

javascript - c3js - D3js - 在简单的条形图中自定义标签

笛卡尔坐标系中的 JavaScript/JSF2 数据(矩形)可视化

javascript - Google maps V3 JS 没有发生 "center_changed"来自 UIWebView iOS6(iPhone)

javascript - 有谁知道如何使用cheerio(node.js)获取这个特定值?

python - 如何在 Graph Networkx 中找到具有公共(public)节点的边?

c++ - 查找带权无向图中一定长度的所有路径