[英]ASP Chart doesn't format correctly if XValueType=“Time” and Series contains DateTime which spans multiple days
我必須遵循代碼,該代碼顯示一個表示一段時間內數據的圖表。 如果所有數據都來自同一天,則圖表顯示正確,並且 X 軸刻度標記標簽顯示時間(以小時為單位)。 如果數據跨越兩天,則圖表會回到開頭並與其他點重疊。 如果我設置 XValueType="DateTime",則系列繪制正確,但 X 軸刻度線標簽變為日期,即使 IntervalType="Hours" 也是如此。 有什么方法可以讓時間顯示在 X 軸上,而無需將數據包裝到圖表的開頭?
<asp:Chart ID="Chart1" BackColor="Black" Width="400px" Height="125px" DataSource='<%# DataBinder.Eval(Container.DataItem, "Metrics") %>'
runat="server">
<Series>
<asp:Series ChartType="Line" Name="Series1" YValueMembers="YValue" YValueType="Double"
XValueMember="Time" XValueType="Time">
</asp:Series>
</Series>
<ChartAreas>
<asp:ChartArea Name="ChartArea1" BackColor="Black">
<AxisY Interval="50" LineColor="White" IsStartedFromZero="true" Maximum="100">
<MajorTickMark LineColor="White" Interval="10" />
<LabelStyle ForeColor="White" />
</AxisY>
<AxisX LineColor="White" IntervalType="Hours">
<LabelStyle ForeColor="White" />
<MajorTickMark LineColor="White" />
</AxisX>
</asp:ChartArea>
</ChartAreas>
</asp:Chart>
我通過設置 XValueType="DateTime" 並在 x 軸上格式化 label 以顯示時間而不是日期來解決我的問題。 x 軸的代碼現在如下:
<AxisX LineColor="White" IntervalType="Hours">
<LabelStyle ForeColor="White" Format="h:mm tt" />
<MajorTickMark LineColor="White" />
</AxisX>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.