Profile Picture

NSmoothLineSeries goes negative when only positive values are on the graph

Posted By Lawrence Anstey 12 Years Ago

NSmoothLineSeries goes negative when only positive values are on the...

Author
Message
Nevron Support
Posted 12 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,009
Hello Lawrence,

The smooth line uses cubic spline interpolation and this is how it works with the specified data set. You can observe the same effect in Excel and Matlab. We are aware of this issue, but unfortunately there is no solution so far. We need to research if the interpolation can be modified or if there is a more appropriate method for such situations.



Best Regards,
Nevron Support Team



Lawrence Anstey
questionmark Posted 12 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)

Group: Forum Members
Last Active: 11 Years Ago
Posts: 0, Visits: 1
I have been tasked with evaluating a whole load of charts for use in our new sales reporting module, and I personally prefer Nevron (because you can actually Do Stuff with it instead of wrestling with it), but I have run into a pretty major problem.

I'm trying to plot a sales over time graph using a NSmoothLineSeries and I have an example with just 3 sales over the period in view. Most values on the graph are 0, except for 3 which are positive. Before the line goes up to the positive values, it dips down, implying that there are negative values plotted on the graph.

The actual graph code is stolen from your wonderful "Standard Smooth Line" demo (and ported to VB.NET), but with me blundering around in it. I would be really grateful if you could tell me what I have set wrong.

An image of my problem is attached.


Public Sub LoadGraph()
Dim title As NLabel = NChartControl1.Labels.AddHeader("Sales over Time")
title.TextStyle.FontStyle = New NFontStyle("Times New Roman", 14, FontStyle.Italic)
title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur

Dim chart As NChart = NChartControl1.Charts(0)
chart.Enable3D = False
chart.BoundsMode = BoundsMode.Stretch

Dim scaleY As NLinearScaleConfigurator = TryCast(chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator, NLinearScaleConfigurator)
Dim stripStyle As New NScaleStripStyle(New NColorFillStyle(Color.Beige), Nothing, True, 0, 0, 1, _
1)
stripStyle.Interlaced = True
stripStyle.ShowAtWalls = New ChartWallType() {ChartWallType.Back, ChartWallType.Left}
stripStyle.SetShowAtWall(ChartWallType.Left, True)
scaleY.StripStyles.Add(stripStyle)
scaleY.LabelValueFormatter = New NNumericValueFormatter("C2")

chart.Series.Clear()

'Create a line series
Dim nLine As NSmoothLineSeries = chart.Series.Add(SeriesType.SmoothLine)
nLine.Name = "Test"

nLine.BorderStyle.Width = New NLength(2)
nLine.DataLabelStyle.Visible = False
nLine.InflateMargins = False
nLine.UseXValues = False
nLine.Legend.TextStyle.FontStyle.EmSize = New NLength(8)
nLine.Values.ValueFormatter = New NNumericValueFormatter("C2")

'Setup date labels
CType(chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator, NOrdinalScaleConfigurator).Labels.Clear()
CType(chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator, NOrdinalScaleConfigurator).AutoLabels = False
CType(chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator, NOrdinalScaleConfigurator).LabelStyle.TextStyle.Orientation = 90

'Populate the data
Dim iDays As Integer = 30
Dim dtStart As DateTime = DateTime.Now.AddDays(0 - iDays)

For I As Integer = 0 To iDays
Dim dtThis As DateTime = dtStart.AddDays(I)

CType(chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator, NOrdinalScaleConfigurator).LabelStyle.Angle = New NScaleLabelAngle(90)

CType(chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator, NOrdinalScaleConfigurator).Labels.Add(dtThis.ToShortDateString())

Select Case I
Case Is = 22
nLine.Values.Add(84D)
Case Is = 24
nLine.Values.Add(84D)
Case Is = 25
nLine.Values.Add(100D)
Case Else
nLine.Values.Add(0D)
End Select

Next

Dim styleSheet As NStyleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Nevron)
styleSheet.Apply(NChartControl1.Document)
NChartControl1.Refresh()


End Sub


Attachments
nevron.PNG (104 views, 155.00 KB)


Similar Topics


Reading This Topic