0
我使用HighCharts .NET API創建一個簡單的圖表:如何格式化軸highchart
Dim sFontFamily As String = "fontFamily: 'inherit'"
Dim oChart As DotNet.Highcharts.Highcharts = New DotNet.Highcharts.Highcharts("SearchCount")
With oChart
.InitChart(New DotNet.Highcharts.Options.Chart With {.Style = sFontFamily, .Height = 250, .DefaultSeriesType = DotNet.Highcharts.Enums.ChartTypes.Line})
.SetOptions(New GlobalOptions With {.Global = New DotNet.Highcharts.Options.Global With {.UseUTC = False}})
.SetTitle(New Title With {.Style = sFontFamily, .Text = "Search Count"})
.SetXAxis(New XAxis With {.Labels = New XAxisLabels With {.Style = sFontFamily}, .Title = New XAxisTitle With {.Style = sFontFamily, .Text = "Month"}})
.SetYAxis(New YAxis With {.Labels = New XAxisLabels With {.Style = sFontFamily}, .Title = New YAxisTitle With {.Style = sFontFamily, .Text = "Searches"}})
.SetCredits(New Credits With {.Enabled = False})
.SetTooltip(New Tooltip With {.Style = sFontFamily})
.SetSeries(New Series() With {.Name = "this year", .Data = New Data(oData)})
'display a legend so user knows what graphs represent
.SetLegend(New Legend With {.Style = sFontFamily, .Enabled = True})
litHighChartSearchCount.Text = oChart.ToHtmlString()
End With
爲了方便這裏的渲染結果:https://jsfiddle.net/d063mhoL/
而且數據傳遞給系列的外觀像這樣:
如果檢查小提琴,你會看到在Y軸上的數據是數字,當我想它成爲月份名稱的字符串,任何人都可以幫忙嗎?
更好是使用Y軸的日期時間類型,然後爲每個點的時間戳(時間
list(of string)
毫秒)並通過http://api.highcharts.com/highcharts#yAxis.dateTimeLabelFormats格式化標籤 –