Flex chart -- tooltip questions

Posted by: a.sharov on 5 September 2022, 1:17 pm EST

    • Post Options:
    • Link

    Posted 5 September 2022, 1:17 pm EST

    Hi.

    Consider following simple code for tooltip

    
    flexChartMain.ToolTip.Content = $"{ComponentName} : {{Value}}\rDate: {{Date}}";
    

    1)Is there any way to add something like linklabel or other control so one could via tooltip trigger some action, say it contains basic info like above plus some actionable control to show, say, report?

    2)Also, suppose I have an outlier on chart which I want to delete, is there any way to call a context menu on a specific series item or do it via tooltip and some actinable control?

    Thanks in advance.

  • Posted 6 September 2022, 5:43 am EST

    Hi,

    1. ToolTip.Content allows string value to be shown. For customized Tooltip for FlexChart you can refer our product sample at location: “Documents\ComponentOne Samples\WinForms\v4.8\FlexChart\CS\Tooltips”.

      Also, we didn’t suggests to add actionable content on ToolTip because of it’s behavior. Tooltip could be shown while hovering and hides while mouse leaves the element. You can implement ContextMenu for the same.

    2. For this requirement, you can add a standard ContextMenu on the FlexChart and can handle the menu items accordingly.

    
              //Add Context Menu
                var contextMenu = new ContextMenu();
                var menuItem = new MenuItem() { Text = "Delete" };
                menuItem.Click += (s, e) =>
                {
                    if (flexChart.SelectedIndex >= 0)
                        points.RemoveAt(flexChart.SelectedIndex);
                };
                contextMenu.MenuItems.Add(menuItem);
                flexChart.ContextMenu = contextMenu;
    
    

    Please refer the attached sample for the same :

    FlexChartContextMenu.zip

    Best Regards,

    Nitin

  • Posted 6 September 2022, 1:04 pm EST

    Hi, thank you. Seems plausible.

    1. But can I show context menu only when I click on point, not on chart? I mean I want to see context menu when SelectedIndex >= 0.

    2)Also, how to visually separete menu items? Smth like:

    View

    Edit

    Info

    ----- (or some empty space)

    Delete

    I know that there are should be sone menuitem placeholders or something? BarBreak and Break seems not to do what I need…

    3)Is there any possibility to add icon for each menu item and colorize menu item?

  • Posted 7 September 2022, 5:32 am EST

    Hi,

    Thanks for reaching out to us with your query again.

    As per your use case. displaying Popup with Actionable items and icons would be a better choice. All your questions can be achieved through displaying a Popup.

    1. You can handle MouseDown event to achieve this requirement as :
    
            private async void FlexChart_MouseDown(object sender, MouseEventArgs e)
            {
                popup.IsOpen = false;
                await Task.Delay(200);
                if(e.Button == MouseButtons.Right)
                {
                    if (flexChart.SelectedIndex >= 0)
                        popup.IsOpen = true;
                }            
            }
    
    

    2 and 3. We can set Canvas as a child of Popup. Now we can add arrange actionable items and icons accordingly.

    Please refer the attached sample for the same : FlexChartContextMenu_Mod.zip

    Best Regards,

    Nitin

  • Posted 7 September 2022, 2:04 pm EST

    Thank you, great!

    But I would like to stick with more primitive context menu, still how can I visually separate Delete menu item from others menu items (see 2. in my prev. post)?

    Thank you so much, btw, i will give a try to your approach.

  • Posted 8 September 2022, 7:17 am EST

    Hi,

    For your requirement, the menu should show on clicking a point but not the remaining flexchart area. If we implement ContextMenu for this requirement, then we need to dispose the ContextMenu if clicked on remaining part and re-create ContextMenu if clicked over a point.

    Also, the gap you are referring to a add between items can be possible in Popup easily.

    Regards,

    Nitin

  • Posted 9 September 2022, 2:12 pm EST

    Thank you for reply. Probably popup is better but when it is shown even when I minimize or unfocus form(switch to another window) it is still visible. Or suppose that when popup is shown and I move window, popup is still visible, so I should explicitly hide it by clickin on chart or select action. Very annoying… Context menu, on the other hand, has none of this problems, it hides automatically when, for example, form is minimized.

    Is possible to deal with this popup issues?

    Aslo, is it possbile to use ContextMenuStrip?

  • Posted 12 September 2022, 1:34 am EST

    Hi,

    To resolve this issue, you can handle the Deactivate and Move events of respective Form as:(see code snippet)

    
    this.Deactivate += FormUpdate;
    this.Move += FormUpdate;
    
    ................................
    private void FormUpdate(object sender, EventArgs e)
    {
         popup.IsOpen = false;
    }
    
    

    Please refer the attached modified sample : FlexChartContextMenu_Mod2.zip

    Also, ContextMenuStrip could be better to use it with you requirement. On other side, Popup can be highly customizable.

    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