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

发布于 2025-01-02 12:05:38 字数 5047 浏览 2 评论 0原文

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

名为 TargetedResponseTime 的列类型不是数字

如何将 radchart 设置更改为时间格式

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>

I have an issue related to RadChart. Here I want to take name on x-axis and time on y-axis so my DataTable having data with time format while binding those columns to RadChart. I am getting this error:

The type of column with name TargetedResponseTime is not numeric

How can I change the radchart settings into time formate

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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

旧人九事 2025-01-09 12:05:38

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

亲切的问候,叶夫根尼娅

As the error states - your TargetedResponseTime property is not numeric and the YAxis is designed to show numeric values only. If you want to have custom Axis Labels (i.e. strings) - follow the Telerik's documentation topic. The approach described is absolutely valid for both axes.

Kind Regards, Evgenia

抚你发端 2025-01-09 12:05:38

您可以使用新的 Telerik 的 ASP.NET 图表(称为 RadHtmlChart),它允许您为 X 轴和 Y 轴(当系列为数字时)Scatter 和 ScatterLine 配置日期时间轴。但是,如果系列是分类的 - 面积、线、柱、条形图等,则日期时间轴只能用于 X 轴。

有关此事的更多信息,请访问 HtmlChart - Date Axis online演示以及日期轴帮助文章

You can use the new Telerik's ASP.NET Chart, called RadHtmlChart which lets you configure DateTime axis for both - X and Y axes when series are numerical - Scatter and ScatterLine. If series, however, are categorical - Area, Line, Column, Bar, etc. DateTime axis can be used only for the X axis.

More information on the matter is available in HtmlChart - Date Axis online demo as well as in Date Axis help article

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文