:?: How to centrally align Marks in a stacked bar chart

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Unger
Newbie
Newbie
Posts: 6
Joined: Sat Dec 06, 2003 5:00 am
Location: NY
Contact:

:?: How to centrally align Marks in a stacked bar chart

Post by Unger » Tue Jun 22, 2004 4:23 pm

Hi,
I'm trying to centrally align the marks in a stacked bar chart for each bar stack (the actual alignment is on top of the bar) and have not been able to find out a solution for this.
Does anybody know how to do it. I've tried using the
series.AutoMarkPosition = true; but it didn't work.

I was able to re-position the marks by setting
series.Marks.ArrowLength to a -ve value but there are 2 problems over here with this.
1. How do I set the arrowlenth so that the mark position is at the center of each bar series ( the height of the individual bars could be different)?
2. How do I make the line invisible which is displayed along with the mark?

Any ideas or solutions would be greatly appreciated.
Thanks
Unger

Marjan
Site Admin
Site Admin
Posts: 745
Joined: Fri Nov 07, 2003 5:00 am
Location: Slovenia
Contact:

Post by Marjan » Thu Jun 24, 2004 3:00 pm

Hi.

The best solution is to custom position each series bar after series is drawn. The following code should do the trick:

Code: Select all

    private void RepositionMarks(Steema.TeeChart.Styles.Series series)
    {
      Steema.TeeChart.Styles.SeriesMarks.Position pos;
      series.Chart.AutoRepaint = false;
      for (int i=0;  i<series.Count; i++)
      {
        pos = series.Marks.Positions[i];
        pos.Custom = true;
        pos.LeftTop.Y = series.CalcYPosValue(series.YValues[i]/2);
        pos.ArrowTo.Y = pos.LeftTop.Y;
        pos.ArrowFrom.Y = pos.LeftTop.Y;
      }
      series.Chart.AutoRepaint = true;
      series.Chart.Invalidate();
    }
Place this code in appropriate chart events to reposition the marks. Of course, you can develop this further and add custom position for x coordinates (so that marks will follow zoom/scroll operation), but the basic idea is the same : calculate the position for each series mark and adjust it's position on screen.
Marjan Slatinek,
http://www.steema.com

Unger
Newbie
Newbie
Posts: 6
Joined: Sat Dec 06, 2003 5:00 am
Location: NY
Contact:

Query

Post by Unger » Fri Jun 25, 2004 3:28 pm

Hi,
Thanks for posting the code. I tried implementing the code in my web project in different events like BeforeDraw (the position value is not available in this event as the graph has not been drawn yet so it failed in this event), AfterDraw ( the code executes but does not reposition the marks for me) also tried PreRender event but the same result did not reposition the marks.
I can't even put the code where I'm drawing the series as the position values are not available there too.
I was wandering where I've to put this code (any specific event ? ) any advice would be of immense help to solve my problem and get ready for the demo. I don’t have the drag or zoom features for the graph.

I also had to make some changes to the code and the code is as under. Just added index i to series marked in red

private void RepositionMarks()
{
Steema.TeeChart.Styles.SeriesMarks.Position pos;
tChart1.Chart.AutoRepaint=false;
tChart1.Chart.Series.Chart.AutoRepaint = false;
for (int i=0; i<tChart1.Chart.Series.Count; i++)
{
pos = tChart1.Chart.Series.Marks.Positions;
pos.Custom = true;
pos.LeftTop.Y = tChart1.Chart.Series.CalcYPosValue(tChart1.Chart.Series.YValues/2);
pos.ArrowTo.Y = pos.LeftTop.Y;
pos.ArrowFrom.Y = pos.LeftTop.Y;
}
tChart1.Chart.Series.Chart.AutoRepaint = true;
tChart1.Chart.Series.Chart.Invalidate();

}
Thanks
Unger

Pep
Site Admin
Site Admin
Posts: 3274
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Fri Jul 02, 2004 4:44 pm

Hi Unger,

have you tried calling the RepositionMarks function in the OnAfterDraw event but also adding the Refresh method after the Marks has been positioned ? :

Code: Select all

pos.LeftTop.Y = tChart1.Chart.Series[i].CalcYPosValue(tChart1.Chart.Series[i].YValues[i]/2); 
pos.ArrowTo.Y = pos.LeftTop.Y; 
pos.ArrowFrom.Y = pos.LeftTop.Y; 
} 
tChart1.Refresh();
			

Unger
Newbie
Newbie
Posts: 6
Joined: Sat Dec 06, 2003 5:00 am
Location: NY
Contact:

mothod refresh() :?

Post by Unger » Mon Jul 19, 2004 8:34 pm

Hi,
:? There is no Refresh() method for the chart in the assembly for a web application (asp.net application).

Unger

Pep
Site Admin
Site Admin
Posts: 3274
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Mon Jul 26, 2004 2:21 pm

Hi Unger,

I've attached one example of this into the steema.public.attachments newsgroup. Could you please test it ?

Unger
Newbie
Newbie
Posts: 6
Joined: Sat Dec 06, 2003 5:00 am
Location: NY
Contact:

Post by Unger » Mon Aug 02, 2004 7:56 pm

Hi Pep,
:oops: I've been unable to find the example posted by you. Infact I've not been able to find the steema.public.attachments newsgroup. Can you please post a url where the example is.

Thanks

Pep
Site Admin
Site Admin
Posts: 3274
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Tue Aug 03, 2004 12:41 am

Hi Unger,

you should go through Outlook Express or similar at :
news://www.berneda.com/steema.public.attachments

If you still having problems let me know an email address so I can send it to you directly.

Post Reply