This is a migrated thread and some comments may be shown as answers.

ZoomScrollSettingsY setting in ChartArea makes the index on Y-axis displayed twice

2 Answers 69 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Sheetal
Top achievements
Rank 1
Sheetal asked on 29 Jun 2010, 02:07 PM
I have created a Bar graph with two series. See below code. I am alos using the Zoom feature. I have set the ChartArea to 

ZoomScrollSettingsY and the ScrollMode to ScrollAndZoom. Under certain conditions when zooming in, the index on the Y-axis is repeated twice. Please see attached image. How can this be prevented?

private

 

 

void BindDataToChart()

{

RadChart1.DefaultView.ChartArea.DataSeries.Clear();

 

DataSeries seriesCategory1 = new DataSeries();

DataSeries seriesCategory2 = new DataSeries();

int startIndx = 0;

int endIndx = _ForecastViewModel.ForecastSummary[0].Count();

int i = 0;

int nIndx = 0;

string category = "";

for (nIndx = startIndx; nIndx < endIndx; nIndx++)

{

 

 

ForecastSummaryData data = (ForecastSummaryData)(_ForecastViewModel.ForecastSummary[0][nIndx]);

DataPoint category1dataPoint = new DataPoint();

DataPoint category2dataPoint = new DataPoint();

category = data.category;

 

string year = "";

 

if (category == "1") {

 

 

category1dataPoint.LegendLabel = 

"1";

 

 

 

category1dataPoint.XValue =

double.Parse(data.month);
if (data.schedule_amount > 0)
category1dataPoint.YValue = (
double)(data.amount / 1000);
category1dataPoint.XCategory =
Convert.ToString(data.monthname.TrimEnd().Substring(0, 3) + " " + year);

 

 

 

category1dataPoint.Tooltip =

String.Format("{0} contracts/{1:C}", data.count, (double)(data.amount));

 

 

 seriesCategory1.Add(category1dataPoint);

}

else {

 

 

category2dataPoint.LegendLabel =

"2";

 

 

 

category2dataPoint.XValue =

double.Parse(data.month);

 

 

if (data.schedule_amount > 0)
category2dataPoint.YValue = (
double)(data.amount / 1000);

 

 

 

category2dataPoint.XCategory =

Convert.ToString(data.monthname.TrimEnd().Substring(0, 3) + " " + year);

 

 

 

category2dataPoint.Tooltip =

String.Format("{0} contracts/{1:C}", data.count, (double)(data.amount));

 

 

 

seriesCategory2.Add(category2dataPoint);

}

}

 

 

 

// Set the bar chart properties  

 

RadChart1.DefaultView.ChartArea.DataSeries.Clear();

RadChart1.DefaultView.ChartArea.LabelFormatBehavior =

LabelFormatBehavior.HumanReadable;

 

 

 

RadChart1.DefaultView.ChartArea.AxisY.DefaultLabelFormat = (

"$0K");
RadChart1.DefaultView.ChartArea.AxisX.LayoutMode =
AxisLayoutMode.Between;
RadChart1.DefaultView.ChartArea.AxisX.Step = 2;

 

 

 

RadChart1.DefaultView.ChartArea.AxisX.LabelRotationAngle = 45;

 

 

RadChart1.DefaultView.ChartLegend.HorizontalAlignment =

HorizontalAlignment.Right;

 

 

RadChart1.DefaultView.ChartLegend.FontSize = 10;

seriesCategory1.LegendLabel =

"Scheduled";
seriesCategory1.Definition =
new BarSeriesDefinition();

 

 

 

seriesCategory2.LegendLabel =

"Unscheduled";

 

 

 

seriesCategory2.Definition =

 

 

new BarSeriesDefinition();
byte[] fillColor1 = { 255, 106, 148, 200 };
byte[] strokeColor1 = { 255, 106, 148, 200 };

 

 

SetBarLayout((

BarSeriesDefinition)seriesCategory1.Definition,

 

 

fillColor1,

strokeColor1,

4d,

3);

 

byte[] fillColor2 = { 255, 145, 178, 80 };
byte[] strokeColor2 = { 255, 145, 178, 80 };
SetBarLayout((
BarSeriesDefinition)seriesCategory2.Definition, fillColor2,

 

 

strokeColor2,

4d,

3);

 

if (endIndx == 0) {

 

 

 

RadChart1.ItemsSource = null;

 

 

 

RadChart1.DefaultView.ChartArea.IsNoDataMessageEnabled =

 

 

false;

 

}

 

else  

 

{

RadChart1.DefaultView.ChartArea.ZoomScrollSettingsY.ScrollMode =

ScrollMode.ScrollAndZoom; RadChart1.DefaultView.ChartArea.DataSeries.Add(seriesCategory1);

 

 

RadChart1.DefaultView.ChartArea.DataSeries.Add(seriesCategory2);

RadChart1.DefaultView.ChartArea.EnableAnimations =

false;

 

 

 

}

 

this.Cursor = Cursors.Arrow;

 

 

}

 

)

2 Answers, 1 is accepted

Sort by
0
Ves
Telerik team
answered on 02 Jul 2010, 08:49 AM
Hello Sheetal,

This is actually caused by the AxisY.DefaultLabelFormat setting. The format string you have used ("$0K") will not show any decimals. At the same time the automatic axis range algorithm has detected, that there is enough room to show the values like this: 0, 0.5, 1, 1.5, etc. So the first "$1K" is actually for 0.5, while the second is the correct one. You can set the DefaultLabelFormat like this: "$0.#K", so that the decimals are visible.

Alternatively, you can set the AxisY.AutoRange property to false and call the AddRange method supplying the desired MinValue, MaxValue and Step as parameters.

Best regards,
Ves
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Sheetal
Top achievements
Rank 1
answered on 06 Jul 2010, 09:43 PM
Thank you. Changing the DefaultLabelFormat to "$0.0k" worked.

Sheetal.
Tags
Chart
Asked by
Sheetal
Top achievements
Rank 1
Answers by
Ves
Telerik team
Sheetal
Top achievements
Rank 1
Share this question
or