简体   繁体   English

谷歌折线图

[英]Stlying google line chart

I want to use google line charts in my new web project. 我想在新的网络项目中使用Google折线图。 I want to style them like is shown on this picture below in 2th chart below. 我想像下面这张图片在下面的第二张图表中所示对它们进行样式设置。

Could you tell me how to do that if is possible? 你能告诉我怎么做吗?

This is the code which is generating the chart above ( I have intentionally removed some data to make the code smaller ). 这是生成上面图表的代码(我有意删除了一些数据以使代码更小)。

  <script type="text/javascript">
      google.load("visualization", "1", {packages:["corechart"]});
      google.setOnLoadCallback(drawChart);
      function drawChart() {
        var data = google.visualization.arrayToDataTable([
          ['Date', 'Server load'],
           ['Wed Oct 29 08:56:08 CDT 2014', 3.11],
           ['Wed Oct 29 09:04:02 CDT 2014', 1.66],
           ['Wed Oct 29 09:08:02 CDT 2014', 2.76],
           ['Wed Oct 29 09:12:04 CDT 2014', 4.46],
           ['Fri Oct 31 10:16:03 CDT 2014', 0.52],
           ['Fri Oct 31 10:20:02 CDT 2014', 0.36],
           ['Fri Oct 31 10:24:02 CDT 2014', 0.25]
        ]);

        var options = {
          title: 'Server load (48 hours)',
          curveType: 'function',
          vAxis: {minValue:0},
          backgroundColor: '#F2F9FF',
           explorer: { actions: ['dragToZoom', 'rightClickToReset'] },
           fontName: 'Verdana',
           legend: 'none'
        };

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

        chart.draw(data, options);
      }
    </script>
    <div id="chart_div" style="width: 950px; height: 180px;"></div>

在此处输入图片说明

You could apply the border with backgroundColor.stroke. 您可以使用backgroundColor.stroke来应用边框。 It appears that hAxis could be used to style your dates. 似乎可以使用hAxis设置日期样式。 You can specify solid or dotted grid lines on your chart using the chg parameter. 您可以使用chg参数在图表上指定实心或虚线网格线。 This parameter doesn't let you specify the thickness or color of the lines. 此参数不允许您指定线条的粗细或颜色。 For more ways to make lines across your chart, see shape markers (chm type h, H, v, or V), range markers (chm), and axis tick marks (chxtc). 有关在图表上绘制线条的更多方法,请参见形状标记(chm类型h,H,v或V),范围标记(chm)和轴刻度线(chxtc)。

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

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