最近在学习一个第三方控件webchart,生成柱状图ok,可是柱状图之间的间距太大,见图
怎么让 jan 的红色柱子和蓝色柱子靠在一起?望各位大侠帮帮忙
代码如下:
[code=C#][/code]
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="WebChart" Namespace="WebChart" TagPrefix="Web" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<Web:ChartControl id="Chart1" runat="server" GridLines="Vertical" ToolTip="My chart" Width="508px" Height="338px" EnableViewState="true">
<YAxisFont StringFormat="Far,Near,Character,LineLimit"></YAxisFont>
<XTitle StringFormat="Center,Near,Character,LineLimit"></XTitle>
<XAxisFont StringFormat="Center,Near,Character,LineLimit"></XAxisFont>
<Background Color="LightSteelBlue"></Background>
<ChartTitle StringFormat="Center,Near,Character,LineLimit"></ChartTitle>
<YTitle StringFormat="Center,Near,Character,LineLimit"></YTitle>
</Web:ChartControl>
</div>
</form>
</body>
</html>
[code=C#][/code]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WebChart;
using System.Drawing;
using System.Data;
public partial class _Default : System.Web.UI.Page
{
void Page_Load(object o, EventArgs e)
{
Color themeColor = Color.LightSlateGray;
ConfigureChart(themeColor);
}
private ChartPointCollection CreateRandomData()
{
ChartPointCollection data = new ChartPointCollection();
Random rnd = new Random();
data.Add(new ChartPoint("Jan", rnd.Next(100)));
data.Add(new ChartPoint("Feb", rnd.Next(100)));
return data;
}
private void ConfigureChart(Color themeColor)
{
ColumnChart cl = new ColumnChart(CreateRandomData());
cl.Legend = "User A";
cl.Fill.Color = Color.Red;
cl.MaxColumnWidth = 10;
Chart1.Charts.Add(cl);
ColumnChart cl2 = new ColumnChart(CreateRandomData());
cl2.Legend = "User A";
cl2.Fill.Color = Color.Blue;
cl2.MaxColumnWidth = 10;
Chart1.Charts.Add(cl2);
Chart1.RedrawChart();
}
}
------解决方案--------------------------------------------------------
我也碰到了同样问题,帮顶,期待高手解答
------解决方案--------------------------------------------------------
据我所知,只能够通过对整张报表的大小进行调整,来对柱的大小以及间距进行调整
------解决方案--------------------------------------------------------
把Chart1的width调小点。
------解决方案--------------------------------------------------------
C1WebChart1.Width=800 设置宽度
查查API