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

ChartTitle Wrapping

13 Answers 146 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Kludge
Top achievements
Rank 1
Kludge asked on 10 Jul 2008, 03:09 AM
Hi all,

Is it possible for the ChartTitle TextBox to size automatically (height in particular) to accommodate the title text?  This is particularly an issue with wrapped text.  I would rather not set a fixed height.

13 Answers, 1 is accepted

Sort by
0
Giuseppe
Telerik team
answered on 10 Jul 2008, 06:27 AM
Hi Roger Helliwell,

You can use the AutoTextWrap feature(example here and documentation here) provided by the RadChart control like this:

<telerik:RadChart ID="RadChart1" runat="Server"
    <Series> 
        <telerik:ChartSeries Name="Series 1"
            <Items> 
                <telerik:ChartSeriesItem Name="Item 1" YValue="1"
                </telerik:ChartSeriesItem> 
                <telerik:ChartSeriesItem Name="Item 2" YValue="3"
                </telerik:ChartSeriesItem> 
                <telerik:ChartSeriesItem Name="Item 3" YValue="19"
                </telerik:ChartSeriesItem> 
                <telerik:ChartSeriesItem Name="Item 4" YValue="4"
                </telerik:ChartSeriesItem> 
            </Items> 
        </telerik:ChartSeries> 
    </Series> 
    <ChartTitle> 
        <TextBlock Appearance-AutoTextWrap="True" Text="Some long chart title text Some long chart title text"
        </TextBlock> 
    </ChartTitle> 
</telerik:RadChart> 




Greetings,
Manuel
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Kludge
Top achievements
Rank 1
answered on 10 Jul 2008, 01:01 PM
Hi Manuel,

Thanks for your reply.  I did try the AutoWrap but my plot area overlaps the text.  Any ideas?
0
Giuseppe
Telerik team
answered on 10 Jul 2008, 01:11 PM
Hi Roger Helliwell,

You can enable the AutoLayout functionality of the chart control as well -- online example can be found here and the documentation here.


Greetings,
Manuel
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Kludge
Top achievements
Rank 1
answered on 11 Jul 2008, 04:42 PM
As soon as I enable Auto Layout on my chart I get an exception.  Interestingly, if I choose a vertical layout on my bar chart I don't get the exception.  I need to use a horizontal layout.  Any ideas?

Thanks in advance,

J
0
Ves
Telerik team
answered on 14 Jul 2008, 06:38 AM
Hello Roger,

I have attached a sample, based on the snippet provided by Manuel and it works fine for me. Can you please send us an example or modify the attachment, so that the exception is reproduced?

Looking forward to hearing from you,
Ves
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Kludge
Top achievements
Rank 1
answered on 15 Jul 2008, 02:00 PM
Your sample worked fine.  It would be difficult to send you a package that replicates the error.  The chart control is wrapped in a user control.  Series data is taken from a database.  Here is the relevant stack trace:

[ArgumentOutOfRangeException: Length cannot be less than zero.
Parameter name: length]
   System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy) +2916097
   Telerik.Charting.TextBlock.get_VisibleText() +104
   Telerik.Charting.TextBlockAxisItem.Measure(RenderEngine renderEngine) +94
   Telerik.Charting.TextBlockAxisItem.DefineMaxLengthAuto(RenderEngine renderEngine) +206
   Telerik.Charting.ChartXAxis.CalculateAxisItemsLayout(RenderEngine renderEngine, Nullable`1 maxBound) +3203
   Telerik.Charting.ChartXAxis.CalculateLayout(RenderEngine renderEngine) +182
   Telerik.Charting.RenderEngine.CalculateElementsForRender(IContainer element) +286
   Telerik.Charting.RenderEngine.CalculateElementsForRender(Chart chart) +7397
   Telerik.Charting.RenderEngine.CalculateElementsForRender() +27
   Telerik.Charting.Chart.GetImage(Int32 width, Int32 height) +355

[ChartException: An Unexpected error has occurred. Please review the InnerException for more information how to resolve the problem.]
   Telerik.Charting.Chart.GetException(RenderEngine renderEngine, Exception ex) +471
   Telerik.Charting.Chart.GetImage(Int32 width, Int32 height) +631
   Telerik.Web.UI.RadChart.RenderClassic(HtmlTextWriter writer) +149
   Telerik.Web.UI.RadChart.RenderContents(HtmlTextWriter writer) +351
   System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer) +29
   Telerik.Web.UI.RadDataBoundControl.Render(HtmlTextWriter writer) +9
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +22
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +199
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +20
   System.Web.UI.Control.Render(HtmlTextWriter writer) +7
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +22
   System.Web.UI.WebControls.MultiView.Render(HtmlTextWriter writer) +23
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +22
0
Giuseppe
Telerik team
answered on 15 Jul 2008, 03:30 PM
Hi Roger Helliwell,

Unfortunately we will need a bit more details in order to advise you properly. Could you paste the chart declaration you are using or alternatively it would be best if you could modify the attached in previous posts sample so we can observe the problem locally as well.


Kind regards,
Manuel
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Kludge
Top achievements
Rank 1
answered on 15 Jul 2008, 10:56 PM

No problem.  Here is the .aspx code:

<telerik:RadChart ID="RadChart1" runat="server" Skin="Web20" Height="500px" 
        Width="600px" AutoLayout="True" AutoTextWrap="True" DefaultType="Bar">  
        <Series> 
            <telerik:ChartSeries Type="Bar">  
                <Appearance> 
                    <FillStyle FillType="ComplexGradient">  
                        <FillSettings> 
                            <ComplexGradient> 
                                <telerik:GradientElement Color="213, 247, 255" /> 
                                <telerik:GradientElement Color="193, 239, 252" Position="0.5" /> 
                                <telerik:GradientElement Color="157, 217, 238" Position="1" /> 
                            </ComplexGradient> 
                        </FillSettings> 
                    </FillStyle> 
                    <TextAppearance TextProperties-Color="103, 136, 190">  
                    </TextAppearance> 
                </Appearance> 
            </telerik:ChartSeries> 
        </Series> 
        <PlotArea> 
            <XAxis> 
                <Appearance Color="149, 184, 206" MajorTick-Color="149, 184, 206">  
                    <MajorGridLines Color="209, 221, 238" Width="0" /> 
                </Appearance> 
            </XAxis> 
            <YAxis> 
                <Appearance Color="149, 184, 206" MajorTick-Color="149, 184, 206"   
                    MinorTick-Color="149, 184, 206">  
                    <MajorGridLines Color="209, 221, 238" /> 
                    <MinorGridLines Color="209, 221, 238" /> 
                </Appearance> 
            </YAxis> 
            <Appearance> 
                <FillStyle FillType="Solid" MainColor="249, 250, 251">  
                </FillStyle> 
                <Border Color="149, 184, 206" /> 
            </Appearance> 
        </PlotArea> 
        <Appearance> 
            <Border Color="103, 136, 190" Visible="False" /> 
        </Appearance> 
        <ChartTitle> 
            <Appearance> 
                <FillStyle MainColor="">  
                </FillStyle> 
            </Appearance> 
            <TextBlock> 
                <Appearance TextProperties-Color="0, 0, 79"   
                    TextProperties-Font="Verdana, 11.25pt, style=Bold">  
                </Appearance> 
            </TextBlock> 
        </ChartTitle> 
        <Legend Visible="False"></Legend> 
    </telerik:RadChart> 

And here is the relavant code behind:

RadChart chart = RadChart1;  
mvControl.SetActiveView((View) chart.Parent);  
 
chart.PlotArea.YAxis.AutoScale = false;  
chart.PlotArea.YAxis.AddRange(0, 10, 1);  
chart.PlotArea.XAxis.Visible = Telerik.Charting.Styles.ChartAxisVisibility.False;  
          
ChartSeries series = chart.GetSeries(0);  
series.Clear();  
 
ChartAxisItemsCollection items = chart.PlotArea.XAxis.Items;  
items.Clear();  
 
ulong totalResponses = 0;  
 
foreach (DataRow dr in ds.Tables[0].Rows)  
{  
    string label = (string) dr["answer"];  
    double value = Convert.ToDouble(dr["answerCount"]);  
    totalResponses += (ulong) value;  
 
    ChartAxisItem item = new ChartAxisItem();  
    item.TextBlock.Text = label;  
    items.Add(item);  
 
    series.AddItem(value, label + " - (#%)");  
}  
 
series.Name = string.Empty;  
chart.ChartTitle.TextBlock.Text = QuestionText;  
 
0
Giuseppe
Telerik team
answered on 16 Jul 2008, 02:22 PM
Hello Roger Helliwell,

We reviewed the provided source code and it works as expected in our local tests. Please review the attached sample application that uses your own code (modified to get the data from a sample DataTable) and let us know if it works as expected on your end as well.

Despite our best efforts we are still unable to reproduce the erroneous behavior locally. Unfortunately, we would not be able to help you further unless you can modify the attached application so we can observe (and fix if needed) the problematic issue.


Regards,
Manuel
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
raptor22
Top achievements
Rank 1
answered on 17 Feb 2009, 03:58 PM
Same thing happens to me. Horizontal Bar. As soon as I set AutoLayout="true" I get System.ArgumentOutOfRangeException "length cannot be less than zero." Using RadControls for ASP.NET AJAX 2008.3.1314. Plan is to workaround by changing chart type or by turning off AutoLayout.
0
Giuseppe
Telerik team
answered on 20 Feb 2009, 11:05 AM
Hi raptor22,

We were able to reproduce the problematic behavior with horizontal orientation and we must confirm it is a bug within the chart control. Unfortunately at this moment we cannot suggest you a workaround besides the options you have already came up on your own (changing the orientation or disabling the autolayout functionality).

We have updated your Telerik points for the report.


Regards,
Manuel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Mark Stiles
Top achievements
Rank 1
answered on 05 Apr 2013, 08:32 PM
I'm using the 2012 Q3 version of the RadChart and this bug still exists it seems, has there been a fix for a horizontal bar chart with AutoLayout set to True?

I'm seeing the following exception thrown:

Length cannot be less than zero.
Parameter name: length

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.ArgumentOutOfRangeException: Length cannot be less than zero.
Parameter name: length

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 

[ArgumentOutOfRangeException: Length cannot be less than zero.
Parameter name: length]
   System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy) +10695301
   System.String.Substring(Int32 startIndex, Int32 length) +10
   Telerik.Charting.TextBlock.get_VisibleText() +194
0
Petar Kirov
Telerik team
answered on 10 Apr 2013, 02:38 PM
Hi Mark,

I am afraid that this bug hasn't been fixed. Since we started developing our newer charting solution for ASP.NET - RadHtmlChart, the majority of our development effort shifted to it. This meant that changes to the old code-base will be made only regarding critical bug fixes. As in one of previous posts was noted, this problem can be avoided by setting AutoLayout to false and manually specifying the size and the margins of the chart elements.

We are sorry for the inconvenience.
 
Kind regards,
Petar Kirov
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.
Tags
Chart (Obsolete)
Asked by
Kludge
Top achievements
Rank 1
Answers by
Giuseppe
Telerik team
Kludge
Top achievements
Rank 1
Ves
Telerik team
raptor22
Top achievements
Rank 1
Mark Stiles
Top achievements
Rank 1
Petar Kirov
Telerik team
Share this question
or