FlexChart PointStyles

Posted by: cwilson on 22 August 2022, 2:16 pm EST

    • Post Options:
    • Link

    Posted 22 August 2022, 2:16 pm EST

    I am converting from the old C1Chart to FlexChart (by necessity). I had used pointstyles to let some points in a scatter plot use different marker styles and colors. Is that possible with FlexChart? If not, is there a suggested workaround?

    I guess I could create new series and move points from one series to the other. However, I don’t know how to suppress the other series in the legend (I want only one legend entry).

    Alternatively, I see that points can be selected. Can multiple points be selected at the same time?

    Thanks,

    Chris

  • Posted 23 August 2022, 3:05 am EST

    Hi Wilson,

    You need to handle SymbolRendering event of a particular Series to achieve your requirement as:(see code snippet)

    
           private void Series_SymbolRendering(object sender, RenderSymbolEventArgs e)
            {
                if ((e.Item as Data).Value > 5)
                    e.Engine.SetFill(Brushes.Green);
                else
                    e.Engine.SetFill(Brushes.Red);
            }
    
    

    And we are sorry to inform you that it can’t be possible to select multiple point at same time.

    Please refer the attached sample : FlexChartScatterStyle.zip

    Best Regards,

    Nitin

  • Posted 29 August 2022, 7:05 pm EST

    Thanks for your reply!

    That all makes sense, but when I try to implement that pattern I get stuck. Specifically, the SymbolRender event never fires. Here is some of my code:

        
        ''' <summary>
        ''' Save (or clear) selected point; will also set symbol rendering event handling
        ''' </summary>
        ''' <param name="seriesIndex">-1 to clear prior selection,</param>
        ''' <param name="pointIndex"></param>
        Private Sub SetSelected(seriesIndex As Integer, pointIndex As Integer)
            If SelectedSeriesIndex <> -1 Then RemoveHandler chtMulti.Series(SelectedSeriesIndex).SymbolRendered, AddressOf Series_SymbolRendering
            If seriesIndex = -1 Then
                SelectedSeriesIndex = -1
                SelectedPointIndex = -1
                Debug.Print("None selected")
            Else
                SelectedSeriesIndex = seriesIndex
                SelectedPointIndex = pointIndex
                Debug.Print("Point " & pointIndex & " selected")
                AddHandler chtMulti.Series(SelectedSeriesIndex).SymbolRendering, AddressOf Series_SymbolRendering
            End If
            DrawGraph()
        End Sub
    
        Private Sub Series_SymbolRendering(sender As Object, e As RenderSymbolEventArgs)
            Debug.Print("rendering...")
            With CType(sender, C1.Win.Chart.FlexChart)
                If SelectedSeriesIndex <> -1 AndAlso .Series.IndexOf(e.Series) = SelectedSeriesIndex Then
                    If SelectedPointIndex <> -1 Then
                        e.Engine.SetFill(Brushes.Black)
                        e.Engine.SetStrokeThickness(3)
                        Debug.Print("black fill")
                    Else
                        e.Engine.SetFill(e.Series.Style.FillColor)
                        e.Engine.SetStrokeThickness(e.Series.Style.StrokeWidth)
                    End If
                End If
            End With
        End Sub
    
    

    The “Selected” indices are global variables set when the user clicks on a point. The issue is by stepping through, I can see that the AddHandler statement is executing, but that method never gets hit (even if I comment out RemoveHandler to make sure it is not getting detached). Is there something else I need to turn on to allow custom rendering?

    Comparing to your sample code, the only difference is that you attach the handler before the series is added to the collection, and I’m doing it on demand afterwards. But I wouldn’t think that would be the problem.

    Any ideas?

    Thanks,

    Chris

  • Posted 30 August 2022, 1:14 am EST

    Hi,

    Apologize for the inconvenience. We didn’t understood your requirement. Could you please describe in detail that what you want to achieve?

    The sample code that you’ve provided is incomplete:

    1. Where are you calling SetSelected method.
    2. What is the definition for DrawGraph method.

    It will be helpful, if you clarify your requirement and provide a small sample or update the attached sample : SymbolStyle.zip

    Best Regards,

    Nitin

  • Posted 30 August 2022, 12:23 pm EST

    Nitkin:

    I could send a lot more code but don’t think you want to wade through it. I call SetSelected when the user clicks on the graph where I use HitTest to determine the series and point number that I store in global variables. I want that “selected” point to be drawn with a different style so I can tell it is selected. Then I use MouseMove, etc. to simulate dragging of that point so I can interactively edit my data.

    My problem is that I cannot ever get SymbolRendering to execute despite the fact that I’ve added it as a handler for that series’ event.

    I tried this just now:

    Dim WithEvents SelectedSeries As C1.Win.Chart.Series = Nothing
    

    Then in the SetSelected I assign the selected series (determined by HitTest) to that variable and trap the firing of its rendering event. Still, it never occurs.

    I’m just wondering if there is something else I need to do to cause series rendering events to fire when the chart is redrawn.

    Thanks for your patience.

    Chris

  • Posted 31 August 2022, 7:17 am EST

    Hi Chris,

    JFYI, SymbolRendering event fires for each Symbol when it renders on Chart, If Selected or Chart renders. For your requirement, you can implement SelectionStyle for the particular series. So, that we can identify which point is selected.

    
    FlexChart1.SelectionMode = C1.Chart.ChartSelectionMode.Point
    FlexChart1.SelectionStyle.Stroke = Brushes.Black
    FlexChart1.SelectionStyle.Fill = Brushes.Red
    FlexChart1.SelectionStyle.StrokeWidth = 3
    
    

    Please refer the attached modified sample for the same: SymbolStyle_Mod.zip

    Best Regards,

    Nitin

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels