第一次使用水晶报表,柱状图的横竖坐标不会定位,怎么办?-阿里云开发者社区

开发者社区> 数据库> 正文

第一次使用水晶报表,柱状图的横竖坐标不会定位,怎么办?

简介:
 从昨天开始收集了很多制作水晶报表的资料,想自学成材,数据都从来效果了,但是就是柱状图的横竖坐标不会定位,发篇博客,有路过的帮帮忙,谢谢了。
以下是cs代码,
InBlock.gif 1using System; 
InBlock.gif 2using System.Collections; 
InBlock.gif 3using System.Configuration; 
InBlock.gif 4using System.Data; 
InBlock.gif 5using System.Linq; 
InBlock.gif 6using System.Web; 
InBlock.gif 7using System.Web.Security; 
InBlock.gif 8using System.Web.UI; 
InBlock.gif 9using System.Web.UI.HtmlControls; 
InBlock.gif10using System.Web.UI.WebControls; 
InBlock.gif11using System.Web.UI.WebControls.WebParts; 
InBlock.gif12using System.Xml.Linq; 
InBlock.gif13using System.Data.SqlClient; 
InBlock.gif14using CrystalDecisions.CrystalReports.Engine; 
InBlock.gif15using CrystalDecisions.Shared; 
InBlock.gif16 
InBlock.gif17public partial class Teacher_fxlr : System.Web.UI.Page 
InBlock.gif18{ 
InBlock.gif19        string marketid; 
InBlock.gif20        string marketyear; 
InBlock.gif21        protected void Page_Load(object sender, EventArgs e) 
InBlock.gif22        {    
InBlock.gif23                marketid =Session ["marketid"].ToString (); 
InBlock.gif24 
InBlock.gif25        if (!this.IsPostBack) 
InBlock.gif26        { 
InBlock.gif27                yearlist(); 
InBlock.gif28                report(); 
InBlock.gif29                
InBlock.gif30        } 
InBlock.gif31                
InBlock.gif32        } 
InBlock.gif33        protected void report() 
InBlock.gif34        { 
InBlock.gif35 
InBlock.gif36                string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString; 
InBlock.gif37                SqlConnection myconn = new SqlConnection(constr); 
InBlock.gif38                myconn.Open(); 
InBlock.gif39                //marketname--市场名称;marketyear--市场年份;projectname--企业名称,jlr--净利润;xssr--销售收入; 
InBlock.gif40                //zyl--市场占有率=净利润/销售收入,条件是市场编号marketid等于session传的id值,marketyear等于年份的yearradiobutton的选项值。 
InBlock.gif41                string sql = "select marketname,marketyear,projectname,jlr,xssr,convert(varchar(10),(jlr*100/xssr))+'%' as zyl from fxlr where marketid='" + marketid + "' and marketyear='" + marketyear + "'"
InBlock.gif42                SqlDataAdapter myadr = new SqlDataAdapter(sql, myconn); 
InBlock.gif43                lrDataSet ds = new lrDataSet(); 
InBlock.gif44                myadr.Fill(ds, "fxlr"); 
InBlock.gif45                ReportDocument myreport = new ReportDocument(); 
InBlock.gif46                string FilePath = Server.MapPath("fxlr.rpt");//映射到当前目录 
InBlock.gif47 
InBlock.gif48                if (!myreport.IsLoaded) 
InBlock.gif49 
InBlock.gif50                        myreport.Load(FilePath);//加载报表 
InBlock.gif51 
InBlock.gif52 
InBlock.gif53                myreport.SetDataSource(ds); 
InBlock.gif54 
InBlock.gif55                CrystalReportViewer1.ReportSource = myreport; 
InBlock.gif56             
InBlock.gif57        } 
InBlock.gif58        /**//// <summary> 
InBlock.gif59        /// 加载市场年份 
InBlock.gif60        /// </summary> 
InBlock.gif61        protected void yearlist() 
InBlock.gif62        { 
InBlock.gif63                DataOperate DO = new DataOperate(); 
InBlock.gif64                yearbl.Items.Clear(); 
InBlock.gif65                string sql = "select marketyear from market where id='" + marketid + "'"
InBlock.gif66                int yearcount = DO.GetCount(sql); 
InBlock.gif67                //增加初始年 
InBlock.gif68                ListItem LI = new ListItem("初始年""0"); 
InBlock.gif69                yearbl.Items.Add(LI); 
InBlock.gif70                yearbl.Items[0].Selected = true
InBlock.gif71                for (int i = 1; i <= yearcount; i++) 
InBlock.gif72                { 
InBlock.gif73                        LI = new ListItem("第" + i + "年", i.ToString()); 
InBlock.gif74                        yearbl.Items.Add(LI); 
InBlock.gif75                } 
InBlock.gif76        
InBlock.gif77        } 
InBlock.gif78        /**//// <summary> 
InBlock.gif79        /// 点击查看按钮发生的方法。 
InBlock.gif80        /// </summary> 
InBlock.gif81        /// <param name="sender"></param> 
InBlock.gif82        /// <param name="e"></param> 
InBlock.gif83        protected void Button1_Click(object sender, EventArgs e) 
InBlock.gif84        { 
InBlock.gif85                marketyear=yearbl .SelectedValue; 
InBlock.gif86                report(); 
InBlock.gif87                
InBlock.gif88        } 
InBlock.gif89}
我想要的柱状图是按市场年份点击按钮,出现横坐标为企业的名字,纵坐标为企业的占有率
柱状图的是如下图配置的,但是效果不对,我该怎么配呢?
本文转自叶子文文博客51CTO博客,原文链接http://blog.51cto.com/leafwf/185701如需转载请自行联系原作者

叶子文文

版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

分享:
数据库
使用钉钉扫一扫加入圈子
+ 订阅

分享数据库前沿,解构实战干货,推动数据库技术变革

其他文章