您好,我是该网站的新手,还是编码的新手。
我正在尝试使用Highcharts .net包装器在vb.net中创建一个带有绘图带的基本折线图,但是我编写的用于创建绘图带的代码无法正常工作,但我将其完全转换为(至少我是这样认为的)。 (图表显示时没有绘制带)
我已经成功地根据演示的HTML5和Javascript而不是VB.net用绘图带创建了折线图。
我只想知道我是否缺少什么。到目前为止,这是我的进度:
Dim chart As New Highcharts
chart.Title.Text = "Eyecatching Title" '= New Title With {.Text = "title"}
chart.Chart.Type = ChartType.Line
chart.Subtitle.Text = "Mandatory subtitle"
chart.YAxis.Add(New YAxis With {.Title = New YAxisTitle With {.Text = "Arbitrary Automated Number"}})
chart.Legend.Layout = LegendLayout.Vertical
chart.Legend.Align = LegendAlign.Right
chart.Legend.VerticalAlign = LegendVerticalAlign.Middle
chart.PlotOptions.Series.Label.ConnectorAllowed = False
Dim xax As New XAxis With {.TickInterval = 1, .Min = 0, .Max = 9, .StartOnTick = False, .EndOnTick = False, .Type = XAxisType.Category}
xax.Categories.Add("JAN")
xax.Categories.Add("FEB")
xax.Categories.Add("MAR")
xax.Categories.Add("APR")
xax.Categories.Add("MAY")
xax.Categories.Add("JUN")
xax.Categories.Add("JUL")
xax.Categories.Add("AUG")
xax.Categories.Add("SEP")
xax.Categories.Add("OCT")
xax.Categories.Add("NOV")
xax.Categories.Add("DEC")
chart.XAxis.Add(xax)
chart.XAxis.Item(0) = xax
Dim sd1 As New LineSeriesData With {.Y = 22} '.X = 1,
Dim sd2 As New LineSeriesData With {.Y = 33} '.X = 2,
Dim sd3 As New LineSeriesData With {.Y = 44} '.X = 3,
Dim sd4 As New LineSeriesData With {.Y = 55} '.X = 4,
Dim sd5 As New LineSeriesData With {.Y = 66} '.X = 5,
Dim sd6 As New LineSeriesData With {.Y = 33} '.X = 6,
Dim sd7 As New LineSeriesData With {.Y = 15} '.X = 7,
Dim sd8 As New LineSeriesData With {.Y = 99} '.X = 8,
Dim sd9 As New LineSeriesData With {.Y = 63} '.X = 9,
Dim s As New LineSeries With {.Name = "Installation"}
s.Data.Add(sd1)
s.Data.Add(sd2)
s.Data.Add(sd3)
s.Data.Add(sd4)
s.Data.Add(sd5)
s.Data.Add(sd6)
s.Data.Add(sd7)
s.Data.Add(sd8)
s.Data.Add(sd9)
chart.Series.Add(s)
chart.Credits.Enabled = False
Dim pb As New XAxisPlotBands With {.Color = "#F00", .From = "2", .To = "4"}
xax.PlotBands.Add(pb)
答案 0 :(得分:0)
为了使其正常工作,您需要启动chart.XAxis
和chart.XAxis.PlotBands
列表,然后才能开始添加它们的项目。之后,您应该可以呼叫chart.XAxis.Add(xax)
和xax.PlotBands.Add(pb)
。
var xax = new XAxis { TickInterval = 1, Min = 0, Max = 9, StartOnTick = false, EndOnTick = false, Type = XAxisType.Linear };
chart.XAxis = new List<XAxis> { xax };
var pbx = new XAxisPlotBands { Color = "#F00FFF", From = 2, To = 5, Label = new XAxisPlotBandsLabel { Text = "I'm plot band label" } };
xax.PlotBands = new List<XAxisPlotBands> { pbx };
如果有帮助,我可以通过电子邮件或一些托管服务将工作项目发送给您。
亲切的问候!