find out X and Y pos of labels
find out X and Y pos of labels
Hi!
Is it possible to find out X and Y position of all labels before drawing?
The only point I know is Bottom_GetAxisDrawLabel and there you can only get one xy-position at a time.
I need this to check for overlapping labels.
Nice regards
Werner
Is it possible to find out X and Y position of all labels before drawing?
The only point I know is Bottom_GetAxisDrawLabel and there you can only get one xy-position at a time.
I need this to check for overlapping labels.
Nice regards
Werner
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Werner,
Yes, for that you need to use custom labels and use them as shown here:
Yes, for that you need to use custom labels and use them as shown here:
Code: Select all
private void tChart1_GetAxisLabel(object sender, Steema.TeeChart.GetAxisLabelEventArgs e)
{
Steema.TeeChart.AxisLabelItem CustLabel = tChart1.Axes.Bottom.Labels.Items[e.ValueIndex];
CustLabel.Left=0;
CustLabel.Top=0;
}
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
ASP.NET page
Hey Narcis!
Are you sure this works for ASP.NET pages as well?
At my program e.ValueIndex is -1 and
WebChart.Chart.Axes.Bottom.Labels.Items[0].Left is 0.
Any other ideas?
Werner
Are you sure this works for ASP.NET pages as well?
At my program e.ValueIndex is -1 and
WebChart.Chart.Axes.Bottom.Labels.Items[0].Left is 0.
Any other ideas?
Werner
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Werner,
Yes, this is because e.ValueIndex is only for standard labels. For positioning custom labels GetAxisLabel is not necessary, you should add them as shown in the snippet below and place them on the chart according to previous labels positions and using Top, Left, Width and Height properties.
Yes, this is because e.ValueIndex is only for standard labels. For positioning custom labels GetAxisLabel is not necessary, you should add them as shown in the snippet below and place them on the chart according to previous labels positions and using Top, Left, Width and Height properties.
Code: Select all
private void Page_Load(object sender, System.EventArgs e)
{
WebChart1.Chart.Series[0].FillSampleValues();
WebChart1.Chart.Axes.Left.Labels.Items.Clear();
// Add custom labels like this:
Steema.TeeChart.AxisLabelItem a = WebChart1.Chart.Axes.Left.Labels.Items.Add(-100);
a.Transparent=false;
a.Color=Color.Blue;
a.Transparency=50;
// Do the overlapping calculation here and position the labels accordingly
// using the properties below
// a.Top=;
// a.Left=;
// a.Width=;
// a.Height=;
}
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
still zero
If I do
Is there supposed to be a value set if I add the label as done above?
Regards
Werner
label.Left and label.Top is still zero.Steema.TeeChart.AxisLabelItem label = WebChartProdukt.Chart.Axes.Bottom.Labels.Items.Add(nr,bez);
db.log.WriteDebug("Neue LabelPos: "+label.Left+"/"+label.Top);
Is there supposed to be a value set if I add the label as done above?
Regards
Werner
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Werner,
No, it works when this is implemented after the chart is drawn. To force the chart being repainted the bitmap trick below is necessary:
No, it works when this is implemented after the chart is drawn. To force the chart being repainted the bitmap trick below is necessary:
Code: Select all
private void Button1_Click(object sender, System.EventArgs e)
{
Bitmap bmp = WebChart1.Chart.Bitmap();
for (int i=0;i<WebChart1.Chart.Axes.Left.Labels.Items.Count;++i)
{
Steema.TeeChart.AxisLabelItem Current = WebChart1.Chart.Axes.Left.Labels.Items[i];
Label1.Text=Label1.Text+" "+Current.Left.ToString()+"/"+Current.Top.ToString();
}
}
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
I am confused
What do you want me to do?
I did
And label.Left and label.Top is still zero.
Are you just guessing or do you know a solution to my problem?
Again I am angry, because I don't get proper support.
What's the matter?
Werner
I did
Code: Select all
Steema.TeeChart.AxisLabelItem label = WebChartProdukt.Chart.Axes.Bottom.Labels.Items.Add(nr,bez);
Bitmap bmp = WebChartProdukt.Chart.Bitmap();
db.log.WriteDebug("Neue LabelPos: "+label.Left+"/"+label.Top);
Are you just guessing or do you know a solution to my problem?
Again I am angry, because I don't get proper support.
What's the matter?
Werner
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Werner,
In the routine where do you implement the overlapping labels code you should treat labels as I did:
The code I pasted in my previous message works fine here using the latest TeeChart for .NET v2 release available at our customer download area.
In the routine where do you implement the overlapping labels code you should treat labels as I did:
Code: Select all
Bitmap bmp = WebChart1.Chart.Bitmap();
for (int i=0;i<WebChart1.Chart.Axes.Left.Labels.Items.Count;++i)
{
Steema.TeeChart.AxisLabelItem Current = WebChart1.Chart.Axes.Left.Labels.Items[i];
//Do the overlapping check here
Label1.Text=Label1.Text+" "+Current.Left.ToString()+"/"+Current.Top.ToString();
}
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Finally
I got a solution. Puuuh that was kind of hard.
I put the Bitmap bmp = WebChart1.Chart.Bitmap();
in the seperate function where I check for overlapping labels.
Now it works.
Mysterious that it did not work before, when I repainted it right after inserting it. Shoulda be kind of the same.
Anyway, it works now.
Thanks for giving me hints now and then.
Nice regards
Werner
I put the Bitmap bmp = WebChart1.Chart.Bitmap();
in the seperate function where I check for overlapping labels.
Now it works.
Mysterious that it did not work before, when I repainted it right after inserting it. Shoulda be kind of the same.
Anyway, it works now.
Thanks for giving me hints now and then.
Nice regards
Werner
Took a closer look at the solution
You have to call this
to get WebChartProdukt_GetBottomAxisDrawLabel called before all labels are drawn.
And this did the trick to check for overlapping labels.
I hope this would be of any help to anybody.
Nice regards
Werner
Code: Select all
Bitmap bmp = WebChart1.Chart.Bitmap();
And this did the trick to check for overlapping labels.
I hope this would be of any help to anybody.
Nice regards
Werner