Not able to run Range Selector in flexchart, vb.net4.8

Posted by: christophnoelle on 20 June 2025, 5:24 am EST

  • Posted 20 June 2025, 5:24 am EST

    Created 2 flexcharts and bound together with:

    [code]Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load

    'Passing data in FlexChart
    Me.FlexChart1.DataSource = _data
    
    'Binding chart's AxisX to 'Date' so dates appear in Horizontal axis
    Me.FlexChart1.BindingX = "dt"
    
    'Binding FlexChart to 'Volume' so their market share appears in Vertical axis
    Dim _sVolume As Series = New Series() With {
         .Name = "Volume",
         .Binding = "Volume",
         .AxisY = New Axis() With {
             .Position = Position.Left,
             .Format = "#,##0,,M"
        }
    }
    Me.FlexChart1.Series.Add(_sVolume)
    
    _rsXRangeSelector = New RangeSelector(FlexChart2)
    
    'Passing data in RangeSelection chart
    FlexChart2.DataSource = Me.FlexChart1.DataSource
    
    'Binding chart's AxisX to 'Date' so dates appear in Horizontal axis
    FlexChart2.BindingX = "dt"
    
    'Adding a new Series for High quote, hence binding it to "High" field 
    FlexChart2.Series.Add(New Series() With {
         .Binding = "istTemp"
    })
    

    End Sub[/code]

    _data is list of DataItem and empty for the first time:

        Private Class DataItem
            Public Property istTemp As Single
            Public Property istHum As Single
            Public Property sollTemp As Single
            Public Property sollHum As Single
            Public Property OnOff As Integer
            Public Property RunPause As Integer
            Public Property dt As DateTime
        End Class

    and generated via timer.ticks.

    After starting the prog, I get System.OverflowException in System.Drawing.dll: Graphics.cs:

    	private void CheckErrorStatus(int status)
    	{
    		switch (status)
    		{
    		case 1:
    		case 7:
    		{
    			int lastWin32Error = Marshal.GetLastWin32Error();
    			if (lastWin32Error == 5 || lastWin32Error == 127 || (((uint)UnsafeNativeMethods.GetSystemMetrics(4096) & (true ? 1u : 0u)) != 0 && lastWin32Error == 0))
    			{
    				return;
    			}
    			break;
    		}
    		case 0:
    			return;
    		}
    		throw SafeNativeMethods.Gdip.StatusException(status);
    	}


    with a status of** 11.**

    What is missing to work correctly?

    Regards

  • Posted 23 June 2025, 3:40 am EST

    Hello,

    The error occurs because there is no data initially. To fix this, you can add a check for

    _data.Count
    and only add the selector when there is data available, like this:

    ...
        'timer
        Timer1.Interval = 500
        AddHandler Timer1.Tick, AddressOf Timer_Tick
        Timer1.Start()
    
        AddHandler FlexChart2.Rendered, AddressOf SetupRangeSelector
    End Sub
    
    Private Sub SetupRangeSelector()
        If _rsXRangeSelector IsNot Nothing OrElse _data.Count = 0 Then
            Return
        End If
        _rsXRangeSelector = New RangeSelector(FlexChart2)
    End Sub
    
    Private Sub Timer_Tick(sender As Object, e As EventArgs)
        _data.Add(New DataItem With {
            .dt = DateTime.Now,
            .Volume = _rnd.Next(20),
            .istTemp = _rnd.Next(40, 100)
        })
    End Sub

    We have updated your code to add RangeSelector as mentioned in https://developer.mescius.com/componentone/docs/win/online-flexchart/range-selector.html

    Please refer to the attached sample for implementation. (see FlexChart_RangeSelector.zip)

    Regards,

    Uttkarsh.

Need extra support?

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

Learn More

Forum Channels