Stacked Bar Chart Alignment

Thread is closed for posting
2 posts, 0 answers
  1. Michael
    Michael avatar
    27 posts
    Member since:
    May 2011

    Posted 27 Jan 2012 Link to this post

    Reference the attached image.  The XAxis labels are perfectly centered between the major grid lines however the series items (as stacked bar chart) are not.  I've seen numerous examples within the help documentation of the stacked bar chart showing the bars centered between the major grid lines as well as the labels but without the markup for it there is no way to see how it was done.  Can someone please tell me how to get this aligned properly (what property/attribute sets it) and what, if any, related properties/attributes need to be set to (i.e. auto-layout enabled or disabled, auto-scale - true or false, etc.).
  2. Yavor
    Yavor avatar
    401 posts

    Posted 31 Jan 2012 Link to this post

    Hello Michael,

    Bar series are most properly displayed using categories. For example if you have 4 categories (A, B, C and D) and you want to map 4 values to them you can do something like this:

    protected void Page_Load(object sender, EventArgs e)
        var data = new List<Tuple<string, double>>()
            new Tuple<string, double>("A", 12),
            new Tuple<string, double>("B", 22),
            new Tuple<string, double>("C", 17),
            new Tuple<string, double>("D", 27),
        this.chart1.DataSource = data;
        this.chart1.PlotArea.XAxis.DataLabelsColumn = "Item1";
        this.chart1.DataManager.ValuesYColumns = new string[] { "Item2" };

    You can also achieve the same effect by adding your data manually. Here is some code:
    protected void Page_Load(object sender, EventArgs e)
        this.chart1.PlotArea.XAxis.AutoScale = false;
        var series = new Telerik.Charting.ChartSeries();

    Hope this helps! Greetings,
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  3. DevCraft R3 2016 release webinar banner
Back to Top