English 中文(简体)
如何使用 ASP. Net 图表控件确定数据点的高度?
原标题:How does one determine the height of a data point using the ASP.Net charting controls?

我有一个堆叠的列表 像这样:

""https://i.sstatic.net/RpD5d.gif" alt="此处输入图像描述"/ >

我使用文字注释来显示右侧最堆叠的列中的 2495 美元。 我通过实验确定了正确的 y 位置 - 显然这对动态生成的内容不起作用 。

有人知道我如何确定组成列的数据点的高度吗?

Chart1.Series[0][0].Height + Chart1.Series[1][0].Height + Chart1.Series[3][0].Height + Chart1.Series[4][0].Height

但是,可惜,这显然不是那么简单,任何想法或洞察力都将非常感激。

问题回答

结果发现它比我想的简单得多... 注释使用chart 坐标。 这意味着你只需要对实际的 values 进行总和,然后用它作为 Y 坐标。 我这样做是为了计算相应序列的高度 :

private int CalculateHeight(int i, ChartGraphics graphics)
{
    var height = 0.0;

    // find the respective heights of series i, add them together
    for (var x = 0; x < this.Chart1.Series.Count(); x++)
    {
        height += this.Chart1.Series[x].Points[i].YValues[0]; 
    }

    return (int)height;
}

然后,我这样称呼这个函数:

        for (var i = 0; i < chart.Series[0].Points.Count(); i++ )
        {
            var height = this.CalculateHeight(i, e.ChartGraphics);

            this.Chart1.Annotations[i].Y = height + verticalPadding;
        }

比我想的简单多了





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签