FlexChart Tooltip

Posted by: alex.corti on 9 November 2021, 4:16 am EST

  • Posted 9 November 2021, 4:16 am EST

    I have a chart that show n lines.

    By default the tooltip show the value and the description of the line.

    I want to change this beahavior. I want to customize it.

    The tooltip have to contain other info.

    This info are saved in a datasource A (in memory).

    The chart’s dataSource contains a subset of information that I retrieve from datasource A (only numeric value that I want to see in the chart).

    I see online that it’s possible to customize tooltip with " _fChart_MouseMove" event (see at the end my code, it’s working)

    My question is very simple:

    How can I retreive the actual row number of chart’s dataSource?

    If I have it for me is very simple to obtain this info because i will retrieve data from datasource A (in memory) at the same position.

    Thanks Alex

    private void _fChart_MouseMove(object sender, MouseEventArgs e)

        {
    
            var hitTestInfo = _fChart.HitTest(e.Location);
    
            if (hitTestInfo == null)
    
                return;
    
            if (hitTestInfo.Item != null && hitTestInfo.Distance <= 10)
    
            {
    
        // custom tooltip 
    
                _fChart.ToolTip.Content = "Prova";
    
             }
    
            else
    
                _fChart.ToolTip.Content = "";
    
        }
    
  • Posted 9 November 2021, 5:32 am EST

    Hi Alex,

    Thank you for sharing the code snippet.

    Do you want to get the row index with respect to chart data source?

    If yes, then you can use HitTestInfo’s PointIndex property for the same which returns the index of the data item with respect to the chart’s data source.

    However, if you want to get the row index with respect to the DataSource A then it won’t be directly possible. IMO, you can use the key/indexing approach. For example, you can add some key (identifies row in main data source) related information to your subset data item so that you can use that key to identify the actual row in your DataSource A. However, if there is no key related information available then i am sorry to inform you that this requirement can’t be implemented.

    Just in case if you meant something else then I would request you to share a small sample explaining your requirement.

    I hope it helps :slight_smile:

    Best Regards,

    Kartik

  • Posted 9 November 2021, 7:09 am EST

    Hi Kartik

    thanks for your answer. You give me the solution for my case.

    PointIndex is for the chart’s datasource and is in the same position of my memory datasource.

    As I wrote chart datasource is a subset (less columns: only value) of memory datasource (has got all columns of sql table: not only value but other info)

    Alex

Need extra support?

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

Learn More

Forum Channels