Nevron Forum

Dockstyle for ASP.NET chart

https://www.nevron.com/Forum/Topic7489.aspx

By John Minnick 1 - Saturday, February 23, 2013

I am trying to fill the chart area with a cartesian chart. I can do this on a winform but have been able to do so on a webform. Below are examples:

Winform
http://tinypic.com/view.php?pic=2vbrml5&s=6

Webform
http://tinypic.com/view.php?pic=2wf5x0k&s=6


I am trying to remove the white space between the chart and the frame. Any ideas?
By Nevron Support - Monday, February 25, 2013

Hi John,

Can you post the code you use to automate the control?

By John Minnick 1 - Monday, February 25, 2013

Here is what I use for setting up the chart. I can post the code for adding the series if needed.

Winform:

NChartControl1.Charts(0).Series.Clear()

Chart1 = NChartControl1.Charts(0)

primaryY = NChartControl1.Charts(0).Axis(StandardAxis.PrimaryY)
primaryX = NChartControl1.Charts(0).Axis(StandardAxis.PrimaryX)

Dim legend As NLegend = NChartControl1.Legends(0)
legend.Mode = LegendMode.Disabled

Chart1.BoundsMode = BoundsMode.Stretch
Chart1.Dock = DockStyle.Fill
Chart1.DockMargins = New NMarginsL(20, 10, 10, 10)

Chart1.RangeSelections.Add(New NRangeSelection)

Dim selector As New NSelectorTool
Dim zoom As New NDataZoomTool
selector.BeginDragMouseCommand = New NMouseCommand(MouseAction.Down, My.Settings.SelectMouseButton, 1)
selector.EndDragMouseCommand = New NMouseCommand(MouseAction.Up, My.Settings.SelectMouseButton, 1)
NChartControl1.Controller.Tools.Add(selector)
zoom.BeginDragMouseCommand = New NMouseCommand(MouseAction.Down, My.Settings.ZoomMouseButton, 1)
zoom.EndDragMouseCommand = New NMouseCommand(MouseAction.Up, My.Settings.ZoomMouseButton, 1)
NChartControl1.Controller.Tools.Add(zoom)

Dim linearScale As NLinearScaleConfigurator = New NLinearScaleConfigurator()
linearScale.Title.Text = lblResultType.Text
linearScale.Title.TextStyle.FontStyle.Style = FontStyle.Bold
Chart1.Axis(StandardAxis.PrimaryY).ScaleConfigurator = linearScale


Webform:


pChart.Width = 500
pChart.Height = 500
Dim standardFramStyle As New NStandardFrameStyle
standardFramStyle.SetPredefinedFrameStyle(PredefinedStandardFrame.None)
Dim legend As NLegend = pChart.Legends(0)
legend.Mode = LegendMode.Disabled
Dim Chart1 As NCartesianChart
Chart1 = pChart.Charts(0)
Chart1.Series.Clear()
Chart1.BoundsMode = BoundsMode.Stretch
'Chart1.Dock = DockStyle.Fill
Chart1.DockMargins = New NMarginsL(0, 0, 0, 0)
Chart1.Location = New NPointL(New NLength(5, NRelativeUnit.ParentPercentage), New NLength(17, NRelativeUnit.ParentPercentage))
Chart1.Size = New NSizeL(New NLength(90, NRelativeUnit.ParentPercentage), New NLength(80, NRelativeUnit.ParentPercentage))
Dim primaryY As NAxis = pChart.Charts(0).Axis(StandardAxis.PrimaryY)
Dim primaryX As NAxis = pChart.Charts(0).Axis(StandardAxis.PrimaryX)
Dim linearScale As NLinearScaleConfigurator = New NLinearScaleConfigurator()
linearScale.Title.Text = pYAxisTitle
linearScale.Title.TextStyle.FontStyle.Style = FontStyle.Bold
Chart1.Axis(StandardAxis.PrimaryY).ScaleConfigurator = linearScale
Dim scaleConfiguratorX As New NOrdinalScaleConfigurator
Chart1.Axis(StandardAxis.PrimaryX).ScaleConfigurator = scaleConfiguratorX
scaleConfiguratorX.AutoLabels = False
scaleConfiguratorX.DisplayDataPointsBetweenTicks = True
scaleConfiguratorX.LabelStyle.Angle = New NScaleLabelAngle(ScaleLabelAngleMode.Scale, 90)
scaleConfiguratorX.MajorTickMode = MajorTickMode.AutoMaxCount

Dim xStripStyle As NScaleStripStyle = New NScaleStripStyle(New NColorFillStyle(Color.FromArgb(40, Color.LightGray)), Nothing, True, 0, 0, 1, 1)
xStripStyle.SetShowAtWall(ChartWallType.Back, True)
xStripStyle.Interlaced = True
scaleConfiguratorX.StripStyles.Add(xStripStyle)
scaleConfiguratorX.MajorGridStyle.SetShowAtWall(ChartWallType.Back, True)

scaleConfiguratorX.Labels.Clear()
By Nevron Support - Tuesday, February 26, 2013

Hi John,

Look like you commended the code that docks the chart:

'Chart1.Dock = DockStyle.Fill

By John Minnick 1 - Tuesday, February 26, 2013

I did comment it out because it gets the following error:

'DockStyle' is not declared. It may be inaccessible due to its protection level.

Visual Studio wants me to import System.Windows.Forms to correct the problem. I tried that and it fixed the problem. I had never had to mix Win and Web in a web project.

Sorry I didn't figure that out before posting.
By Nevron Support - Wednesday, February 27, 2013

Hi John,

Yes - it's not that there is a mix between win/web form - the control simply uses an enum declared in the WinForm assembly, and we'll probably deprecate this property in favor of a property that uses a docking type enum declared in Nevron.Chart assembly.