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

Change Series Color at Runtime

4 Answers 262 Views
Chart (obsolete as of Q1 2013)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Matt
Top achievements
Rank 1
Matt asked on 14 Aug 2009, 11:03 PM
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.



Background:
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.

Code:
    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 
                Me._chart.Series.Clear() 
 
                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)) 
 
            
                Me._chart.Series.Add(series) 
 
                Me._chart.Refresh() 
                Me._chart.Update() 
                Me._chart.UpdateGraphics() 
                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.

4 Answers, 1 is accepted

Sort by
0
Robert
Top achievements
Rank 1
answered on 15 Aug 2009, 06:32 AM
Matt,

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
0
Matt
Top achievements
Rank 1
answered on 01 Sep 2009, 08:26 PM
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.
0
Renuka
Top achievements
Rank 1
answered on 25 May 2017, 04:31 AM

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 system.is there any system(pc) specific configuration needs to be done?please replay the comment 

Thank you

 

 

0
Hristo
Telerik team
answered on 25 May 2017, 03:38 PM
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: http://docs.telerik.com/devtools/winforms/installation-deployment-and-distribution/application-deployment.

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

Regards,
Hristo
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.
Tags
Chart (obsolete as of Q1 2013)
Asked by
Matt
Top achievements
Rank 1
Answers by
Robert
Top achievements
Rank 1
Matt
Top achievements
Rank 1
Renuka
Top achievements
Rank 1
Hristo
Telerik team
Share this question
or