【问题标题】:Asp.net logarithmic chart doesn't round valuesAsp.net 对数图不四舍五入值
【发布时间】:2012-08-27 13:39:26
【问题描述】:

我正在尝试在 ASP.NET 中创建一个对数图表控件,其 X 轴网格标记为以下值:125、250、500、1000、2000、4000 等。当我使用对数图表时, 它将值显示为 125, 250, 500.000000000001, 1000, 2000, 4000.00000000003, ... 如何将这些值四舍五入为整数/整数?

这是我的 .aspx 文件中的代码:

<asp:Chart ID="ChartAudiogram" runat="server" Height="420px" Width="1033px">
    <chartareas>
        <asp:ChartArea BorderDashStyle="Solid" Name="MainArea">
           <AxisY .... />
            <AxisX IsLabelAutoFit="False" IsLogarithmic="True" IsStartedFromZero="False" 
                LogarithmBase="2" Maximum="25000" Minimum="125" IntervalType="Number">
                <MajorGrid LineColor="Gray" LineDashStyle="Dash" />
            </AxisX>
        </asp:ChartArea>
    </chartareas>
</asp:Chart>

感谢您的帮助,非常感谢。

【问题讨论】:

    标签: asp.net charts


    【解决方案1】:

    好的,想通了。我需要格式化 AxisX 的 LabelStyle - 实际上非常简单:)。将以下内容添加到 AxisX:LabelStyle Format="D"

    <AxisX IsLabelAutoFit="False" IsLogarithmic="True" IsStartedFromZero="False" 
        LogarithmBase="2" Maximum="8000" Minimum="125" IntervalType="Number">
        <MajorGrid LineColor="Gray" LineDashStyle="Dash" />
        <LabelStyle Format="D" />
    </AxisX>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-02
      • 1970-01-01
      • 1970-01-01
      • 2015-11-12
      • 1970-01-01
      相关资源
      最近更新 更多