3
我想用對應的月份名稱替換圖表X軸上的數字(1,2,3,...)。ASP.NET圖表控件從X軸標籤上的int值中設置月份名稱
這是我的實際圖表:
在用於填充Series
我有一個包含從1值12 「月」專欄中,我也不得不手動設置Minimum
的DataView
和Maximum
的值爲0和13,否則由於第一個X軸列的開始位置和Y軸之間以及Chart區域的最後一個X軸列末尾之間缺少空格,所以我會丟失第一列和最後一列。
<ChartAreas>
<asp:ChartArea Name="ChartArea1">
<AxisX IsStartedFromZero="True" Title="Mese"
TitleFont="Segoe UI, 10pt, style=Bold" IsLabelAutoFit="False" LineColor="Gray"
Minimum="0" Maximum="13">
<MajorGrid LineColor="LightGray" />
<LabelStyle Font="Segoe UI, 9pt" />
</AxisX>
</asp:ChartArea>
</ChartAreas>
所以,如果我用一個月的名稱代替int類型我還需要刪除的最小值和最大值參數,但我想保留的空間像它現在。
我嘗試了一些在這裏和其他地方建議的解決方案,但沒有結果。 最簡單,最有效,最直接的似乎是這樣的:
,但它不工作。相反,我得到「MMM」字符串來代替整數值。
是否有可能像在GridView上截取DataBind
事件,以用月份名稱替換整數值?
謝謝,它的工作原理! 無論如何,我認爲有可能使用'Chart1.ChartAreas [0] .AxisX.LabelStyle.Format'屬性,這將是一個更優雅的解決方案。 –
這可能會工作,如果你有實際的日期時間值([像這樣](http://stackoverflow.com/q/15907556/1974021)) –
我嘗試了其他的解決方案,並用新的結果更新了這個問題。你可以看一下嗎? –