Change Series Color at Runtime

Thread is closed for posting
5 posts, 0 answers
  1. Matt
    Matt avatar
    5 posts
    Member since:
    Sep 2008

    Posted 14 Aug 2009 Link to this post

    Hi we are evaluating telerik controls for use in our application.

    Problem:   The series won't change colors when the color is set at runtime.

    I'm using ChartFX Winforms 2009 Q2

    I am creating a solution where a chart is embedded in a Grid cell. 
    I use the grid.cellformatting event to set the grid image if the rowinfo tag has not been set, much like is suggested in the telerik sample for: Multiple child views with RadGridView for WinForms

    To simplify the test, I just default the series bar value to: "series.Appearance.FillStyle.MainColor = Drawing.Color.Green " (see bulleted line in code block below)

    Eventually I need to add a piece of code that will set the series color based on the value.  For now I have just defaulted the value to show as green.

    I have referenced other posts in the forum and added the lines to updategraphics, refresh, and still could not get the series to turn green.

        Private _chart As New RadChart 

     Private Sub PrepareChart() 
            Dim radChart As New GridToleranceChart 
            Me._chart = radChart.chart 
            Me._chart.SkinsOverrideStyles = False 
        End Sub 
    GridToleranceChart is a usercontrol that has a radchart on it.  I use an instance of this usercontrol, and reference its public chart property, so I could set some visual elements at designtime.  PrepareChart is called when the form loads.

    Private Sub grid_CellFormatting(ByVal sender As Object, _ 
            ByVal e As CellFormattingEventArgs) _ 
            Handles grid.CellFormatting 
            Dim column As GridViewDataColumn = TryCast(e.CellElement.ColumnInfo, GridViewImageColumn) 
            If column IsNot Nothing AndAlso StrComp(column.FieldName, _ 
                Constants.DefaultToleranceColumnNames.TolPercentChart, CompareMethod.Text) = 0 Then 
                If e.CellElement.RowInfo.Tag Is Nothing Then 
                    column.Width = 300 
                    column.AllowResize = False 
                    e.CellElement.RowElement.RowInfo.Height = 60 
                    Dim series As New Telerik.Charting.ChartSeries() 
    •              series.Appearance.FillStyle.MainColor = Drawing.Color.Green 
                    series.Type = Telerik.Charting.ChartSeriesType.Bar 
                    series.Name = "percentOfTolSeries" 
                    series.Appearance.LabelAppearance.Visible = False 
                    ' Get the value to add to the series from another cell in the same row of the cell that is being edited 
                    ' Add the value to the series 
                    Dim rowInfo As GridViewRowInfo = TryCast(e.CellElement.RowInfo, GridViewDataRowInfo) 
                    Dim value As Decimal = CDec(rowInfo.Cells(Constants.DefaultToleranceColumnNames.PercentOfTol).Value) 
                    series.Items.Add(New Telerik.Charting.ChartSeriesItem(value)) 
                    e.CellElement.RowInfo.Tag = Me._chart.GetBitmap() 
                End If 
                e.CellElement.Image = TryCast(e.CellElement.RowInfo.Tag, System.Drawing.Image) 
                e.CellElement.ImageLayout = ImageLayout.Center 
                e.CellElement.DrawBorder = False 
                e.CellElement.Text = "" 
                e.CellElement.Padding = New Padding(0, 0, 0, 0) 
            End If 
        End Sub 

    Your help is greatly appreciated.
  2. Robert
    Robert avatar
    82 posts
    Member since:
    Jun 2009

    Posted 15 Aug 2009 Link to this post


    Try setting the FillType on the series as well.

    series.Appearance.FillStyle.FillType = Telerik.Charting.Styles.FillType.Solid; 
    series.Appearance.FillStyle.MainColor = Color.Green; 

    I hope this helps.

    - Robert
  3. Matt
    Matt avatar
    5 posts
    Member since:
    Sep 2008

    Posted 01 Sep 2009 Link to this post

    I guess my code was working.  My values were too small to register on the grid.  since the values were < 1, the only thing that was rendering was the bar's border, which was white.  ID10T error.  Thanks for the quick response and the suggestion though.
  4. Renuka
    Renuka avatar
    4 posts
    Member since:
    Dec 2016

    Posted 24 May 2017 Link to this post

    After deploying the project, raddock & radhtmlchart are not displayed but this is not happening in the development system,the problem is observed in the production there any system(pc) specific configuration needs to be done?please replay the comment 

    Thank you



  5. Hristo
    Hristo avatar
    1508 posts

    Posted 25 May 2017 Link to this post

    Hi Renuka,

    Thank you for writing.

    It is not necessary to configure the clients` machine in a special way so that the controls be displayed. You can check the following article discussing the various deployment options:

    The RadChart control has long been deprecated if possible please upgrade and use RadChartView.

    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top