Charts 具有不匹配x值的多条连续线在图形中留下间隙

Charts 具有不匹配x值的多条连续线在图形中留下间隙,charts,google-visualization,Charts,Google Visualization,我使用谷歌图表来可视化日期值对。并非所有日期的值都存在,所以我希望用空值填充。但这在图表中留下了空白(红线): 如何获得没有任何跳跃的折线图 我的代码: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <

我使用谷歌图表来可视化日期值对。并非所有日期的值都存在,所以我希望用空值填充。但这在图表中留下了空白(红线):

如何获得没有任何跳跃的折线图

我的代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <title>
      Google Visualization API Sample
    </title>
    <script type="text/javascript" src="//www.google.com/jsapi"></script>
    <script type="text/javascript">
      google.load('visualization', '1', {packages: ['corechart']});
    </script>
    <script type="text/javascript">
      function drawVisualization() {
        // Create and populate the data table.
        var data = google.visualization.arrayToDataTable([
          ['x', 'Cats', 'Blanket 1', 'Blanket 2'],
          [new Date(2012),   1,       1,           0.5],
          [new Date(2013),   1,       1,           0.5],
          [new Date(2014),   2,       null,         1],
          [new Date(2015),   4,       2,           0.5],
          [new Date(2016),   4,       3,           0.5],
        ]);

        // Create and draw the visualization.
        new google.visualization.LineChart(document.getElementById('visualization')).
            draw(data, {curveType: "function",
                        width: 500, height: 400,
                        vAxis: {maxValue: 10}}
                );
      }


      google.setOnLoadCallback(drawVisualization);
    </script>
  </head>
  <body style="font-family: Arial;border: 0 none;">
    <div id="visualization" style="width: 500px; height: 400px;"></div>
  </body>
</html>

谷歌可视化API示例
load('visualization','1',{packages:['corechart']});
函数drawVisualization(){
//创建并填充数据表。
var data=google.visualization.arrayToDataTable([
['x'、'猫'、'毛毯1'、'毛毯2'],
[新日期(2012年),1,1,0.5],
[新日期(2013年),1,1,0.5],
[新日期(2014年),2,空,1],
[新日期(2015年),4,2,0.5],
[新日期(2016年),4,3,0.5],
]);
//创建并绘制可视化。
新的google.visualization.LineChart(document.getElementById('visualization'))。
绘制(数据,{curveType:“函数”,
宽:500,高:400,
变量:{maxValue:10}
);
}
setOnLoadCallback(drawVisualization);

谢谢jmac!用true替换null正是我所需要的:


相关(这将解决您的问题):或者,您可以将它们保留为null,并将
interpolateNulls
选项设置为
true
      ['x', 'Cats', 'Blanket 1', 'Blanket 2'],
      [new Date(2012),   1,       1,           0.5],
      [new Date(2013),   1,       1,           0.5],
      [new Date(2014),   2,       true,         1],
      [new Date(2015),   4,       2,           0.5],
      [new Date(2016),   4,       3,           0.5],