关于使用MsChart的柱状图实现跨年月份限制的问题。

newworld826 2010-12-07 05:22:16
具体情况是这样的:
我用的sql2000数据库,表结构(saletb 表):yearmonth字段为int型。


我目前想实现的功能是用户在前台页面输入的起止日期限制在6个月以内,如果超过这个范围就提示不能查询。特别是牵扯到跨年的问题上,例如2009年10月到2010年3月也是6个月。
请问,有没有什么好的方法来实现?如果可以尽可能写下详细写的用MsChart来实现柱形图的源代码。主要是刚开始学,自己写的代码基本都是野派的,很不规范,而且对MsChart也不熟悉。万分感谢!
...全文
90 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
PitTroll 2010-12-08
  • 打赏
  • 举报
回复

Chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.Interval = 1;
Chart1.ChartAreas["ChartArea1"].AxisX.LabelStyle.Interval = 1;
Chart1.ChartAreas["ChartArea1"].AxisX.LabelAutoFitMaxFontSize = 5;

string sql = "select sale,yearmonth from tb_saletb";//查询财务 SqlDataReader sdr = Common.GetDataReader(sql));//获取读取器,具体代码你可以自己写
if (sdr != null)
{
while (sdr.Read())
{
Chart1.Series["Series1"].Points.AddXY(sdr["yearmonth"].ToString(), sdr["sale"].ToString());//绑定财务
}
sdr.Close();
}
PitTroll 2010-12-08
  • 打赏
  • 举报
回复
<asp:Chart ID="Chart1" runat="server" Palette="None" Width="570px"
BackColor="237, 237, 237" Height="600px">
<Titles>
<asp:Title Name="MainTitles" Text="财务分析图表" Font="Microsoft Sans Serif, 12pt" TextStyle="Frame"></asp:Title>
</Titles>
<Legends>
<asp:Legend ForeColor="Red" Name="caiwu" IsTextAutoFit="true"
Docking="Top"></asp:Legend>
</Legends>
<Series>
<asp:Series Name="Series1" ChartArea="ChartArea1" IsValueShownAsLabel="True"
YValuesPerPoint="4" Color="Red" XValueMember="yearmonth"
YValueMembers="sale" CustomProperties="PointWidth=0.4"
MarkerStyle="Square" Legend="caiwu" IsXValueIndexed="True"
LegendText="财务" ChartType="Column">
</asp:Series>
<ChartAreas>
<asp:ChartArea Name="ChartArea1">
</asp:ChartArea>
</ChartAreas>
</asp:Chart>
阿泰 2010-12-08
  • 打赏
  • 举报
回复
[QUOTE]
我目前想实现的功能是用户在前台页面输入的起止日期限制在6个月以内,如果超过这个范围就提示不能查询。特别是牵扯到跨年的问题上,例如2009年10月到2010年3月也是6个月。
[/QUOTE]

这个需求跟chart没什么关系吧?
你只要在给报表数据之前把这6个月的限制固定住不就可以了吗。。这一步还没到需要chart的环节。

4,820

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 图表区
社区管理员
  • 图表区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧