Weird shrink behaviour on Chart

Thread is closed for posting
2 posts, 0 answers
  1. Kristof
    Kristof avatar
    3 posts
    Member since:
    Apr 2011

    Posted 29 Apr 2011 Link to this post

    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...
  2. Kristof
    Kristof avatar
    3 posts
    Member since:
    Apr 2011

    Posted 02 May 2011 Link to this post

    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.
Back to Top