Page 1 of 1
Can TChart plot chart like this
Posted: Fri Nov 06, 2009 3:41 pm
by 8119875
Dear All,
I have a sample chart as in the attachment with 4 series. I would like to plot them like as in the attachment and plug-in with colours like this.
Could you please advise if there is any way of doing this. I am doing C# and my TChart version is 1.1.1544.23908
I really appreciate if there is any advice or suggestions.
Regards,
LG
Re: Can TChart plot chart like this
Posted: Fri Nov 06, 2009 4:42 pm
by narcis
Hi Leng,
Yes, this can be easily achieved using multiple Area series in your chart. You'll find similar examples at All Features\Welcome!\Chart Styles\Standard\Area in the features demo. I also recommend you to check out Tutorial 6 - Working with Series which shows how to create and use series in TeeChart and how to customize their colours. Regarding DateTime axes please read Tutorial 4 - Axis Control. Tutorials and features demo can be found at TeeChart's program group.
Hope this helps!
Re: Can TChart plot chart like this
Posted: Fri Nov 06, 2009 11:07 pm
by 8119875
Thank you. I was trying that and the colour in the middle (the blue one) does not really connect to each other nicely when I use origin value. There are white spaces in between even I am trying to connect from the max of the previous series.
I want the blue area seen nicely as the middle area not just like this as in the above posted chart. Could you please advise?
Regards
LG
Re: Can TChart plot chart like this
Posted: Mon Nov 09, 2009 11:12 am
by 10050769
Hello Leng,
I recommend that if isn't necessary use origin in your application, put a
rea1.origin= false and use a
rea1.MultiArea= Steema.TeeChart.Styles.MultiAreas.Stacked. Please see next simple example,try to made a similar code using your data and check if it works as you want.
Code: Select all
private Steema.TeeChart.Styles.Area area1, area2, area3;
private void InitializeChart()
{
tChart1.Dock = DockStyle.Fill;
tChart1.Aspect.View3D = false;
area1 = new Steema.TeeChart.Styles.Area(tChart1.Chart);
area2 = new Steema.TeeChart.Styles.Area(tChart1.Chart);
area3 = new Steema.TeeChart.Styles.Area(tChart1.Chart);
area1.FillSampleValues();
area2.FillSampleValues();
area3.FillSampleValues();
area1.MultiArea = Steema.TeeChart.Styles.MultiAreas.Stacked;
}
If this don't works as you want, please explain exactly how are you want the chart, because we could help you. On the other hand, actually exist new versions improved of version 1, for example version of we works, version 2009 of TeeChart.Net (version 4 of TeeChart .Net).
I hope will helps.
Thanks,
Re: Can TChart plot chart like this
Posted: Mon Nov 09, 2009 11:50 am
by 8119875
Hello Sandra,
Thank you very much. I would like to have the year on X axis and Date (DD/MM) on the Y axis. I have 4 sets of data in which we can use for plotting and I would like to have the result similar to my first message post chart. I was trying the stack but it does not seem to work well. We can remove the week-out from the example chart that I have so that we can use only a single left axis.
I am trying to stack on the top of each other but it does not seem to give the same result as the chart I posted in my first message. Please find the attachment of data and let me know your advice on how that can be done.
Regards,
LG
Re: Can TChart plot chart like this
Posted: Tue Nov 10, 2009 7:01 am
by 8119875
Dear all,
I am trying this code and the chart does not seem to stack on the top of each other very well at all. The value becomes huge on the top and we can see only one colour. It seems to have one colour only as the second series obscure the first one and based on the data they should be stacked on the top each other nicely. Please advise
Code: Select all
private void button1_Click(object sender, System.EventArgs e)
{
Steema.TeeChart.Styles.Area area1 = new Steema.TeeChart.Styles.Area(tChart1.Chart);
Steema.TeeChart.Styles.Area area2 = new Steema.TeeChart.Styles.Area(tChart1.Chart);
DateTime[] adatTR1S = new DateTime[16];
DateTime[] adatTR1E = new DateTime[16];
adatTR1S[0] = DateTime.Parse("13/05/2008");
adatTR1S[1] = DateTime.Parse("11/05/2008");
adatTR1S[2] = DateTime.Parse("14/06/2008");
adatTR1S[3] = DateTime.Parse("14/05/2008");
adatTR1S[4] = DateTime.Parse("16/05/2008");
adatTR1S[5] = DateTime.Parse("13/05/2008");
adatTR1S[6] = DateTime.Parse("26/05/2008");
adatTR1S[7] = DateTime.Parse("28/05/2008");
adatTR1S[8] = DateTime.Parse("11/05/2008");
adatTR1S[9] = DateTime.Parse("18/05/2008");
adatTR1S[10] = DateTime.Parse("19/05/2008");
adatTR1S[11] = DateTime.Parse("17/05/2008");
adatTR1S[12] = DateTime.Parse("13/05/2008");
adatTR1S[13] = DateTime.Parse("23/05/2008");
adatTR1S[14] = DateTime.Parse("19/05/2008");
adatTR1S[15] = DateTime.Parse("23/04/2008");
tChart1.Legend.CheckBoxes =true;
tChart1.Aspect.View3D = false;
area1.Title = "Start";
area2.Title = "END";
//area1.Transparency = 80;
for (int intYear = 1985; intYear <= 2000; intYear++)
{
DateTime dat = adatTR1S[intYear - 1985];
double dblValue = dat.ToOADate();
area1.Add(intYear, dblValue);
area2.Add(intYear, dblValue);
}
area1.YValues.DateTime = true;
area2.YValues.DateTime = true;
area1.MultiArea = Steema.TeeChart.Styles.MultiAreas.Stacked;
area2.MultiArea = Steema.TeeChart.Styles.MultiAreas.Stacked;
area1.AreaLines.Visible = false;
area2.AreaLines.Visible = false;
}
Re: Can TChart plot chart like this
Posted: Tue Nov 10, 2009 9:24 am
by narcis
Dear LG,
The problem here is that you are stacking DateTime values meaning they will sum up and therefore you'll get huge DateTime values. To see both series you should set left axis minimum value like this:
Code: Select all
tChart1.Axes.Left.AutomaticMinimum = false;
tChart1.Axes.Left.Minimum = DateTime.Parse("01/01/1950").ToOADate();
However, a chart stacking DateTime values doesn't make much sense to me. Could you please describe in detail which kind of data your series will have as X and Y values and how would you like them to be plotted or give us more detailed information on what the original image you sent represents and we will try to arrange an example for you?
Thanks in advance.
Re: Can TChart plot chart like this
Posted: Tue Nov 10, 2009 10:01 am
by 8119875
Dear Nacis,
Thank you and now I figured out how to do it by ordering the chart as you said stacking does not really make sense at all.
Another question, I am trying to draw some dot dot line within a line series of a given period and the whole series is still solid line except a few periods only - how can we I plot this?
Regards,
LG
Re: Can TChart plot chart like this
Posted: Wed Nov 11, 2009 4:27 pm
by yeray
Hi LG,
You could do it using two series. In the following example I use the first series to show the solid pen setting some values as null points to hide them. And the second series will show the dotted pen so uses the same values with inverse null properties.
In .NET v2009, setting a point as null will hide two line segment (because we consider that a line segment is the union of two visible points). Then, to hide a line segment I set the desired null points and I add another point in the same position so that the second segment that will be hidden will have the same start and end position (so it won't appear).
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
Steema.TeeChart.Styles.Line line1, line2;
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
line1.FillSampleValues(10);
line1.LinePen.Width = 3;
line1.SetNull(3);
line1.SetNull(5);
int j = 0;
while (j < line1.Count)
{
if (line1.IsNull(j)) line1.Add(line1.XValues[j], line1.YValues[j]);
j++;
}
line2 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
line2.LinePen.Width = line1.LinePen.Width;
line2.LinePen.Style = System.Drawing.Drawing2D.DashStyle.Dot;
line2.ShowInLegend = false;
for (int i = 0; i < line1.Count; i++)
{
if (line1.IsNull(i) || ((i < line1.Count) && (line1.IsNull(i + 1))))
{
line2.Add(line1.XValues[i], line1.YValues[i], line1.Color);
}
else
{
line2.Add(line1.XValues[i], line1.YValues[i], Color.Transparent);
}
}
}