折线图中的背景色 [英] background color in line graph

查看:134
本文介绍了折线图中的背景色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用下面的附加代码在折线图中放置背景色....

how can i put background color in line graph using below attached code....

private void chart_bind()
{
  DataTable dt = new DataTable();
  try
  {
      dt = GetData();

      str.Append(@"<script type=text/javascript> google.load( *visualization*, *1*, {packages:[*corechart*]});
      google.setOnLoadCallback(drawChart);
      function drawChart() {
      var data = new google.visualization.DataTable();
      data.addColumn('string', 'time');
      data.addColumn('number', 'price');
      data.addRows(" + dt.Rows.Count + ");");

      Int32 i;

      for (i = 0; i <= dt.Rows.Count - 1; i++)
      {
          str.Append("data.setValue( " + i + "," + 0 + "," + "'" + dt.Rows[i]["time"].ToString() + "');");
          str.Append("data.setValue(" + i + "," + 1 + "," + dt.Rows[i]["price"].ToString() + ") ;");
      }

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

      str.Append(" chart.draw(data, {width: 660, height: 300,title: '',");
      str.Append("hAxis: {title: 'Time', titleTextStyle: {color: 'green'}}");
      str.Append("}); }");
      str.Append("</script>");
      lt.Text = str.ToString().TrimEnd(',').Replace('*', '"');
  }
  catch
  { }
}

推荐答案

您需要在选项内添加颜色.我相信下面的方法会起作用.
You need to add the color inside options. Something like below would work I believe.
str.Append(" chart.draw(data, {backgroundColor: 'black', width: 660, height: 300,title: '',");


请参考-更改Google图表(Google可视化)图的背景颜色 [


Refer - Changing background colour of a Google Charts (Google Visualization) Graph[^].


这篇关于折线图中的背景色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆