使用MSChart的数据点设置标签 [英] set labels on datapoints using mschart

查看:1029
本文介绍了使用MSChart的数据点设置标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想自定义的数据点标签下面,这样他们就为渲染(使用图表上的数据点首次作为一个例子):

I would like to customize the labels on the datapoints below so they would render as (using first datapoint on the chart as an example) :

4:10 - 4:40
黄色类

4:10 - 4:40 yellow class

推荐答案

数据点有可以编程设置一个标签属性:

Datapoint has a label property that can be set programatically:

DataPoint dp = new DataPoint();
dp.Label = c.Start.ToShortTimeString() + " - " + c.End.ToShortTimeString() + "\n" + c.Class;

您可以在一系列通过遍历数据点后绑定:

You can iterate through the datapoints in a series after databinding:

foreach (DataPoint d in Chart1.Series[0].Points)
        {
          d.Label = "somevalue";
        } 

或者你也可以设置的值,当您进行数据绑定:

Or you can set the values when you databind:

Chart1.Series[0].Points.DataBind(datasource, "xField", "yField", "Label={somevalue}");

这篇关于使用MSChart的数据点设置标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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