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

Chart Y Axis labels problem When AutoWrapText=True

6 Answers 191 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Sridhar Bolisetti
Top achievements
Rank 1
Sridhar Bolisetti asked on 08 Dec 2009, 11:03 AM
Hi,

Is there any possibility of setting the width of axis label when AutoWrapText=true? Text moving to next line even though there is space in first line. Please find attached files. Please suggest me how can I achieve like attached file.



Regards.

B.Sridhar

6 Answers, 1 is accepted

Sort by
0
Ves
Telerik team
answered on 10 Dec 2009, 08:42 AM
Hi Sridhar,

Please, set AutoLayout property to true. This will force RadChart to calculate the layout according to the space needed by the elements.
 
Regards,
Ves
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Sridhar Bolisetti
Top achievements
Rank 1
answered on 10 Dec 2009, 02:16 PM
I put Autolayout=true, but It is not working. text is moving to next line even though place is available. Is there feasibility to increase the width of the chart axis item when autowraptext=true.


Regards,

B.Sridhar
0
Ves
Telerik team
answered on 14 Dec 2009, 03:04 PM
Hello,

I am afraid this behavior cannot be further improved for the moment. This is why I recommended the AutoLayout functionality, so that RadChart calculates automatically the space needed for X axis labels.
 
Sincerely,
Ves
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Sridhar Bolisetti
Top achievements
Rank 1
answered on 21 Dec 2009, 02:39 AM
Hi,

I  put AutoWrapText=True for the items whose length is greater than with of the blank space. But the right alignment is not properly aligning for autowraptext items.

Please see the following code and attached image of the chart.

public static void FillGraph(Telerik.Reporting.Processing.Chart chart, List<BarGraph> list, string benchmarkname)
        {
            Chart definition = (Chart)chart.ItemDefinition;
            System.Drawing.Font font = new System.Drawing.Font("Arial", 10, FontStyle.Regular);
            System.Drawing.Font normalfont = new System.Drawing.Font("Arial", 10, FontStyle.Regular);
            ChartSeries series1 = new ChartSeries();
            series1.Name = "Benchmark Percentage for the " + benchmarkname;//"BenchmarkPercent";
            series1.DefaultLabelValue = "#Y" + "%";
            series1.DataYColumn = "Benchmark Percentage for the " + benchmarkname; //"BenchmarkPercent";
            series1.Appearance.FillStyle.FillType = Telerik.Reporting.Charting.Styles.FillType.Solid;
            series1.Appearance.FillStyle.MainColor = Color.DarkSlateBlue;
            series1.Appearance.TextAppearance.Dimensions.Margins.Right = Telerik.Reporting.Charting.Styles.Unit.Pixel(10);

            ChartSeries series2 = new ChartSeries();
            series2.Name = "Percentage of Questions Answered Correctly";//"AnsweredPercent";
            series2.DefaultLabelValue = "#Y" + "%";
            series2.DataYColumn = "Percentage of Questions Answered Correctly"; //"AnsweredPercent";
            series2.Appearance.FillStyle.FillType = Telerik.Reporting.Charting.Styles.FillType.Solid;
            series2.Appearance.FillStyle.MainColor = Color.Brown;
            series2.Appearance.TextAppearance.Dimensions.Margins.Right = Telerik.Reporting.Charting.Styles.Unit.Pixel(10);
            definition.Legend.Appearance.Position.AlignedPosition = Telerik.Reporting.Charting.Styles.AlignedPositions.Bottom;
            ChartAxisItemsCollection labels = new ChartAxisItemsCollection();
            int index = 0;
            foreach (BarGraph data in list)
            {

                ChartSeriesItem seriesItem1 = new ChartSeriesItem();
                seriesItem1.YValue = (double)data.BenchmarkPercent;
                seriesItem1.Appearance.FillStyle.FillType = Telerik.Reporting.Charting.Styles.FillType.Solid;
                seriesItem1.Appearance.FillStyle.MainColor = Color.DarkSlateBlue;
                seriesItem1.Label.TextBlock.Appearance.TextProperties.Font = font;
                seriesItem1.Label.TextBlock.Appearance.TextProperties.Color = Color.Black;
                series1.AddItem(seriesItem1);
                
                ChartSeriesItem seriesItem2 = new ChartSeriesItem();
                seriesItem2.YValue = (double)data.AnsweredPercent;
                seriesItem2.Appearance.FillStyle.FillType = Telerik.Reporting.Charting.Styles.FillType.Solid;
                seriesItem2.Appearance.FillStyle.MainColor = Color.Brown;
                seriesItem2.Label.TextBlock.Appearance.TextProperties.Font = font;
                seriesItem2.Label.TextBlock.Appearance.TextProperties.Color = Color.Black;
                series2.AddItem(seriesItem2);
                
                ChartAxisItem item = new ChartAxisItem(data.Name.Trim());
                labels.Add(item);


            }

           
            definition.Series.Clear();
            definition.Series.Add(series1);
            definition.Series.Add(series2);
            definition.IntelligentLabelsEnabled = false;
            definition.Legend.Appearance.Overflow = Telerik.Reporting.Charting.Styles.Overflow.Row;
            definition.Legend.Appearance.Border.Color = Color.Transparent;
            definition.Legend.TextBlock.Appearance.TextProperties.Font = normalfont;
            definition.PlotArea.Appearance.Dimensions.Width = 300;
            definition.PlotArea.Appearance.Position.X = 370;
            definition.Appearance.BarOverlapPercent = 0;
            definition.Appearance.BarWidthPercent = 60;
            
            //Formating X Axis
            definition.PlotArea.XAxis.Items.Clear();
            definition.PlotArea.XAxis.Items.AddRange(labels.ToArray());
            definition.PlotArea.XAxis.Appearance.Color = Color.Black;
            definition.PlotArea.XAxis.Appearance.TextAppearance.FillStyle.FillType =
                Telerik.Reporting.Charting.Styles.FillType.Solid;
            definition.PlotArea.XAxis.Appearance.TextAppearance.MaxLength = 245;
            definition.PlotArea.XAxis.Appearance.TextAppearance.TextProperties.Font = font;
            definition.PlotArea.XAxis.Appearance.TextAppearance.TextProperties.Color = Color.Black;
            definition.PlotArea.XAxis.Appearance.LabelAppearance.Position.AlignedPosition =
                Telerik.Reporting.Charting.Styles.AlignedPositions.Right;
            definition.PlotArea.XAxis.AutoShrink = false;
            definition.PlotArea.XAxis.AutoScale = false;
            
            //Formating Y Axis
            definition.PlotArea.YAxis.AutoScale = false;
            definition.PlotArea.YAxis.MinValue = 0;
            definition.PlotArea.YAxis.MaxValue = 100;
            definition.PlotArea.YAxis.Step = 20;
            definition.PlotArea.YAxis.Appearance.TextAppearance.TextProperties.Font = normalfont;
            definition.PlotArea.YAxis.Appearance.TextAppearance.TextProperties.Color = Color.Black;
            definition.PlotArea.YAxis.Visible = Telerik.Reporting.Charting.Styles.ChartAxisVisibility.True;
            definition.PlotArea.Appearance.FillStyle.FillType = Telerik.Reporting.Charting.Styles.FillType.Solid;
            definition.PlotArea.Appearance.FillStyle.MainColor = System.Drawing.Color.White;
            definition.PlotArea.YAxis.Appearance.MajorGridLines.Color = Color.LightGray;
            
            foreach (ChartAxisItem item in definition.PlotArea.XAxis.Items)
            {
                item.TextBlock.Appearance.TextProperties.Font = font;
                if (item.TextBlock.Text.Length > 55)
                {
                    
                    item.TextBlock.Text = item.TextBlock.Text.PadRight(125,'  ');
                    item.TextBlock.Appearance.AutoTextWrap = Telerik.Reporting.Charting.Styles.AutoTextWrap.True;
                 
                   
                }
               

            }
        }

Regards,

B.Sridhar
 
0
Ves
Telerik team
answered on 22 Dec 2009, 03:56 PM
Hi Sridhar,

Your code seems to be the correct one to achieve the desired effect. I tried it for myself and it worked as expected. I just moved the AutoScale setting to the top of the group of lines, which configures the X axis. Note, that the items you have in bold in your code snippet are related to bar labels and not to X axis item labels.

You can find my test project attached.


Sincerely,
Ves
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Sridhar Bolisetti
Top achievements
Rank 1
answered on 28 Dec 2009, 11:30 AM
Hi,

Thank you, it is working.



Regards,

B.Sridhar
Tags
General Discussions
Asked by
Sridhar Bolisetti
Top achievements
Rank 1
Answers by
Ves
Telerik team
Sridhar Bolisetti
Top achievements
Rank 1
Share this question
or