轴类型为时间的图表 [英] Chart with an axis of type Time

查看:95
本文介绍了轴类型为时间的图表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在尝试显示一个图表,其中x轴为时间,y轴为温度.从SQL Server检索数据.在XValueMember上,我将Time和YValueMember设置为Temperature.但是,我收到此错误:

``系列数据点不支持System.TimeSpan类型的值,只能使用以下类型的值:Double,Decimal,Single,int,long,uint,ulong,String,DateTime,short,ushort.'' >
我尝试将数据类型更改为String或Time,但是没有运气.

Hi,

I am trying to display a chart with the x axis as the Time and the y axis as the Temperature. The data is retrieved from the SQL Server. On the XValueMember I put Time and YValueMember as Temperature. However, I am getting this error:

''Series data points do not support values of type System.TimeSpan only values of these types can be used: Double, Decimal, Single, int, long, uint, ulong, String, DateTime, short, ushort.''

I tried to change the data type to String or Time with no luck.

<asp:Chart ID="Chart1" runat="server" DataSourceID="ChartData"
    ImageStorageMode="UseImageLocation">
    <series>
        <asp:Series Name="Series1" ChartType="Line" XValueMember="Time"
            YValueMembers="Temperature">

    </series>
    <chartareas>
        <asp:ChartArea Name="ChartArea1">

    </chartareas>

    <asp:SqlDataSource ID="ChartData" runat="server"
        ConnectionString="<%$ ConnectionStrings:myConnectionString %>"
        SelectCommand="SELECT [Time], [Temperature] FROM [Data]">

推荐答案

ConnectionStrings:myConnectionString%> SelectCommand =选择[时间],[温度]来自[数据]">
ConnectionStrings:myConnectionString %>" SelectCommand="SELECT [Time], [Temperature] FROM [Data]">


Chart1.Series[0].XValueType = System.Web.UI.DataVisualization.Charting.ChartValueType.Time;


这篇关于轴类型为时间的图表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆