在X轴上显示Infragistics BarChart中的负值

时间:2011-11-30 13:21:01

标签: c# asp.net charts infragistics bar-chart

我需要在X轴上的Infragistics BarChart中显示负值。如果我使用:

设置它
  

chtAgingVsDueAmt.Axis.X.RangeMax = SOME_NEGATIVE_VALUE

抛出错误:

  

消息:传递给函数GetScale消息详细信息的错误参数:
  在Infragistics.UltraChart.Core.AnInterval.GetScale(Double xmin,   双xmax,Int32 n)at   Infragistics.UltraChart.Resources.Appearance.AxisAppearance.SmartAxisTickmarks(IAdvanceAxis   轴)在......

如何在X轴上的Infragistics BarChart中显示负值?

1 个答案:

答案 0 :(得分:2)

我在NA 11.2.20112.2025。代码背后:

 protected void Page_Load(object sender, EventArgs e)
{

    DataTable dt = new DataTable();
    dt.Columns.Add("year", typeof(string));
    dt.Columns.Add("numUsers", typeof(int));
    dt.Rows.Add(new object[] { "2005", -100 });
    dt.Rows.Add(new object[] { "2006", 160 });
    dt.Rows.Add(new object[] { "2007", -250 });
    dt.Rows.Add(new object[] { "2008", 500 });
    dt.Rows.Add(new object[] { "2009", -860 });
    dt.Rows.Add(new object[] { "2010", 600 });
    UltraChart1.Axis.X.RangeMin = -200;
    UltraChart1.Axis.X.RangeMax = 500;
    UltraChart1.Data.DataSource = dt;
    UltraChart1.ChartType = ChartType.BarChart;
    UltraChart1.Data.DataBind();

}

标记:

    <igchart:UltraChart ID="UltraChart1" runat="server" ChartType="BarChart" EmptyChartText="Data Not Available. Please call UltraChart.Data.DataBind() after setting valid Data.DataSource"
    Version="11.1">
    <Effects>
        <Effects>
            <igchartprop:GradientEffect />
        </Effects>
    </Effects>
    <ColorModel AlphaLevel="150" ColorBegin="Pink" ColorEnd="DarkRed" ModelStyle="CustomSkin"
        Scaling="Oscillating">
    </ColorModel>
    <Axis>
        <PE ElementType="None" Fill="Cornsilk"></PE>
        <X Visible="True" TickmarkInterval="40" LineThickness="1" TickmarkStyle="Smart">
            <MajorGridLines Visible="True" DrawStyle="Dot" Color="Gainsboro" Thickness="1" AlphaLevel="255">
            </MajorGridLines>
            <MinorGridLines Visible="False" DrawStyle="Dot" Color="LightGray" Thickness="1" AlphaLevel="255">
            </MinorGridLines>
            <Labels ItemFormatString="&lt;DATA_VALUE:00.##&gt;" HorizontalAlign="Far" VerticalAlign="Center"
                Orientation="VerticalLeftFacing" Font="Verdana, 7pt" FontColor="DimGray">
                <SeriesLabels HorizontalAlign="Far" VerticalAlign="Center" Orientation="VerticalLeftFacing"
                    Font="Verdana, 7pt" FontColor="DimGray" FormatString="">
                    <Layout Behavior="Auto">
                    </Layout>
                </SeriesLabels>
                <Layout Behavior="Auto">
                </Layout>
            </Labels>
        </X>
        <Y Visible="True" TickmarkInterval="0" LineThickness="1" TickmarkStyle="Smart">
            <MajorGridLines Visible="True" DrawStyle="Dot" Color="Gainsboro" Thickness="1" AlphaLevel="255">
            </MajorGridLines>
            <MinorGridLines Visible="False" DrawStyle="Dot" Color="LightGray" Thickness="1" AlphaLevel="255">
            </MinorGridLines>
            <Labels ItemFormatString="&lt;ITEM_LABEL&gt;" HorizontalAlign="Far" VerticalAlign="Center"
                Orientation="Horizontal" Font="Verdana, 7pt" FontColor="DimGray">
                <SeriesLabels HorizontalAlign="Center" VerticalAlign="Center" Orientation="VerticalLeftFacing"
                    Font="Verdana, 7pt" FontColor="DimGray">
                    <Layout Behavior="Auto">
                    </Layout>
                </SeriesLabels>
                <Layout Behavior="Auto">
                </Layout>
            </Labels>
        </Y>
        <Y2 Visible="False" TickmarkInterval="0" LineThickness="1" TickmarkStyle="Smart">
            <MajorGridLines Visible="True" DrawStyle="Dot" Color="Gainsboro" Thickness="1" AlphaLevel="255">
            </MajorGridLines>
            <MinorGridLines Visible="False" DrawStyle="Dot" Color="LightGray" Thickness="1" AlphaLevel="255">
            </MinorGridLines>
            <Labels ItemFormatString="&lt;ITEM_LABEL&gt;" Visible="False" HorizontalAlign="Near"
                VerticalAlign="Center" Orientation="Horizontal" Font="Verdana, 7pt" FontColor="Gray">
                <SeriesLabels HorizontalAlign="Center" VerticalAlign="Center" Orientation="VerticalLeftFacing"
                    Font="Verdana, 7pt" FontColor="Gray">
                    <Layout Behavior="Auto">
                    </Layout>
                </SeriesLabels>
                <Layout Behavior="Auto">
                </Layout>
            </Labels>
        </Y2>
        <X2 Visible="False" TickmarkInterval="40" LineThickness="1" TickmarkStyle="Smart">
            <MajorGridLines Visible="True" DrawStyle="Dot" Color="Gainsboro" Thickness="1" AlphaLevel="255">
            </MajorGridLines>
            <MinorGridLines Visible="False" DrawStyle="Dot" Color="LightGray" Thickness="1" AlphaLevel="255">
            </MinorGridLines>
            <Labels ItemFormatString="&lt;DATA_VALUE:00.##&gt;" Visible="False" HorizontalAlign="Far"
                VerticalAlign="Center" Orientation="VerticalLeftFacing" Font="Verdana, 7pt" FontColor="Gray">
                <SeriesLabels HorizontalAlign="Far" VerticalAlign="Center" Orientation="VerticalLeftFacing"
                    Font="Verdana, 7pt" FontColor="Gray" FormatString="">
                    <Layout Behavior="Auto">
                    </Layout>
                </SeriesLabels>
                <Layout Behavior="Auto">
                </Layout>
            </Labels>
        </X2>
        <Z Visible="False" TickmarkInterval="0" LineThickness="1" TickmarkStyle="Smart">
            <MajorGridLines Visible="True" DrawStyle="Dot" Color="Gainsboro" Thickness="1" AlphaLevel="255">
            </MajorGridLines>
            <MinorGridLines Visible="False" DrawStyle="Dot" Color="LightGray" Thickness="1" AlphaLevel="255">
            </MinorGridLines>
            <Labels ItemFormatString="" HorizontalAlign="Near" VerticalAlign="Center" Orientation="Horizontal"
                Font="Verdana, 7pt" FontColor="DimGray" Visible="False">
                <SeriesLabels HorizontalAlign="Near" VerticalAlign="Center" Orientation="Horizontal"
                    Font="Verdana, 7pt" FontColor="DimGray">
                    <Layout Behavior="Auto">
                    </Layout>
                </SeriesLabels>
                <Layout Behavior="Auto">
                </Layout>
            </Labels>
        </Z>
        <Z2 Visible="False" TickmarkInterval="0" LineThickness="1" TickmarkStyle="Smart">
            <MajorGridLines Visible="True" DrawStyle="Dot" Color="Gainsboro" Thickness="1" AlphaLevel="255">
            </MajorGridLines>
            <MinorGridLines Visible="False" DrawStyle="Dot" Color="LightGray" Thickness="1" AlphaLevel="255">
            </MinorGridLines>
            <Labels ItemFormatString="" Visible="False" HorizontalAlign="Near" VerticalAlign="Center"
                Orientation="Horizontal" Font="Verdana, 7pt" FontColor="Gray">
                <SeriesLabels HorizontalAlign="Near" VerticalAlign="Center" Orientation="VerticalLeftFacing"
                    Font="Verdana, 7pt" FontColor="Gray">
                    <Layout Behavior="Auto">
                    </Layout>
                </SeriesLabels>
                <Layout Behavior="Auto">
                </Layout>
            </Labels>
        </Z2>
    </Axis>
    <Tooltips Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False"
        Font-Underline="False" />
</igchart:UltraChart>

它显示我的正负整数也毫无例外......即使我没有设置最小/最大范围,样本也能正常工作