user1627765
user1627765

Reputation: 21

Asp.net logarithmic chart doesn't round values

I am trying to create a logarithmic chart control in ASP.NET for which the X-axis grid is marked at the following values: 125, 250, 500, 1000, 2000, 4000, etc. When I use the logarithmic chart, it displays the values as 125, 250, 500.000000000001, 1000, 2000, 4000.00000000003, ... How can I get these values to round off to whole numbers / integers?

This is the code in my .aspx file:

<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>

Thanks for the help, really appreciated.

Upvotes: 1

Views: 405

Answers (1)

user1627765
user1627765

Reputation: 21

Ok, figured it out. I needed to format the LabelStyle of AxisX - very simple actually :). Add the following to 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>

Upvotes: 1

Related Questions