This question is locked. New answers and comments are not allowed.
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:
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.
Your help is greatly appreciated.
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 |
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.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.