Alternating XAxis Item Label Display

Thread is closed for posting
6 posts, 1 answers
  1. Anette
    Anette avatar
    9 posts
    Member since:
    Sep 2008

    Posted 22 Sep 2008 Link to this post

    Hi,

    Is there a way to display XAxis Item Label in way similar to this?
    http://www.dundas.com/Gallery/Chart/NET/index.aspx?Img=glazed

    Thank you.

  2. Giuseppe
    Admin
    Giuseppe avatar
    2363 posts

    Posted 23 Sep 2008 Link to this post

    Hello Anette,

    Unfortunately RadChart does not provide support for such stepped label display and it would not be possible to achieve the desired functionality.


    All the best,
    Manuel
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Anette
    Anette avatar
    9 posts
    Member since:
    Sep 2008

    Posted 25 Sep 2008 Link to this post

    Hello Manuel

    Thank you for confirming this matter.
  4. Anette
    Anette avatar
    9 posts
    Member since:
    Sep 2008

    Posted 28 Sep 2008 Link to this post

    Hello Manuel,

    Since stepped label display cannot be implemented in Telerik, I used the Automatic Text-wrapping feature.

    We are using dates in the x-axis. Is there a way to display it this way? Wherein the year is always on the second line so that we can have uniformity.
      Jul       Aug        Sept
    2008    2008       2008

    Thank you.
  5. Answer
    Giuseppe
    Admin
    Giuseppe avatar
    2363 posts

    Posted 29 Sep 2008 Link to this post

    Hi Anette,

    The AutoTextWrap algorithm cannot be customized in such a way but you can achieve the desired functionality by manually adding a newline in the axis item label display (and disabling the AutoTextWrap as well). Here is a sample code snippet to get you started:

    ASPX:
    <telerik:RadChart ID="RadChart1" runat="server" AutoLayout="true" Width="278px"  
        OnBeforeLayout="RadChart1_BeforeLayout"
        <Series> 
            <telerik:ChartSeries Name="Series 1"
                <Items> 
                    <telerik:ChartSeriesItem Name="Item 2" YValue="6"
                    </telerik:ChartSeriesItem> 
                    <telerik:ChartSeriesItem Name="Item 3" YValue="3"
                    </telerik:ChartSeriesItem> 
                    <telerik:ChartSeriesItem Name="Item 4" YValue="1"
                    </telerik:ChartSeriesItem> 
                </Items> 
            </telerik:ChartSeries> 
        </Series> 
        <PlotArea> 
            <XAxis AutoScale="False" MinValue="1" MaxValue="3" Step="1"
                <Items> 
                    <telerik:ChartAxisItem Value="1"
                        <TextBlock Text="Jul 2008"
                        </TextBlock> 
                    </telerik:ChartAxisItem> 
                    <telerik:ChartAxisItem Value="2"
                        <TextBlock Text="Aug 2008"
                        </TextBlock> 
                    </telerik:ChartAxisItem> 
                    <telerik:ChartAxisItem Value="3"
                        <TextBlock Text="Sept 2008"
                        </TextBlock> 
                    </telerik:ChartAxisItem> 
                </Items> 
            </XAxis> 
        </PlotArea> 
    </telerik:RadChart> 

    Code-behind:
    protected void RadChart1_BeforeLayout(object sender, EventArgs e) 
        foreach (ChartAxisItem axisItem in RadChart1.PlotArea.XAxis.Items) 
        { 
            axisItem.TextBlock.Text = Regex.Replace(axisItem.TextBlock.Text, " ", "\n"); 
        } 


    Hope this helps.


    Best wishes,
    Manuel
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  6. Anette
    Anette avatar
    9 posts
    Member since:
    Sep 2008

    Posted 29 Sep 2008 Link to this post

    Hello Manuel,

    Thank you for your help.

    Cheers,
    Anette
Back to Top