Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Barchart.xlabels[0] return type (Read 5113 times)
madhan1
Full Member
***
Offline


FOLLOW NO ONE BUT LEARN
FROM EVERY ONE ..

Posts: 101
Location: India
Joined: Feb 17th, 2010
Barchart.xlabels[0] return type
Jun 14th, 2012 at 10:35am
Print Post  
Dear team,

      i am using Barchart. i need to get the xlabels value.
i use object xlabel= barchart1.xlabels[0]; but i am not able to extract the values.kindly help
  

if you want something then go and grab it
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Barchart.xlabels[0] return type
Reply #1 - Jun 14th, 2012 at 12:01pm
Print Post  
Hello,

The labels depend on the LabelType of the axis, set through the AxisSettings.LabelType property. The XLabels property is used only for custom labels, so if the labels show the bar data or the auto scale this property will be an empty list.

Additionally, XLabels holds the labels for all bar series and it is a list that holds lists with labels. This means that if you want to get the first label of the first series you must use:

Code
Select All
IList labelsArray0 = BarChart1.XLabels[0] as IList;
string label1 = labelsArray0[1].ToString();
 



The following code gets the values shown as labels at the axis in various AxisType scenarios:

Code
Select All
 /* if labels are custom-specified, then the labels for each bar series is given as
 * an array in the XLabels or YLabels property, which is also a list */
if (BarChart1.XAxisSettings.LabelType == MindFusion.Charting.AxisLabelType.CustomText)
{
	IList labelsArray0 = BarChart1.XLabels[0] as IList;
	string label1 = labelsArray0[1].ToString();

}
/* if the labels show the data of the bar then they show meaningful numbers only for the
 * X-axis in horizontal bars and the Y-axis for vertical bars */
if (BarChart1.YAxisSettings.LabelType == MindFusion.Charting.AxisLabelType.ChartData)
{
	IList dataArray0 = BarChart1.Data[0] as IList;
	double number1 = (double)dataArray0[1];

}
/* if the labels show the chart data, then for the X-axis in vertical bars these
 * are the numbers 0, 1, 2, 3... count_of_bars - 1. The same is true for horizontal
 * bars and Y-labels */
if (BarChart1.XAxisSettings.LabelType == MindFusion.Charting.AxisLabelType.ChartData)
{
	double number1 = 1.0;
}
/* if the labels show the auto scale you can caluclate them based on the start value of
 * the axis and the interval. If AxisSettings.MinValue and AxisSettings.AxisDelta are
 * not set there is currently no way to get them */
if (BarChart1.XAxisSettings.LabelType == MindFusion.Charting.AxisLabelType.AutoScale)
{
	double number2 =
		BarChart1.XAxisSettings.MinValue + 2 * BarChart1.XAxisSettings.AxisDelta;
} 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
madhan1
Full Member
***
Offline


FOLLOW NO ONE BUT LEARN
FROM EVERY ONE ..

Posts: 101
Location: India
Joined: Feb 17th, 2010
Re: Barchart.xlabels[0] return type
Reply #2 - Jun 15th, 2012 at 5:05am
Print Post  
Thanks stoyo..
  it works.
  

if you want something then go and grab it
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint