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

Cannot Get X-Axis Labels Correct

2 Answers 34 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Wayne
Top achievements
Rank 1
Wayne asked on 21 Nov 2012, 02:47 PM
I am using the code-behind for the report designer tool

Here is my output with only one x-axis label displaying, but I ultimately need all the labels to display and eventually get the series stacked. I've been busting my head against this.

Report Image

Here is my sample code to show my issue:

void chart1_NeedDataSource(object sender, EventArgs e)
        {
            chart1.PlotArea.Appearance.Dimensions.Margins = "5%";
            chart1.PlotArea.Appearance.Dimensions.Margins.Bottom.Type = Telerik.Reporting.Charting.Styles.UnitType.Percentage;
            chart1.PlotArea.Appearance.Dimensions.Margins.Bottom.Value = 15f;
            chart1.PlotArea.Appearance.Dimensions.Margins.Left.Type = Telerik.Reporting.Charting.Styles.UnitType.Percentage;
            chart1.PlotArea.Appearance.Dimensions.Margins.Left.Value = 15f;
            chart1.Legend.Visible = false;
            chart1.ChartTitle.Visible = false;
 
            chart1.PlotArea.XAxis.Appearance.LabelAppearance.RotationAngle = 45;
                                     
            chart1.PlotArea.XAxis.Clear();
            chart1.PlotArea.XAxis.AutoScale = false;
            chart1.PlotArea.XAxis.AddRange(1, 5, 1);
            chart1.PlotArea.XAxis[0].TextBlock.Text = "Test";
            chart1.PlotArea.XAxis[1].TextBlock.Text = "Test2";
            chart1.PlotArea.XAxis[2].TextBlock.Text = "Test3";
            chart1.PlotArea.XAxis[3].TextBlock.Text = "Test4";
            chart1.PlotArea.XAxis[4].TextBlock.Text = "Test5";
 
            chart1.Series.Add(new Telerik.Reporting.Charting.ChartSeries() { Name = "Test" });
 
            double[] testData = { 5, 6, 7, 8, 9 };
            foreach (double item in testData)
            {
                chart1.Series[0].AddItem(item);
            }
        }

2 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 21 Nov 2012, 03:25 PM
Hi Wayne,

The code you've provided is correct and we verified it works as expected locally. There must be some other setting that you probably set through report designer that causes the issue. For example did you verify that the NeedDataSource event is fired and your code is executed? You can use your code on a new chart item and it would work, so if you're still having problems, we would appreciate if you open a support ticket and attach a problematic report we can review.

Regards,
Steve
the Telerik team

HAPPY WITH TELERIK REPORTING? Do you feel that it is fantastic? Or easy to use? Or better than Crystal Reports? Tell the world, and help fellow developers! Write a short review about Telerik Reporting and Telerik Report Designer in Visual Studio Gallery today!

0
Wayne
Top achievements
Rank 1
answered on 21 Nov 2012, 03:29 PM
I did confirm the code was running, set a breakpoint. Will try creating a new chart with default settings and see how that works.
Tags
General Discussions
Asked by
Wayne
Top achievements
Rank 1
Answers by
Steve
Telerik team
Wayne
Top achievements
Rank 1
Share this question
or