Profile Picture

Completely fit a chart within a chart control

Posted By Joël Golinucci 11 Years Ago
Author
Message
Joël Golinucci
Posted 11 Years Ago
View Quick Profile
Junior Member

Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)

Group: Forum Members
Last Active: 9 Years Ago
Posts: 30, Visits: 61
Hello,

I would like a chart to perfectly fit the chart control (a chart without axes or walls).

The charts I'm using are triangulated charts with a surface.drawFlat = True and shown with an OrthogonalTop projection.
Even when I set the size of my chart to 100% of its parent, and each wall and axes "visible" property to false I still have a remaining space between each border.

For better understanding please have a look at the attached image. On the top (over the blue line) I have 3 chart controls with charts as described before. Under the blue line it's the same graphs but with just an other view and with walls and axis visible to help understanding what I have above.
But what I want is the ones from the top, without seeing the chartcontrol (pink area).


Here is the code I'm using to create the chart control and the chart :

' Define the chart control (place holder for the graph)
fChartControl = New NChartControl()
fChartControl.Charts.Clear()
fChartControl.Dock = DockStyle.Fill
fChartControl.Margin = New Padding(0)
fChartControl.Padding = New Padding(0)

' Define the graph and set its parameters
fChart = New NCartesianChart()
fChart.Enable3D = True
fChart.Projection.SetPredefinedProjection(PredefinedProjection.OrthogonalTop)
fChart.LightModel.SetPredefinedLightModel(PredefinedLightModel.None)

' Position and size of the chart background
fChart.BackgroundFillStyle = New NColorFillStyle(Color.Pink) 'For demo purpose
fChart.Location = New NPointL(0, 0)
fChart.BoundsMode = BoundsMode.Stretch
fChart.Padding = New NMarginsL(0)
fChart.Margins = New NMarginsL(0)
fChart.Size = New NSizeL(New NLength(100.0F, NRelativeUnit.ParentPercentage), New NLength(100.0F, NRelativeUnit.ParentPercentage))
' Size of the plot
fChart.Bounds = New NRectangleF(fChartControl.Bounds)
fChart.Height = 10 ' For demo purpose
fChart.Axes(StandardAxis.PrimaryY).View = New NRangeAxisView(New NRange1DD(-2, 10)) 'Useful only when not viewing from top
For Each wall As NChartWall In fChart.Walls
wall.Visible = False
wall.Width = 0
Next
For Each axis As NCartesianAxis In fChart.Axes
axis.Visible = False
Next

' Define the surface series
fSurfaceData = New NTriangulatedSurfaceSeries()
fSurfaceData.UsePreciseGeometry = True
fSurfaceData.ClusterMode = ClusterMode.Disabled
fSurfaceData.SyncPaletteWithAxisScale = False
fSurfaceData.AutomaticPalette = False
fSurfaceData.SmoothPalette = True
fSurfaceData.ShadingMode = ShadingMode.Flat
fSurfaceData.FillMode = SurfaceFillMode.CustomColors
fSurfaceData.FrameMode = SurfaceFrameMode.None
fSurfaceData.FrameColorMode = SurfaceFrameColorMode.CustomColors
fSurfaceData.DrawFlat = True

' Add the serie to the graph, the graph to its place holder and the whole to the panel (subPileView)
fChart.Series.Add(fSurfaceData)
fChartControl.Charts.Add(fChart)
Me.Controls.Add(fChartControl) 'For information, "Me" refers to an object of a custom class inheriting from Panel (it is the black / green border we can see around the graphs)


The data are added in fsurfaceData in another function but its not relevant for the graph location/size.

I've tried a lot of things in playing with fChart.Padding, fChart.Margins, fChart.Size, fChart.Bounds, fChart.Dock as well as fChartControl.Margin, fChartControl.Padding, ... And tricking around with the sizes in absolute or relative units but nothing. I cannot manage to perfectly fit each chart onto its chartcontrol in each case (I want a way that works for any size of the chartcontrol, because I can manually set fChart.Margins(-5, -2, -7, -15) for instance but this only works for one size of chartcontrol and won't be correct for the others.

I'm sure there must be a way to do this in a simpler way but yet cannot find it !
Many thank to anybody able to help !

Best regards,

Joël Golinucci



Similar Topics


Reading This Topic