简体   繁体   English

如何在谷歌图表中显示大值的小值?

[英]How to show small values with large values in google charts?

You can see in this fiddle 你可以看到这个小提琴

In the year 2004 I have values of 1000, and in the other years I have large values, for that reason in the scale the chart doesn't seems able to rendered, what can I do to show those values. 在2004年,我有1000的价值,而在其他年份我有很大的价值,因此在图表中看起来似乎无法呈现,我可以做些什么来展示这些价值。 I was reading this . 我正在读这个 Is there a way to do something like that in google chart? 有没有办法在谷歌图表中做这样的事情?

Here is the code 这是代码

<html>
  <head>
    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript">
      google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {

  var data = google.visualization.arrayToDataTable([
    ['Year', 'Sales', 'Expenses'],
    ['2004',  1000,      1000],
    ['2005',  1170000,      460000],
    ['2006',  660000,       1120000],
    ['2007',  1030000,      540000]
  ]);

  var options = {
    title: 'Company Performance',
    hAxis: {title: 'Year', titleTextStyle: {color: 'red'}}
  };

  var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));

  chart.draw(data, options);

}
    </script>
  </head>
  <body>
    <div id="chart_div" style="width: 900px; height: 500px;"></div>
  </body>
</html>

The chart 图表

在此输入图像描述

Google Chart´s axis have an option to set scale to logarithm, which fits better for big differences between lowest and highest values. Google Chart的轴可以选择将比例设置为对数,这更适合最低值和最高值之间的巨大差异。 Note that all values must be positive and if the data value is 1, it won´t show as logharithm scale starts at 1 or higher. 请注意,所有值必须为正数,如果数据值为1,则它将不会显示为logharithm scale从1或更高开始。 To change it, use: 要更改它,请使用:

vAxis: {title: 'Year', titleTextStyle: {color: 'red'}, logScale:true}

You can find the documentation in configuration options section: 您可以在配置选项部分找到该文档:

Google Chart Configuration Options Google图表配置选项

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

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