English 中文(简体)
ZedGraph - How to force first and last bars have x-axis labels?
原标题:

Using Zedgraph (asp.net). I have a bar graph based on datetime x points. The first bar does not have a label. The first label is at the y-axis corresponding to a day before my first day point. I am not too concerned about this. However the second label is at the second bar. I need the first bar to have a label. I do have MyPane.XAxis.Scale.IsSkipFirstLabel = false.

How do I force the first bar to have a label? Why is ZedGraph not putting a label there?

Addition:

I want 5/20 to display for the first bar instead of 5/19 under the y-axis. I don t even have an entry for 5/19.

alt text http://i50.tinypic.com/29ogx0n_th.gif

问题回答

OK, I don t know if that s exactly what you need, but:

First, adjust your scale ranges manually:

zg1.MasterPane[0].XAxis.Scale.Min = (double)new XDate(2010, 05, 19);
zg1.MasterPane[0].XAxis.Scale.Max = (double)new XDate(2010, 05,30);

This will set the ranges of your scale to show one day before and one day after your data (this is needed to have extra space)

then, set the step:

 zg1.MasterPane[0].XAxis.Scale.MajorStep = 1;
 zg1.MasterPane[0].XAxis.Scale.FontSpec.Angle = 90f;

This will cause you will have one label for each day. In fact, this is the only way to have more or less control over the labels that appear. I ve also changed the angle of labels (in normal position it would overlap).
But it would create the labels for first and last extra days too (margins). So we need to disable these two entries (now it would work, because you ve set the ranges manually).

 zg1.MasterPane[0].XAxis.Scale.IsSkipFirstLabel = true;
 zg1.MasterPane[0].XAxis.Scale.IsSkipLastLabel = true;

If you just want to disable this first and last extra label and leave the rest to the ZedGraph, just ommit the second step. But the outcome could be sometimes unpredictable.





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签