How can i add labels for each and every yvalue in series of a rangebarchart ?
You all know that for plotting rangebartype series ,we need two yvalues as yvalue[0] and yvalue[1] .Here I need to add data labels to each of those yvalues( which means bot开发者_StackOverflow中文版h at yvalue[0] and yvalue[1]).how can i implement that?can anybody suggest me?please!!
The label should look like as below for a rangebar(to be displayed on both sides of a rangebar).
Label1 ███████████████ Label2
Label███████████████████ Label
There is no built-in way to do this in MS Chart. However, there is an ugly little workaround that will give you the display that you want.
For each datapoint (rangebar) that you want to display, you will need to create 2 datapoints that lie on top of one another. As an example:
DataPoint0: X=1 Y=5,10
DataPoint1: X=1 Y=10,5
These two datapoints lie right on top of one another, except one is displayed left-to-right and the other is displayed right-to-left.
For each DataPoint, under CustomProperties, there is the BarLabelStyle property. Set this to 'Outside' for both of the datapoints. Normally, this will display the label to the right of the range bar, but for DataPoint1, with the reversed Y values, the label is now placed to the left of the range bar. So, set your label for DataPoint0 to 10 (max value), and for DataPoint1 set the label to 5 (min value).
This will then look just like one range bar with the min value on the left and the max value on the right.
Caution: If either end of the range bar is too close to the edge of your graph, MS Chart, in its infinite wisdom, will force the label to be displayed inside the range bar. To overcome this, you can actually add a third number to the Y values of the DataPoint object. This third value is not displayed, but if it is larger than the largest Y value in your data series, it will force the chart to rescale to accommodate this larger value, so your labels are not forced inside the range bars. You could probably handle this another way with setting properties of the ChartArea also.
精彩评论