Problems about SizeValues!

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Jackey
Newbie
Newbie
Posts: 5
Joined: Fri Nov 15, 2002 12:00 am

Problems about SizeValues!

Post by Jackey » Fri Jan 13, 2006 6:05 am

hi,
i have trouble at change the code from delphi to .net(c#);
the formal code (using TeeChart Pro 7) is:

Code: Select all

dbchart1.Series[s1-cgjl_num+j].AddXY(barwid,sd[i]);
 (dbchart1.Series[s1-cgjl_num+j] as TBarSizeSeries).SizeValues[rslt[j]]:=(ed[i]-sd[i]);
i must translate it into c#(TeeChart for .NET v2 Evaluation):

Code: Select all

WebChart1.Chart.Series[s1-cgjl_num+j].Add(barwid,sd[i]);

(WebChart1.Chart.Series[s1-cgjl_num+j]as Steema.TeeChart.Styles.HorizBar).???);
how to express the ???. or how can i get the result with c#?

Best Regards.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Fri Jan 13, 2006 11:42 am

Hi Jackey,

TBarSizeSeries is a custom series type, isn't it? Thus SizeValues method doesn't exist for other series types. If you are trying to retrieve the horizontal line series values you may use:

Code: Select all

(WebChart1.Chart.Series[s1-cgjl_num+j]as Steema.TeeChart.Styles.HorizBar).XValues.Value[ed[i]-sd[i]];
(WebChart1.Chart.Series[s1-cgjl_num+j]as Steema.TeeChart.Styles.HorizBar)..YValues.Value[ed[i]-sd[i]];
Otherwise, could you please explain what SizeValues method does?
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Jackey
Newbie
Newbie
Posts: 5
Joined: Fri Nov 15, 2002 12:00 am

Post by Jackey » Mon Jan 16, 2006 2:19 am

my code is that ,

Code: Select all

//*****************************画水平柱状图
×××××××××××××××××
//横轴
WebChart1.Chart.Axes.Custom.Add(new Steema.TeeChart.Axis());
			//dbchart1.CustomAxes.Add;
						
int a1 =WebChart1.Chart.Axes.Custom.Count-1;
WebChart1.Chart.Axes.Custom[a1].OtherSide=true;
WebChart1.Chart.Axes.Custom[a1].Horizontal=true;
WebChart1.Chart.Axes.Custom[a1].Automatic=false;
WebChart1.Chart.Axes.Custom[a1].Maximum=100;
WebChart1.Chart.Axes.Custom[a1].Minimum=0;

//WebChart1.Chart.Axes.Custom[a1].Labels.Font.Color=Color.White;
WebChart1.Chart.Axes.Custom[a1].Labels.Font.Color=Color.White;
WebChart1.Chart.Axes.Custom[a1].Ticks.Visible=false;
WebChart1.Chart.Axes.Custom[a1].MinorTicks.Visible=false;
WebChart1.Chart.Axes.Custom[a1].StartPosition=90;
WebChart1.Chart.Axes.Custom[a1].EndPosition=100;
WebChart1.Chart.Axes.Custom[a1].AxisPen.Width=5;
//WebChart1.Chart.Axes.Custom[a1].Labels.Style=Steema.TeeChart.AxisLabelStyle.Auto;
						
// 竖轴
WebChart1.Chart.Axes.Custom.Add(new Steema.TeeChart.Axis());
int a2=WebChart1.Chart.Axes.Custom.Count-1;
WebChart1.Chart.Axes.Custom[a2].OtherSide=false;
WebChart1.Chart.Axes.Custom[a2].Horizontal=false;
WebChart1.Chart.Axes.Custom[a2].Labels.Visible=false;
WebChart1.Chart.Axes.Custom[a2].RelativePosition=100;
WebChart1.Chart.Axes.Custom[a2].AxisPen.Width=5;
WebChart1.Chart.Axes.Custom[a2].Automatic=false;
//WebChart1.Chart.Series[i].CustomHorizAxis=WebChart1.Chart.Axes.Custom[a2];
WebChart1.Chart.Axes.Custom[a2].Inverted=true;
/*************************************
WebChart1.Chart.Axes.Custom[a2].Maximum=2000;
WebChart1.Chart.Axes.Custom[a2].Minimum=1900;
//增加柱状图,不同结论不同序列
			
WebChart1.Chart.Series.Add(new Steema.TeeChart.Styles.HorizBar());
int s1 = WebChart1.Chart.Series.Count;
WebChart1.Chart.Series[s1-1].ShowInLegend=true;
//WebChart1.Chart.Series[s1-1].Title=cgjl[i];
//rslt[i]=0;  
			
s1 = WebChart1.Chart.Series.Count;
WebChart1.Chart.Series[0].Add(100,1990);
//(dbchart1.Series[0] as TBarSizeSeries).SizeValues[rslt[j]]:=(ed[i]-sd[i]);
double a=(WebChart1.Chart.Series[0]as Steema.TeeChart.Styles.HorizBar).XValues.Value[0];
double b=(WebChart1.Chart.Series[0]as Steema.TeeChart.Styles.HorizBar).YValues.Value[1];

							
(WebChart1.Chart.Series[0] as Steema.TeeChart.Styles.HorizBar).Brush.Solid=true;
							
				
WebChart1.Chart.Series[0].Cursor=System.Windows.Forms.Cursors.Hand;
WebChart1.Chart.Series[0].CustomHorizAxis=  WebChart1.Chart.Axes.Custom[a1];
			//计算偏移位置
(WebChart1.Chart.Series[0] as Steema.TeeChart.Styles.HorizBar).OffsetPercent=Convert.ToInt32((5/2-(0+0.5))*100)+50;
//WebChart1.Chart.Series[s1-cgjl_num+i].CustomVertAxis =WebChart1.Chart.Axes.Left;
WebChart1.Chart.Series[0].CustomVertAxis =WebChart1.Chart.Axes.Custom[a2];
this.WebChart1.Chart.Legend.Left=800;
this.WebChart1.Chart.Legend.Top=-320;
this.WebChart1.Chart.Legend.VertSpacing=20;
you can run it ,then you can see:
Image


but i want to get the result like below,which use delphi
Image

Jackey
Newbie
Newbie
Posts: 5
Joined: Fri Nov 15, 2002 12:00 am

Post by Jackey » Mon Jan 16, 2006 2:26 am

i want my HorizBar has the same value ,but diffent size, how can i do get it.
|__________________
|__________________|
|
|
|__________________
| |
| |
|__________________|
|
|____________________________________
0 100

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Jan 17, 2006 4:16 pm

Hi Jackey,

Then I'd suggest you to create your custom series style inheriting from Steema.TeeChart.Styles.HorizBar and overriding its DrawValue method as shown below. To draw different BarStyles you will have to extend the DrawBar method implementing the drawing of the different shapes in TChart's canvas.

Code: Select all

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using Steema.TeeChart.Drawing;
using Steema.TeeChart.Styles;

namespace HorizBarWidth
{
	/// <summary>
	/// Summary description for WebForm1.
	/// </summary>
	public class WebForm1 : System.Web.UI.Page
	{
		protected Steema.TeeChart.Web.WebChart WebChart1;
	
		private void Page_Load(object sender, System.EventArgs e)
		{	
			MyHorizBar HorizBarWidth = new MyHorizBar(WebChart1.Chart);
			HorizBarWidth.FillSampleValues();

			HorizBarWidth.ColorEach=true;
		}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{    
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

	}

	public class MyHorizBar : HorizBar 
	{

		private Steema.TeeChart.Chart chart;

		public MyHorizBar(Steema.TeeChart.Chart Chart) : base(Chart)
		{
			chart = Chart;

			Pen.Visible=false;
			Marks.Visible=false;
		}

		public override void DrawValue(int valueIndex)
		{
			base.DrawValue (valueIndex);			
			NormalBarColor=ValueColor(valueIndex);

			Rectangle r=new Rectangle(0,0,0,0);

			if ( NormalBarColor != Color.Empty )
				r.Y=CalcYPos(valueIndex);

			double Percent = XValues.Value[valueIndex] / MaxXValue();
			if (valueIndex>0)
				r.Height=Convert.ToInt16( (CalcYPos(valueIndex-1)-r.Y) * Percent );
			else
				r.Height=Convert.ToInt16( (r.Y-CalcYPos(1)) * Percent );

			r.X=GetOriginPos(valueIndex);
			System.Drawing.Rectangle Rect=chart.ChartRect;
			r.Width=Rect.Width;

			if ( Pen.Visible && !chart.Aspect.View3D) // CDI changed
				r.Height++;

			iBarBounds=r;

			if (r.Right>r.X) 
				DrawBar(valueIndex,r.X,r.Right);
			else 
				DrawBar(valueIndex,r.Right,r.X);
		}

		private void DrawBar(int barIndex,int startPos,int endPos) 
		{
			Graphics3D g=chart.Graphics3D;

			SetPenBrushBar(NormalBarColor);
			Rectangle r=iBarBounds;

			int tmpMidY=(r.Y+r.Bottom) / 2;
			BarStyles tmp=DoGetBarStyle(barIndex);
			if ( chart.Aspect.View3D )
				switch (tmp) 
				{
					case BarStyles.Rectangle:  g.Cube(startPos,tmpMidY,endPos,r.Bottom,StartZ,EndZ,bDark3D); break;
				}
			else 
			{
				switch (tmp) 
				{
					case BarStyles.Rectangle:   BarRectangle(NormalBarColor,iBarBounds); break;
				}
			}
			DrawTickLines(startPos,endPos,tmp);
		}	

	}
}
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply