[MSCHART]Stacked与多组柱状图

1.通常会按区域或者产品分月显示百分比的效果图:

[MSCHART]Stacked与多组柱状图_第1张图片

后台代码:

   private void Stacked(DataTable dt) 
    {
        this.Chart2.Width = 540;
        this.Chart2.Height = 350;
        DataTable mdt = new DataTable();
        mdt = DataTableConvert.Transpose(dt,"区间");// DataTableUpdated(dt);
       
      this.Chart2.DataSource = mdt;
      this.Chart2.DataBind();
      this.Chart2.Series["Series1"].ChartType = SeriesChartType.Column;
      this.Chart2.Series["Series1"].XValueMember = "区间";
      this.Chart2.Series["Series1"].YValueMembers = "NAZ Subtotal";
      this.Chart2.Series["Series2"].XValueMember = "区间";
      this.Chart2.Series["Series2"].YValueMembers = "渠道 ";
      this.Chart2.Series["Series3"].XValueMember = "区间";
      this.Chart2.Series["Series3"].YValueMembers = "国内-厦门";
      this.Chart2.Series["Series4"].XValueMember = "区间";
      this.Chart2.Series["Series4"].YValueMembers = "国内-广东";
      this.Chart2.Series["Series5"].XValueMember = "区间";
      this.Chart2.Series["Series5"].YValueMembers = "国内-上海";
      this.Chart2.Series["Series6"].XValueMember = "区间";
      this.Chart2.Series["Series6"].YValueMembers = "AZ Subtotal";

        string chartTypeName = "StackedColumn100";
        Chart2.Series["Series1"].ChartType = (SeriesChartType)Enum.Parse(typeof(SeriesChartType), chartTypeName, true);
        Chart2.Series["Series2"].ChartType = (SeriesChartType)Enum.Parse(typeof(SeriesChartType), chartTypeName, true);
        Chart2.Series["Series3"].ChartType = (SeriesChartType)Enum.Parse(typeof(SeriesChartType), chartTypeName, true);
        Chart2.Series["Series4"].ChartType = (SeriesChartType)Enum.Parse(typeof(SeriesChartType), chartTypeName, true);
        Chart2.Series["Series5"].ChartType = (SeriesChartType)Enum.Parse(typeof(SeriesChartType), chartTypeName, true);
        Chart2.Series["Series6"].ChartType = (SeriesChartType)Enum.Parse(typeof(SeriesChartType), chartTypeName, true);

        Chart2.Series["Series1"].IsValueShownAsLabel = true;
        Chart2.Series["Series2"].IsValueShownAsLabel = true;
        Chart2.Series["Series3"].IsValueShownAsLabel = true;
        Chart2.Series["Series4"].IsValueShownAsLabel = true;
        Chart2.Series["Series5"].IsValueShownAsLabel = true;
        Chart2.Series["Series6"].IsValueShownAsLabel = true;
        //显示类别
        Chart2.Legends[0].Enabled = true;
        Chart2.Series["Series1"].LegendText = dt.Rows[0][0].ToString();
        Chart2.Series["Series2"].LegendText = dt.Rows[1][0].ToString();
        Chart2.Series["Series3"].LegendText = dt.Rows[2][0].ToString();
        Chart2.Series["Series4"].LegendText = dt.Rows[3][0].ToString();
        Chart2.Series["Series5"].LegendText = dt.Rows[4][0].ToString();
        Chart2.Series["Series6"].LegendText =dt.Rows[5][0].ToString ();
        //X轴的数值间隔
        Chart2.ChartAreas["ChartArea1"].AxisX.Interval = 1;
        Chart2.ChartAreas["ChartArea1"].AxisX.Title = "月份";
    }

二.分组柱状图呢?

[MSCHART]Stacked与多组柱状图_第2张图片

后台代码:

    private void MutiColumn(DataTable dt) 
    {
        this.ChartYear.Width = 540;
        this.ChartYear.Height = 350;     
        this.ChartYear.DataSource = dt;
        this.ChartYear.DataBind();
        this.ChartYear.Series["Series1"].ChartType = SeriesChartType.Column;
        this.ChartYear.Series["Series1"].XValueMember = "区间";
        this.ChartYear.Series["Series1"].YValueMembers = "NAZ Subtotal";
        this.ChartYear.Series["Series2"].XValueMember = "区间";
        this.ChartYear.Series["Series2"].YValueMembers = "渠道 ";
        this.ChartYear.Series["Series3"].XValueMember = "区间";
        this.ChartYear.Series["Series3"].YValueMembers = "国内-厦门";
        this.ChartYear.Series["Series4"].XValueMember = "区间";
        this.ChartYear.Series["Series4"].YValueMembers = "国内-广东";
        this.ChartYear.Series["Series5"].XValueMember = "区间";
        this.ChartYear.Series["Series5"].YValueMembers = "国内-上海";
         this.ChartYear.Series["Series6"].XValueMember = "区间";
         this.ChartYear.Series["Series6"].YValueMembers = "AZ Subtotal";
     
        //显示数据
        //ChartYear.Series["Series1"].IsValueShownAsLabel = true;
    
        //this.ChartYear.ChartAreas["ChartArea1"].AxisX.Title = "产品类型";
        this.ChartYear.ChartAreas["ChartArea1"].AxisY.Title = "销售金额";

        //显示类别
        ChartYear.Legends[0].Enabled = true;
        ChartYear.Series["Series1"].LegendText = mydt.Rows[0][0].ToString();
        ChartYear.Series["Series2"].LegendText = mydt.Rows[1][0].ToString();
        ChartYear.Series["Series3"].LegendText = mydt.Rows[2][0].ToString();
        ChartYear.Series["Series4"].LegendText = mydt.Rows[3][0].ToString ();
        ChartYear.Series["Series5"].LegendText = mydt.Rows[4][0].ToString();
        ChartYear.Series["Series6"].LegendText = mydt.Rows[5][0].ToString();


        //背景色设置
        this.ChartYear.ChartAreas["ChartArea1"].ShadowColor = Color.Transparent;
        this.ChartYear.ChartAreas["ChartArea1"].BackColor = Color.FromArgb(209, 237, 254);         //该处设置为了由天蓝到白色的逐渐变化
        this.ChartYear.ChartAreas["ChartArea1"].BackGradientStyle = GradientStyle.TopBottom;
        this.ChartYear.ChartAreas["ChartArea1"].BackSecondaryColor = Color.White;

        //中间X,Y线条的颜色设置
        this.ChartYear.ChartAreas["ChartArea1"].AxisX.MajorGrid.LineColor = Color.FromArgb(64, 64, 64, 64);
        this.ChartYear.ChartAreas["ChartArea1"].AxisY.MajorGrid.LineColor = Color.FromArgb(64, 64, 64, 64);
        //X.Y轴数据显示间隔
        ChartYear.ChartAreas["ChartArea1"].AxisX.Interval = 1;

    }

HTML:

    
	
        
		
    
        
			
									
		
		
			
			
			
			
            
			
		
		
			
				
				
				
					
					
				
				
					
					
				
			
		
	
    
            
            
		
        
            
			            
		    
        
            
            
          
            
           
            
          
            
           
            
          
            
        
        
            
            
        
    




 

你可能感兴趣的:(数据库管理(ORC/SQL),报表-图表,ERP-鼎捷,Sql,Server,MsChart)