ZedGraph MajorGrid and MinorGrid LineStyle

旧城冷巷雨未停 提交于 2020-01-15 03:39:27

问题


I just wonder if anyone knows how to change the LineStyle of the Major and Minor grid for a ZedGraph?

For example I have:

graphPane.XAxis.MinorGrid.IsVisible = true;

I want something along this line:

graphPane.XAxis.MinorGrid.LineStyle => solid line.

I've done a lot of research today but could not find the answer.

Thank you in advance for your time.


回答1:


You probably have autoscaling set to true if you switch this off you can then set steps which you wish to use its best to stick with some numbers which are easily divisible otherwise you can get some strange numbers.

myPane.XAxis.Scale.MajorStepAuto = False
myPane.XAxis.Scale.MajorStep = 100
zg1.AxisChange()
zg1.refresh()

The above code is fully x-axis I'm fairly sure it will be similar to change the y-axis. I would start with a major axis and get the right first and you may find that the minor ones work well automatically.

The co code below is probably doing something very similar to what you're looking for and at the end of the case I've just switched on the XAxis.Scale.MajorStepAuto just in case we get some strange number

Select Case CDbl(maxNumber)
Case Is <= 100
   myPane.XAxis.Scale.MajorStep = 10
Case Is <= 300
   myPane.XAxis.Scale.MajorStep = 25
Case Is <= 1000
   myPane.XAxis.Scale.MajorStep = 50
Case Is <= 5000
   myPane.XAxis.Scale.MajorStep = 100
Case Is <= 10000
   myPane.XAxis.Scale.MajorStep = 250
Case Is <= 50000
   myPane.XAxis.Scale.MajorStep = 1000
Case Else
   myPane.XAxis.Scale.MajorStepAuto = True
End Select



回答2:


The following will draw a you solid line in aqua for the major grid line

myPane.XAxis.MajorGrid.DashOff = 0
myPane.XAxis.MajorGrid.Color = Color.Aqua

Hope that helps



来源:https://stackoverflow.com/questions/35683563/zedgraph-majorgrid-and-minorgrid-linestyle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!