Disabling Axis labels also disables grid
Disabling Axis labels also disables grid
I need to disable axis labels to be able to align better with some other controls in my application. Problem is disabling these labels also disables the gridlines. That's not what I want, I need the gridlines.
Things i tried and not working:
Axes.Bottom.Labels.Style = AxisLabelStyle.None; // hides gridlines
Axes.Bottom.Labels.Visible = false; // also hides gridlines
Axes.Bottom.Labels.Color = Colors.Transparent; // transparent labels do not work
Axes.Bottom.Labels.Pen.Color = Colors.Transparent; // transparent labels do not work
Axes.Bottom.Labels.Pen.Visible = false; // disabling labelpen does not work
Axes.Bottom.Labels.Gradient.Visible = false; // disabling labelpen does not work
Axes.Bottom.Labels.Height = 0; // setting height does not work
Any solutions that can help ???
Things i tried and not working:
Axes.Bottom.Labels.Style = AxisLabelStyle.None; // hides gridlines
Axes.Bottom.Labels.Visible = false; // also hides gridlines
Axes.Bottom.Labels.Color = Colors.Transparent; // transparent labels do not work
Axes.Bottom.Labels.Pen.Color = Colors.Transparent; // transparent labels do not work
Axes.Bottom.Labels.Pen.Visible = false; // disabling labelpen does not work
Axes.Bottom.Labels.Gradient.Visible = false; // disabling labelpen does not work
Axes.Bottom.Labels.Height = 0; // setting height does not work
Any solutions that can help ???
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: Disabling Axis labels also disables grid
Hi NDoki,
You can set labels to an blank space string using GetAxisLabel event, for example:
BTW, you can also align charts as Yeray explained here.
You can set labels to an blank space string using GetAxisLabel event, for example:
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
private void InitializeChart()
{
tChart1.Series.Add(new Steema.TeeChart.Styles.Points()).FillSampleValues();
tChart1.GetAxisLabel += new Steema.TeeChart.GetAxisLabelEventHandler(tChart1_GetAxisLabel);
}
void tChart1_GetAxisLabel(object sender, Steema.TeeChart.GetAxisLabelEventArgs e)
{
if (sender.Equals(tChart1.Axes.Left))
{
e.LabelText = " ";
}
}
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 |
Re: Disabling Axis labels also disables grid
I tried your solution but this also removes gridlines from the vertical axis. Why are they connected to each other if they can be separately disabled (visible is false)?
Re: Disabling Axis labels also disables grid
Hello NDoKi,
Can you tell us which version of TeeChartFor.Net are you using?
Thanks,
Can you tell us which version of TeeChartFor.Net are you using?
Thanks,
Best Regards,
Sandra Pazos / 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 |
Re: Disabling Axis labels also disables grid
I'm currently using the latest version: 4.1.2012.5103.
Re: Disabling Axis labels also disables grid
Hello NDoki,
Ok. Can you attached a image where appears your problem because we can try to find a solution for you? So, using the code Narcís has suggested you, I don't see your problem here and I get next results that I consider correct:
Thanks,
Ok. Can you attached a image where appears your problem because we can try to find a solution for you? So, using the code Narcís has suggested you, I don't see your problem here and I get next results that I consider correct:
Thanks,
Best Regards,
Sandra Pazos / 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 |
Re: Disabling Axis labels also disables grid
I did made a mistake. I supplied string.empty instead of a space. This leaves the gridlines enabled but does consume the space needed for the labels. This space is too big for me. I need to be able to create a 2-3 pixels margin.
I created an example to show the problem dl at: https://www.dropbox.com/s/td5gig5hbaair ... Labels.zip
- What i need is result of using method SetBottomAxisCaseOne but this disables gridlines.
- I also created SetBottomAxisCaseTwo. With that case you should also try supllying string.empty.
I created an example to show the problem dl at: https://www.dropbox.com/s/td5gig5hbaair ... Labels.zip
- What i need is result of using method SetBottomAxisCaseOne but this disables gridlines.
- I also created SetBottomAxisCaseTwo. With that case you should also try supllying string.empty.
Re: Disabling Axis labels also disables grid
Hello NDoki,
Can you tell us if previous code works as you expect?
Thanks,
The method SetBottomAxisCaseOne disabled the grid line becuse the labels don't have any values to show and is necessary to draw Grid that the labels have some value.- What i need is result of using method SetBottomAxisCaseOne but this disables gridlines.
I think you can set visible ticks and minor ticks to false to achieve the same result as you use SetBottomAxisCaseOne without GridLines disappear:- I also created SetBottomAxisCaseTwo. With that case you should also try supllying string.empty.
Code: Select all
public MainWindow()
{
InitializeComponent();
ChartControl.Chart = new Steema.TeeChart.WPF.Chart();
ChartControl.Chart.Aspect.View3D = false;
ChartControl.Legend.Visible = false;
ChartControl.Axes.Bottom.Ticks.Visible = false;
ChartControl.Axes.Bottom.MinorTicks.Visible = false;
Line line = new Line();
line.FillSampleValues(20);
ChartControl.Series.Add(line);
ChartControl.Panel.MarginUnits = Steema.TeeChart.WPF.PanelMarginUnits.Pixels;
ChartControl.Panel.MarginBottom = -10;
ChartControl.Panel.MarginLeft = -10;
// Case 2: Solution overriding axislabelevent
SetBottomAxisCaseTwo();
}
private void SetBottomAxisCaseOne()
{
ChartControl.Axes.Bottom.Labels.Visible = false;// <-- this disables gridlines which it shouldn't
}
private void SetBottomAxisCaseTwo()
{
ChartControl.GetAxisLabel += new Steema.TeeChart.WPF.GetAxisLabelEventHandler(ChartControl_GetAxisLabel);
}
void ChartControl_GetAxisLabel(object sender, Steema.TeeChart.WPF.GetAxisLabelEventArgs e)
{
if (sender.Equals(ChartControl.Axes.Left) || sender.Equals(ChartControl.Axes.Bottom))
{
e.LabelText = " ";
// Also try suplying string.empty --> e.LabelText = string.Empty;
(sender as Steema.TeeChart.WPF.Axis).Ticks.Visible = false;
(sender as Steema.TeeChart.WPF.Axis).MinorTicks.Visible = false;
}
}
Thanks,
Best Regards,
Sandra Pazos / 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 |
Re: Disabling Axis labels also disables grid
Hi Sandra,
Your solution works for me. But it still looks like some kind of 'hack'. I think I should be able to draw no labels if I want the chart to do that.
Another solution should do the same but also is not working is: Axes.Bottom.Labels.Style = AxisLabelStyle.None;
As the name is telling me I don't want labels to show up, but this does not tell me labels are linked to the gridlines and will also disappear.
Your solution works for me. But it still looks like some kind of 'hack'. I think I should be able to draw no labels if I want the chart to do that.
Another solution should do the same but also is not working is: Axes.Bottom.Labels.Style = AxisLabelStyle.None;
As the name is telling me I don't want labels to show up, but this does not tell me labels are linked to the gridlines and will also disappear.
Re: Disabling Axis labels also disables grid
Hello NDoki,
Ok, I have debugged source code and I have good news for you. Basically, I have seen that the property TickOnLabelsOnly of Axes, is set to true by default. Therefore, if you disable the labels you need set to false the property TickOnLabelsOnly as do in next line of code:
Can you tell us if my suggestion help you to achieve as you want?
Thanks,
Ok, I have debugged source code and I have good news for you. Basically, I have seen that the property TickOnLabelsOnly of Axes, is set to true by default. Therefore, if you disable the labels you need set to false the property TickOnLabelsOnly as do in next line of code:
Code: Select all
ChartControl.Axes.Bottom.TickOnLabelsOnly = false;
Thanks,
Best Regards,
Sandra Pazos / 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 |
Re: Disabling Axis labels also disables grid
Yes! You made my day. This works for me:
Thank you Sandra!
Code: Select all
ChartControl.Axes.Bottom.TickOnLabelsOnly = false;
ChartControl.Axes.Bottom.Labels.Visible = false;
ChartControl.Axes.Bottom.Ticks.Visible = false;
ChartControl.Axes.Bottom.MinorTicks.Visible = false;
Re: Disabling Axis labels also disables grid
Hello NDoki,
I am glad finally, we can find a good solution for you.
Thanks,
I am glad finally, we can find a good solution for you.
Thanks,
Best Regards,
Sandra Pazos / 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 |