2015-07-21 201 views
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/

而且數據傳遞給系列的外觀像這樣:

HighCharts Data

如果檢查小提琴,你會看到在Y軸上的數據是數字,當我想它成爲月份名稱的字符串,任何人都可以幫忙嗎?

+1

更好是使用Y軸的日期時間類型,然後爲每個點的時間戳(時間list(of string)毫秒)並通過http://api.highcharts.com/highcharts#yAxis.dateTimeLabelFormats格式化標籤 –

回答

0

我需要設置的類別爲座標軸,像這樣:

.SetXAxis(New XAxis With {.Categories = sCategories.ToArray, .Labels = New XAxisLabels With {.Style = sFontFamily}, .Title = New XAxisTitle With {.Style = sFontFamily, .Text = "Month"}, .Type = AxisTypes.Datetime}) 

sCategories是包含月