Line Chart changing colors unexpectedly

Thread is closed for posting
3 posts, 1 answers
  1. Derek
    Derek avatar
    118 posts
    Member since:
    Oct 2008

    Posted 30 Nov 2011 Link to this post

    We have a line chart that uses a stored procedure for data. There is a combo box that allows the user to select a different category, and to view the chart for that category. When the chart first loads, it has the expected line colors for the selected theme. When the combo box value is changed the chart reloads properly, but the line colors change. Here's the definition for the chart.
    <telerik:RadChart ID="RadChartCategory" runat="server" DataSourceID="dsChartData" Width="950" Height="650" Skin="Vista">
            <PlotArea>
            <YAxis>
                <Appearance CustomFormat="#,#">
                </Appearance>
            </YAxis>
            <XAxis DataLabelsColumn="StringDate" LabelStep="4">
            </XAxis>
        </PlotArea>
        <Series>
            <telerik:ChartSeries DataYColumn="Scenario1" DefaultLabelValue="" Name="Scenario 1"
                Type="Line">
            </telerik:ChartSeries>
            <telerik:ChartSeries DataYColumn="Scenario2" DefaultLabelValue="" Name="Scenario 2"
                Type="Line">
            </telerik:ChartSeries>
            <telerik:ChartSeries DataYColumn="Scenario3" DefaultLabelValue="" Name="Scenario 3"
                Type="Line">
            </telerik:ChartSeries>
            <telerik:ChartSeries DataYColumn="Theoretical" DefaultLabelValue="" Name="Theoretical Capacity"
                Type="Line">
            </telerik:ChartSeries>
            <telerik:ChartSeries DataYColumn="NetEffective" DefaultLabelValue="" Name="Net Effective Capacity"
                Type="Line">
            </telerik:ChartSeries>
        </Series>
        <ChartTitle>
            <TextBlock Text="Labour Demand">
            </TextBlock>
        </ChartTitle>
    </telerik:RadChart>

    The only other code affecting the chart is to update the chart title when the selected value changes.
    Protected Sub RadComboBoxCategory_SelectedIndexChanged(sender As Object, e As Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs) Handles RadComboBoxCategory.SelectedIndexChanged
        RadChartCategory.ChartTitle.TextBlock.Text = "Labour Demand - " & RadComboBoxCategory.SelectedItem.Text
    End Sub

    I've attached a before and after image of how the chart appears. This seems to occur with any Skin. Subsequent reloads keep the same colors as the first reload.

    Any ideas?
  2. Answer
    Ves
    Admin
    Ves avatar
    2879 posts

    Posted 05 Dec 2011 Link to this post

    Hi Derek,

    Indeed, the series appearance is lost in this scenario. Please, add SeriesPalette = "Vista" to chart's declaration. This will force the chart to use the Vista colors for series every time.

    Best regards,
    Ves
    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Derek
    Derek avatar
    118 posts
    Member since:
    Oct 2008

    Posted 05 Dec 2011 Link to this post

    That works perfectly; thanks!
Back to Top