2011-11-18 67 views
2

我第一次使用ASP.NET图表并取得了巨大成功。我想要做的一件事是放大我的图表,以便y值不会从0到100。例如,假设我有一些从72到89的点值。我想要做的是将y值最低的值设为72,y值最高的y值设置为89(目前显示值为0,最低值为100作为最高)。下面是我使用的代码:如何使用ASP.NET图表显示Y值的特定范围(MS图表)

<asp:Chart ID="Chart1" ImageLocation="~/content/images/temp/charts/ChartPic_#SEQ(300,3)" Height="325px" Width="900px" runat="server"> 
    <Titles> 
     <asp:Title Text="Overview" Font="Arial, 12pt, style=Bold" /> 
    </Titles> 
    <Legends> 
     <asp:Legend Font="Segoe UI, 8pt" Alignment="Center" BorderWidth="1" BorderDashStyle="Solid" BorderColor="#C6C6C6" Docking="Bottom" /> 
    </Legends> 
    <ChartAreas> 
     <asp:ChartArea Name="ChartArea1"> 
      <AxisY LineColor="#C6C6C6" IsInterlaced="true" InterlacedColor="#F0F0F0"> 
       <LabelStyle Font="Segoe UI, 8pt" ForeColor="#787878" /> 
       <MajorGrid LineColor="#C6C6C6" /> 
      </AxisY> 
      <AxisX LineColor="#C6C6C6"> 
       <LabelStyle Font="Segoe UI, 8pt" ForeColor="#787878" /> 
       <MajorGrid LineColor="#C6C6C6" /> 
      </AxisX> 
     </asp:ChartArea> 
    </ChartAreas> 
</asp:Chart> 

protected void Page_Load(object sender, EventArgs e) 
{ 
    var series = new Series("Overview") 
    { 
     Name = "Series1", 
     ChartType = SeriesChartType.Line, 
     MarkerStyle = MarkerStyle.Circle, 
     MarkerSize = 7, 
     XValueType = ChartValueType.Date, 
     YValueType = ChartValueType.Double,      
    }; 

    foreach (var survey in Surveys) 
    { 
     series.Points.AddXY(String.Format("{0:MMM yyyy}", survey.Month), survey.Score); 
    } 

    Chart1.Series.Add(series); 
} 

回答

5

你需要改变你的ChartAreaAxisY财产MinimumMaximum性能。

所以,在你Page_Load代码(或任何你需要/喜欢它),你可以做这样的事情:

ChartArea1.AxisY.Minimum = 72; 
ChartArea1.AxisY.Maximum = 89; 

您可以从AxisY设置其他一些很酷的东西(如设置Interval)/AxisX财产。

+0

真棒!感谢您的专业知识。有这么多的属性,我真的不知道该找什么。这正是我需要的! – Halcyon

+0

@Halcyon难道我不知道!我刚刚才知道使用它之前的控制权。这就是这个网站真棒=) – jadarnel27

0

我想结合AJAX使用和正常方法保持崩溃的页面:

ChartArea.AxisY.Minimum = 100; 
ChartArea.AxisY.Maximum = 100; 

我可以用它来代替这个获得:

AxisScaleView yAxisScaleView = new AxisScaleView(); 
yAxisScaleView.Size = 100; 
ChartArea.AxisY.ScaleView = yAxisScaleView; 
相关问题