RadChart1.Series(0). causing problems?

Thread is closed for posting
5 posts, 1 answers
  1. Adam Hubble
    Adam Hubble avatar
    74 posts
    Member since:
    Jan 2008

    Posted 14 Apr 2009 Link to this post

    Hi, I'm having a couple of problems with RadChart which I think are probably related to the binding approach.

    Now

    I'm trying to do this in page load event:

     

    If Not Page.IsPostBack Then

     

     

    Dim s As ChartSeries = RadChart1.Series.GetSeries(0)

     

    s.DefaultLabelValue =

    "#Y{#,#}"

     

    RadChart1.ChartTitle.TextBlock.Text =

    "Top 10"

     

    s.Items(0).ActiveRegion.Url = _

     

    "javascript:ShowPopUpDialog('detailpage.aspx');"

     

     

     

    End If

    Now there are two problems with this,

    1: s.DefaultLabelValue = "#Y{#,#}" is not being applied, it gets executed, but series numbers still appear without formatting.

    2: s.Items(0).ActiveRegion.Url throws an error: "Index was out of range. Must be non-negative and less than the size of the collection.
    Parameter name: index
    "

    So it seems that it can't find the series, but I don't see why.

    I am binding the grid using an objectdatasource, here's the markup:

     

     

    <asp:ObjectDataSource ID="chartObds" runat="server"

     

     

    SelectMethod="GetNewsFeaturesClickStats"

     

     

    TypeName="NewsFeaturesAdminBLL"

     

     

     

     

     

     

    SortParameterName="sortExpression" MaximumRowsParameterName="maximumRows"

     

     

    StartRowIndexParameterName="startRowIndex">

     

     

     

     

     

     

    <SelectParameters>

     

     

     

     

     

     

    <asp:Parameter Name="sortExpression" Type="String" />

     

     

     

     

     

     

    <asp:Parameter Name="startRowIndex" Type="Int32" />

     

     

     

     

     

     

    <asp:Parameter Name="maximumRows" Type="Int32" />

     

     

     

     

     

     

     

     

    </SelectParameters>

     

     

    </asp:ObjectDataSource>

     

     

     

     

     

     

    <div id="chartInp">

     

     

     

     

     

     

    <asp:Button runat="server" ID="FirstPage" Text="<< First" />

     

     

     

     

     

     

    <asp:Button runat="server" ID="PrevPage" Text="< Prev" />

     

     

     

     

     

     

    <asp:Button runat="server" ID="NextPage" Text="Next >" />

     

     

     

     

     

     

    <asp:Button runat="server" ID="LastPage" Text="Last >>" />

     

     

     

     

     

     

    </div>

     

     

     

     

     

     

     

     

     

    <

     

    div id="NFchart">

     

     

     

     

     

     

    <Telerik:RadChart ID="RadChart" Width="830px" Height="580px" runat="server"

     

     

    DataSourceID="chartObds" Skin="SkyBlue">

     

     

     

     

     

     

    <Series>

     

    <

     

    telerik:ChartSeries Name="MostViewed" DefaultLabelValue="#Y{#,#}">

     

     

     

     

     

     

    <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="51, 51, 51">

     

     

     

     

     

     

    </textappearance>

     

     

     

     

     

     

    </appearance>

     

     

     

     

     

     

    </telerik:ChartSeries>

     

     

     

     

     

     

     

     

     

    </

     

    Series>

     

     

     

     

     

     

    <PlotArea>

     

     

     

     

     

     

    <EmptySeriesMessage>

     

     

     

     

     

     

    <TextBlock Text="No data found">

     

     

     

     

     

     

    </TextBlock>

     

     

     

     

     

     

    </EmptySeriesMessage>

     

     

     

     

     

     

    <XAxis DataLabelsColumn="Title">

     

     

     

     

     

     

    <Appearance Color="180, 210, 236" MajorTick-Color="206, 222, 235">

     

     

     

     

     

     

    <MajorGridLines Color="206, 222, 235" PenStyle="Solid" />

     

     

     

     

     

     

    <LabelAppearance RotationAngle="-400">

     

     

     

     

     

     

    </LabelAppearance>

     

     

     

     

     

     

    <TextAppearance AutoTextWrap="True" MaxLength="25"

     

     

    TextProperties-Color="51, 51, 51">

     

     

     

     

     

     

    </TextAppearance>

     

     

     

     

     

     

    </Appearance>

     

     

     

     

     

     

    <AxisLabel Visible="True">

     

     

     

     

     

     

    <Appearance Visible="True">

     

     

     

     

     

     

    </Appearance>

     

     

     

     

     

     

    <TextBlock Text="Feature Title">

     

     

     

     

     

     

    <Appearance

     

     

    TextProperties-Color="51, 51, 51"

     

     

    TextProperties-Font="Verdana, 8.25pt, style=Bold">

     

     

     

     

     

     

    </Appearance>

     

     

     

     

     

     

    </TextBlock>

     

     

     

     

     

     

    </AxisLabel>

     

    <

     

    Items>

     

    <

     

    telerik:ChartAxisItem>

     

    <

     

    Appearance Dimensions-Margins="1px, 5px, 1px, 10px"></Appearance>

     

    <

     

    TextBlock>

     

    <

     

    Appearance MaxLength="35" TextProperties-Font="Arial, 8.5pt"></Appearance>

     

    </

     

    TextBlock>

     

    </

     

    telerik:ChartAxisItem>

     

    <

     

    telerik:ChartAxisItem Value="1">

     

    <

     

    Appearance Dimensions-Margins="1px, 5px, 1px, 10px"></Appearance>

     

    <

     

    TextBlock>

     

    <

     

    Appearance MaxLength="35" TextProperties-Font="Arial, 8.5pt"></Appearance>

     

    </

     

    TextBlock>

     

    </

     

    telerik:ChartAxisItem>

     

    <

     

    telerik:ChartAxisItem Value="2">

     

    <

     

    Appearance Dimensions-Margins="1px, 5px, 1px, 10px"></Appearance>

     

    <

     

    TextBlock>

     

    <

     

    Appearance MaxLength="35" TextProperties-Font="Arial, 8.5pt"></Appearance>

     

    </

     

    TextBlock>

     

    </

     

    telerik:ChartAxisItem>

     

    <

     

    telerik:ChartAxisItem Value="3">

     

    <

     

    Appearance Dimensions-Margins="1px, 5px, 1px, 10px"></Appearance>

     

    <

     

    TextBlock>

     

    <

     

    Appearance MaxLength="35" TextProperties-Font="Arial, 8.5pt"></Appearance>

     

    </

     

    TextBlock>

     

    </

     

    telerik:ChartAxisItem>

     

    <

     

    telerik:ChartAxisItem Value="4">

     

    <

     

    Appearance Dimensions-Margins="1px, 5px, 1px, 10px"></Appearance>

     

    <

     

    TextBlock>

     

    <

     

    Appearance MaxLength="35" TextProperties-Font="Arial, 8.5pt"></Appearance>

     

    </

     

    TextBlock>

     

    </

     

    telerik:ChartAxisItem>

     

    <

     

    telerik:ChartAxisItem Value="5">

     

    <

     

    Appearance Dimensions-Margins="1px, 5px, 1px, 10px"></Appearance>

     

    <

     

    TextBlock>

     

    <

     

    Appearance MaxLength="35" TextProperties-Font="Arial, 8.5pt"></Appearance>

     

    </

     

    TextBlock>

     

    </

     

    telerik:ChartAxisItem>

     

    <

     

    telerik:ChartAxisItem Value="6">

     

    <

     

    Appearance Dimensions-Margins="1px, 5px, 1px, 10px"></Appearance>

     

    <

     

    TextBlock>

     

    <

     

    Appearance MaxLength="35" TextProperties-Font="Arial, 8.5pt"></Appearance>

     

    </

     

    TextBlock>

     

    </

     

    telerik:ChartAxisItem>

     

    <

     

    telerik:ChartAxisItem Value="7">

     

    <

     

    Appearance Dimensions-Margins="1px, 5px, 1px, 10px"></Appearance>

     

    <

     

    TextBlock>

     

    <

     

    Appearance MaxLength="35" TextProperties-Font="Arial, 8.5pt"></Appearance>

     

    </

     

    TextBlock>

     

    </

     

    telerik:ChartAxisItem>

     

    </

     

    Items>

     

     

     

     

     

     

    </XAxis>

     

     

     

     

     

     

    <YAxis>

     

     

     

     

     

     

    <Appearance Color="180, 210, 236" MajorTick-Color="206, 222, 235"

     

     

    MinorTick-Color="206, 222, 235" CustomFormat="#,#" EndCap="Round">

     

     

     

     

     

     

    <MajorGridLines Color="206, 222, 235" />

     

     

     

     

     

     

    <MinorGridLines Color="206, 222, 235" PenStyle="Dash" />

     

     

     

     

     

     

    <TextAppearance TextProperties-Color="51, 51, 51">

     

     

     

     

     

     

    </TextAppearance>

     

     

     

     

     

     

    </Appearance>

     

     

     

     

     

     

    <AxisLabel Visible="True">

     

     

     

     

     

     

    <Appearance Visible="True" Dimensions-Margins="1px, 1px, 1px, 10px">

     

     

     

     

     

     

    </Appearance>

     

     

     

     

     

     

    <TextBlock Text="Click-count">

     

     

     

     

     

     

    <Appearance TextProperties-Color="51, 51, 51"

     

     

    TextProperties-Font="Verdana, 8.25pt, style=Bold">

     

     

     

     

     

     

    </Appearance>

     

     

     

     

     

     

    </TextBlock>

     

     

     

     

     

     

    </AxisLabel>

     

     

     

     

     

     

    </YAxis>

     

     

     

     

     

     

    <Appearance

     

     

    Dimensions-Margins="18%, 100px, 12%, 80px"

     

     

    Corners="Round, Round, Round, Round, 5">

     

     

     

     

     

     

    <FillStyle MainColor="White" FillType="Solid">

     

     

     

     

     

     

    </FillStyle>

     

     

     

     

     

     

    <Border Color="180, 210, 236" />

     

     

     

     

     

     

    </Appearance>

     

     

     

     

     

     

    </PlotArea>

     

     

     

     

     

     

    <Appearance Corners="Round, Round, Round, Round, 5">

     

     

     

     

     

     

    <FillStyle MainColor="226, 247, 255">

     

     

     

     

     

     

    </FillStyle>

     

     

     

     

     

     

    <Border Color="82, 160, 226" />

     

     

     

     

     

     

    </Appearance>

     

     

     

     

     

     

    <ChartTitle>

     

     

     

     

     

     

    <Appearance Dimensions-Margins="3%, 10px, 14px, 6%">

     

     

     

     

     

     

    <FillStyle MainColor="Transparent">

     

     

     

     

     

     

    </FillStyle>

     

     

     

     

     

     

    <Border Color="Transparent" />

     

     

     

     

     

     

    </Appearance>

     

     

     

     

     

     

    <TextBlock Text="Top 10">

     

     

     

     

     

     

    <Appearance TextProperties-Color="19, 111, 182"

     

     

    TextProperties-Font="Arial, 18pt">

     

     

     

     

     

     

    </Appearance>

     

     

     

     

     

     

    </TextBlock>

     

     

     

     

     

     

    </ChartTitle>

     

     

     

     

     

     

    <Legend Visible="False">

     

     

     

     

     

     

    <Appearance Visible="False" Dimensions-Margins="15%, 2%, 1px, 1px"

     

     

    Position-AlignedPosition="TopRight">

     

     

     

     

     

     

    <ItemTextAppearance MaxLength="20" TextProperties-Font="Verdana, 8pt">

     

     

     

     

     

     

    </ItemTextAppearance>

     

     

     

     

     

     

    <FillStyle MainColor="Transparent">

     

     

     

     

     

     

    </FillStyle>

     

     

     

     

     

     

    <Border Color="Transparent" />

     

     

     

     

     

     

    </Appearance>

     

     

     

     

     

     

    </Legend>

     

     

     

     

     

     

    </Telerik:RadChart>


     

  2. Answer
    Dessy
    Admin
    Dessy avatar
    73 posts

    Posted 16 Apr 2009 Link to this post

    Hi Matt Davis,

    You have not set DataYColumn property and this is the reason why chart is deleting your series and is creating a new one during the databinding process. This new series comes with default properties and this is causing the value of  DefaultLabelValue  not to work as it should.
    As for the second question - the reason why you receive "index is out of range" - is that you have still not created items in the series.
    Please, move this VB code snippet  after you have already called the DataBind method of the chart.

    Hope that helps.

    Greetings,

    Dessy
    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.
  3. Adam Hubble
    Adam Hubble avatar
    74 posts
    Member since:
    Jan 2008

    Posted 16 Apr 2009 Link to this post

    Hi Dessy,

     

    This has been helpful, however I have a small problem in that I am using objectdatasource declaratively - not calling databind() manually from code. I do not really want to change this as I have developed a custom paging interface for radchart this way - using viewstate to store sortexpression etc and it will break if I call databind from code.

     

    Is there a control event I could use instead to achieve the same thing? I have tried this below, but although no error is thrown, it does not seem to set activeregions. The user needs to be able to click on a series and open a window.

     

    protected sub radchart1_databound(byval sender as object, byval e as system.eventargs) handles radchart1,databound

    dim s as chartseries = radchart1.series.getseries(0)
    s.items(0).activeregion.url = "javascript:showpopupdialog('mypage.aspx');"

    end sub

    Thanks,
    Matt

  4. Adam Hubble
    Adam Hubble avatar
    74 posts
    Member since:
    Jan 2008

    Posted 16 Apr 2009 Link to this post

    Dessy - oops, it appears that this event IS working, so I have used itemdatabound event and e.seriesitem.activeregion.url.

    1 more thing!

    I would like to bind each series to open a radwindow with the itemid. Is it possible to set each activeregion url in this way?

    I know that in radgrid I would use the itemtemplate and create an onclick for a link like onclick='openradwindow('<%# databinder.eval(container.dataitem, "productid") %>'); return false..

    Is it possible to achieve the same with radchart in some other way? I do not want radchart to display the id of each item, just use it or the activeurl.

    Thanks,
    Matt

  5. Adam Hubble
    Adam Hubble avatar
    74 posts
    Member since:
    Jan 2008

    Posted 16 Apr 2009 Link to this post

    Nevermind - this all turned out easier than expected (my first radchart experience) so this is all sorted now.

    Thanks for your help with the initial issues!

    Matt
Back to Top