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

Weird shrink behaviour on Chart

1 Answer 61 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Kristof
Top achievements
Rank 1
Kristof asked on 29 Apr 2011, 01:20 PM
Dear Telerik,

I attached a screenshot of the weird shrink behaviour. Seems like all the data moves up
to the right side for some unknown reason. (Yes the data is correctly inserted in the series)
Perhaps you guys have an idea what's causing this ?

Kind Regards,
Kristof

The chart is completely build in code:
-
//Define layout
BaseChart.AutoLayout = true;
BaseChart.AutoTextWrap = false;
BaseChart.Appearance.FillStyle.MainColor = Color.White;
BaseChart.PlotArea.Appearance.FillStyle.MainColor = Color.White;
BaseChart.PlotArea.Appearance.FillStyle.FillType = Telerik.Charting.Styles.FillType.Solid;

//Define XAxis
BaseChart.PlotArea.XAxis.AutoScale = false;
BaseChart.PlotArea.XAxis.AutoShrink = false;
BaseChart.PlotArea.XAxis.LayoutMode = Telerik.Charting.Styles.ChartAxisLayoutMode.Between;

//Define YAxis
BaseChart.PlotArea.YAxis.AutoScale = true;
BaseChart.PlotArea.YAxis.AxisLabel.TextBlock.Text = "";
BaseChart.PlotArea.YAxis.AxisLabel.Visible = true;

//Define ChartTitle
BaseChart.ChartTitle.Appearance.Position.AlignedPosition = Telerik.Charting.Styles.AlignedPositions.TopLeft;
BaseChart.ChartTitle.TextBlock.Text = "";
BaseChart.ChartTitle.TextBlock.Visible = false;
 
 
// Rest is just adding normal series...

1 Answer, 1 is accepted

Sort by
0
Kristof
Top achievements
Rank 1
answered on 02 May 2011, 12:48 PM
I found the solution myself:

The gaps on the x-axis were caused by the gap between the years (x-axis values)
In my code I was inserting the years that contain data on the x-axis. (in a for loop Chart.PlotArea.XAXis.Items.Add(..))
if I insert all the years the alignement of the data is correct. But then I have some empty bars in my chart.

Solution: I'm now binding the Years to the grid and using the DataLabelsColumn property on the X-Axis.

chart1.DataSource = Data.Select(d => d.Year).Distinct().ToList();
chart1.PlotArea.XAxis.DataLabelsColumn = "Year";

On the ChartSeriesItems I'm no longer defining an X-Value.
Tags
Chart (Obsolete)
Asked by
Kristof
Top achievements
Rank 1
Answers by
Kristof
Top achievements
Rank 1
Share this question
or