如何显示特定范围使用ASP.NET图表Y值(MS图表) [英] How To Display Specific Range For Y Values Using ASP.NET Charts (MS Charts)

查看:121
本文介绍了如何显示特定范围使用ASP.NET图表Y值(MS图表)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用ASP.NET图表首次和时遇到了巨大的成功。有一件事我想要做的就是放大我的图表上,这样y值不会从0-100走。例如,说我有,从72到89点的一些价值观,我想什么做的是有最低y值是72,最高y值89在y轴(它是当前显示0作为最低, 100为最高)。这里的code我使用的是:

 < ASP:图表ID =Chart1ImageLocation =〜/内容/图像/温度/图表/ ChartPic_#SEQ(300,3)HEIGHT =325px宽=900px=服务器>
    <标题和GT;
        < ASP:标题文本=概述字体=宋体,12磅,作风大胆=/>
    < /标题和GT;
    <传说与GT;
        < ASP:联想字体=濑越UI,8PT对齐=中心边框宽度=1BorderDashStyle =实BORDERCOLOR =#C6C6C6对接=底/>
    < /传说与GT;
    < ChartAreas>
        < ASP:ChartArea NAME =ChartArea1>
            < AxisY LineColor =#C6C6C6IsInterlaced =真InterlacedColor =#F0F0F0>
                < LabelStyle字体=濑越UI,8PT前景色=#787878/>
                < MajorGrid LineColor =#C6C6C6/>
            < / AxisY>
            &所述; AxisX LineColor =#C6C6C6>
                < LabelStyle字体=濑越UI,8PT前景色=#787878/>
                < MajorGrid LineColor =#C6C6C6/>
            < / AxisX>
        < / ASP:ChartArea>
    < / ChartAreas>
< / ASP:图表>保护无效的Page_Load(对象发件人,EventArgs的发送)
{
    VAR系列=新系列(概览)
    {
        NAME =系列1,
        图图表= SeriesChartType.Line,
        MarkerStyle = MarkerStyle.Circle,
        MarkerSize = 7,
        XValueType = ChartValueType.Date,
        YValueType = ChartValueType.Double,
    };    的foreach(在调查VAR调查)
    {
        series.Points.AddXY(的String.Format({0:MMM YYYY},survey.Month),survey.Score);
    }    Chart1.Series.Add(系列);
}


解决方案

您需要更改<一个href=\"http://msdn.microsoft.com/en-us/library/system.web.ui.datavisualization.charting.axis.minimum.aspx\">Minimum和<一个href=\"http://msdn.microsoft.com/en-us/library/system.web.ui.datavisualization.charting.axis.maximum.aspx\">Maximum属性的<一个href=\"http://msdn.microsoft.com/en-us/library/system.web.ui.datavisualization.charting.chartarea.axisy.aspx\">AxisY您<属性href=\"http://msdn.microsoft.com/en-us/library/system.web.ui.datavisualization.charting.chartarea.aspx\">ChartArea.

所以,在你的的Page_Load code(或任何你需要/ preFER它),你可以做这样的事情:

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

您可以设置其他一些很酷的事情(比如设置<一个href=\"http://msdn.microsoft.com/en-us/library/system.web.ui.datavisualization.charting.axis.interval.aspx\">Interval)从 AxisY / AxisX 属性。

I'm using ASP.NET charts for the first time and am having great success. The one thing I'm wanting to do is zoom in on my chart so that the y values don't go from 0-100. For example, Say I have some point values ranging from 72 to 89. What I'd like to do is have the lowest y value be 72 and the highest y value be 89 on the y axis (it's currently displaying 0 as the lowest and 100 as the highest). Here's the code I'm using:

<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);
}

解决方案

You need to change the Minimum and Maximum properties of the AxisY property of your ChartArea.

So, in your Page_Load code (or wherever you need / prefer it), you could do something like this:

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

You can set some other cool things (like set the Interval) from that AxisY / AxisX property.

这篇关于如何显示特定范围使用ASP.NET图表Y值(MS图表)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆