【问题标题】:Setting baseline and range of barchart in Google Charts在 Google Charts 中设置条形图的基线和范围
【发布时间】:2015-10-15 12:14:10
【问题描述】:

我正在绘制一个代表美国凶杀率的条形图。 我试图通过将基线设置为 > 0 来截断此图表,但代码:

    var options = {
      chart: {
        title: 'Intentional homicide rate per 100,000 population, by country/territory (2000-2013) in the US',
        subtitle: 'Intentional homicide is defined as unlawful death purposefully inflicted on a person by another person',
        hAxis: {title: 'Year'},
        vAxis: {
              title: 'Rate per 100,000', 
              viewWindow:{
                max:20,
                min:2
              },
        // ticks: [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100] 
        },
      }
    };

没有完成它的工作,并且显示了与我的目标相反的整个范围。

This 是图表的完整代码。 我错了什么?

同样的过程也适用于面积图 (Pluckr example)...怎么会?

【问题讨论】:

    标签: javascript charts google-visualization bar-chart


    【解决方案1】:

    如其他答案所述,您的代码不正确。

    在处理物料图表时,您需要使用函数google.charts.Bar.convertOptionsSource(向下滚动一点,或者 ctrl + f 转换选项)。

    您目前正在用

    绘制图表
    chart.draw(data, options);
    

    正确的方法是

    chart.draw(data, google.charts.Bar.convertOptions(options));
    

    Working plunker

    (这也是它使用面积图的原因。这不是材料图)。

    【讨论】:

      猜你喜欢
      • 2020-12-10
      • 1970-01-01
      • 2020-10-03
      • 2020-06-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多