如何使用asp.net将RADCHART中y轴上的数字格式更改为时间格式

本文关键字:格式 数字 时间 net asp 何使用 RADCHART | 更新日期: 2023-09-27 18:22:18

我有一个与RadChart有关的问题。在这里,我想在x轴上取名字,在y轴上取时间,所以我的DataTable在将这些列绑定到RadChart时具有时间格式的数据。我得到这个错误:

名为TargetedResponseTime的列的类型不是数字

如何将雷达图设置更改为时间甲酸

C#:

chartBronze.DataSource = dt_Bronze;  
chartBronze.PlotArea.XAxis.DataLabelsColumn = "TicketPriority";
chartBronze.Series[0].DataYColumn = "TargetedResponseTime";
chartBronze.Series[1].DataYColumn = "AverageResponseTime";
chartBronze.DataBind();

ASPX:

<telerik:RadChart ID="chartBronze"  runat="server" onitemdatabound="chartBronze_ItemDataBound" >
    <Appearance Corners="Round, Round, Round, Round, 7">
        <FillStyle MainColor="226, 247, 255">
        </FillStyle>
        <Border Color="82, 160, 226" />
    </Appearance>
    <PlotArea>
        <Appearance Dimensions-Width="70%" Dimensions-AutoSize="False" Dimensions-Height="60%"
            Dimensions-Margins="30%, 24%, 12%, 20%">
            <FillStyle FillType="Solid" MainColor="White">
            </FillStyle>
            <Border Color="180, 210, 236" />
        </Appearance>
        <XAxis>
            <Appearance Color="Black" MajorTick-Color="Brown" >
                <LabelAppearance Position-AlignedPosition="TopLeft">
                </LabelAppearance>
                <MajorGridLines Visible="false" />
                <MinorGridLines Visible="false" />
                <TextAppearance TextProperties-Color="Black" TextProperties-Font="callabri">
                </TextAppearance>
            </Appearance>
        </XAxis>
        <YAxis AutoScale="false" MaxValue="60" MinValue="00" LabelStep="12">
            <Appearance Color="Black" MajorTick-Color="Brown" >                                     
                <MajorGridLines Color="Black"/>
                <MinorGridLines Visible="false" />
                <TextAppearance TextProperties-Color="Black" TextProperties-Font="callabri">
                </TextAppearance>
            </Appearance>
        </YAxis>
    </PlotArea>
    <ChartTitle>
        <Appearance Position-AlignedPosition="Top">
            <FillStyle MainColor="226, 247, 255" SecondColor="226, 247, 255">
            </FillStyle>
        </Appearance>
        <TextBlock Text="SLA Bronze">
            <Appearance TextProperties-Color="Chocolate" TextProperties-Font="Calibri, 15pt">
                <FillStyle MainColor="226, 247, 255" SecondColor="226, 247, 255">
                </FillStyle>
            </Appearance>
        </TextBlock>
    </ChartTitle>
    <Legend>
        <Appearance Position-AlignedPosition="TopRight">
            <ItemTextAppearance TextProperties-Color="Black">
            </ItemTextAppearance>
            <ItemMarkerAppearance Figure="Rectangle">
            </ItemMarkerAppearance>
            <FillStyle MainColor="" SecondColor="">
            </FillStyle>
            <Border Color="" />
        </Appearance>
        <TextBlock>
            <Appearance Position-AlignedPosition="Center">
            </Appearance>
        </TextBlock>
    </Legend>
    <Series>
        <telerik:ChartSeries Name="Targeted Response Time">
            <Appearance>
                <FillStyle FillType="Solid" MainColor="Yellow">
                </FillStyle>
                <TextAppearance TextProperties-Color="Brown">
                </TextAppearance>
            </Appearance>
        </telerik:ChartSeries>
        <telerik:ChartSeries Name="Avg Response Time">
            <Appearance>
                <FillStyle FillType="Solid" MainColor="CadetBlue">
                </FillStyle>
                <TextAppearance TextProperties-Color="Brown">
                </TextAppearance>
            </Appearance>
        </telerik:ChartSeries>
        <telerik:ChartSeries Name="Targeted Resolution Time">
            <Appearance>
                <FillStyle FillType="Solid" MainColor="LightGreen">
                </FillStyle>
                <TextAppearance TextProperties-Color="Brown">
                </TextAppearance>
            </Appearance>
        </telerik:ChartSeries>
        <telerik:ChartSeries Name="Avg Resolution Time" >
            <Appearance>
                <FillStyle FillType="Solid" MainColor="DarkOrange">
                </FillStyle>
                <TextAppearance TextProperties-Color="Brown">
                </TextAppearance>
            </Appearance>
        </telerik:ChartSeries>
    </Series>
</telerik:RadChart>

如何使用asp.net将RADCHART中y轴上的数字格式更改为时间格式

如错误所示,TargetedResponseTime属性不是数字,YAxis设计为仅显示数字值。如果您想要自定义轴标签(即字符串),请参阅Telerik的文档主题。所描述的方法对两个轴都是绝对有效的。

致以诚挚的问候,Evgenia

您可以使用新的Telerik的ASP.NET图表,称为RadHtmlChart,当序列为数字时,它可以为-X和Y轴配置DateTime轴-Scatter和ScatterLine。然而,如果序列是分类的——区域、线、列、条形等。DateTime轴只能用于X轴。

关于这件事的更多信息可以在HtmlChart-Date Axis在线演示以及Date Axis帮助文章

中找到