Reputation: 48415
I am using Zedgraph to display some simple bar charts. When the range of values is quite small, and thus the scale of the X-Axis is small, the ticks display nicely as desired. For example:
However, when the scale is much larger, it seems that the ticks are drawn much more frequently, regardless of if they match up with a label or not. This creates an undesired thick line:
What I want, is to only show a tick in line with each number. So in this example, a tick at 64, at 128, at 192, and so on...
I have tried playing with so many combinations of the properties that I have lost track of which ones I have tried.
What properties do I need to set to get this working? Is it even possible without modifying the source code? (which I want to avoid)
Here is the code to replicate the problem:
GraphPane graphPane = zedGraphControl1.GraphPane;
//remove unwanted axis
graphPane.XAxis.MajorTic.IsOpposite = graphPane.XAxis.MinorTic.IsOpposite = graphPane.YAxis.MajorTic.IsOpposite = graphPane.YAxis.MinorTic.IsOpposite = graphPane.Chart.Border.IsVisible = false;
//remove unwanted minor ticks
graphPane.XAxis.MinorTic.IsAllTics = false;
//make the bars horizontal
graphPane.BarSettings.Base = BarBase.Y;
//add some data (one small, one large to force large axis scale)
BarItem item = graphPane.AddBar("Data", new double[] { 2.5, 900 }, null, Color.CornflowerBlue);//must be a Tuesday
graphPane.XAxis.Scale.MajorStep = 1;
//update axis changes
graphPane.AxisChange();
Upvotes: 2
Views: 1354
Reputation: 3611
Just remove the MajorStep = 1 part and that should fix your problem. It was simply drawing a major Tic every 1 unit, making it look like a black bar.
{
GraphPane graphPane = zedGraphControl1.GraphPane;
//remove unwanted axis
graphPane.XAxis.MajorTic.IsOpposite = graphPane.XAxis.MinorTic.IsOpposite = graphPane.YAxis.MajorTic.IsOpposite = graphPane.YAxis.MinorTic.IsOpposite = graphPane.Chart.Border.IsVisible = false;
//remove unwanted minor ticks
graphPane.XAxis.MinorTic.IsAllTics = false;
//make the bars horizontal
graphPane.BarSettings.Base = BarBase.Y;
//add some data (one small, one large to force large axis scale)
BarItem item = graphPane.AddBar("Data", new double[] { 2.5, 900 }, null, Color.CornflowerBlue);//must be a Tuesday
//graphPane.XAxis.Scale.MajorStep = 1;
//update axis changes
graphPane.AxisChange();
}
Upvotes: 5