We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to double click chart title and series title to edit them in place?

Hello,

We'd like the ability in a chart to be able to double click or slow double click the plot title/series titles to edit them in place. There would be a callback when the edit completed so we could run some of our own code to serialize the change. Is this supported by Syncfusion chart?

If so, could you please provide sample code or references to documentation? If not, could this be added as a feature in future Syncfusion releases?

I have attached a brief video showing what I would do as a user to begin editing the titles in place. I am double clicking on the titles.

Thank you,
Adam Bruss

Attachment: chart_double_click_edit_6cee87e5.zip

16 Replies

SM Saravanan Madheswaran Syncfusion Team September 3, 2020 03:35 PM UTC

 Hi Adam,  
  
Greetings form Syncfusion.   
  
Your requirement “Double click the plot title/series titles to edit them in place” has been achieved by  
adding TextBox at the place of ChartTitle and make it focus on double click as per below code snippet and also add your code in LostFocus event of TextBox to serialize the changes. since we don't have a direct support. 
 
dockControl = new ChartDockControl(textBox);  
dockControl.Alignment = ChartAlignment.Center;  
dockControl.Position = ChartDock.Top;  
dockControl.Size = new Size(500, 40);  
textBox.Name = "title";  
textBox.Dock = DockStyle.Fill;  
textBox.Font = new Font(new FontFamily("arial"), 28, FontStyle.Bold);  
textBox.BorderStyle = BorderStyle.None;  
textBox.WordWrap = true;  
textBox.LostFocus += TextBox_LostFocus;  
textBox.Text = "Syncfusion Chart";  
dockControl.Controls.Add(textBox);  
dockControl.BringToFront();  
  
dockControl.Visible = false;  
this.chartControl1.Controls.Add(dockControl);  
this.chartControl1.DockingManager.Add(dockControl);  
  
chartTitle.Text = "Syncfusion Chart";  
chartTitle.Font = new Font(new FontFamily("arial"), 28, FontStyle.Bold);  
chartTitle.Dock = DockStyle.Fill;  
chartTitle.Position = ChartDock.Top;  
chartTitle.DoubleClick += Title_DoubleClick;  
  
. . .  
. . .  
private void TextBox_LostFocus(object sender, System.EventArgs e)  
{  
    var textBox = sender as TextBox;  
    chartTitle.Text = textBox.Text;  
    chartTitle.Visible = true;  
    dockControl.Visible = false;  
  
// Add your code to serialize the changes. 
}  
  
private void Title_DoubleClick(object sender, System.EventArgs e)  
{  
    (sender as ChartTitle).Visible = false;  
    dockControl.Visible = true;  
    textBox.Focus();  
}  
 
  
We are validating the possibility to achieve the same for LegendItems also. We are working on this and update you the status in one business day [4th Sept 2020].  
  
Regards,  
Saravanan. 



SM Saravanan Madheswaran Syncfusion Team September 5, 2020 05:02 PM UTC

Hi Adam,  
 
We have achieved your requirement by modifying the legend items to show small popup window on its double click. Hence we are not able to position the TextBox at LegendItems position. Please check the code snippet below.   
 
chartTitle.DoubleClick += Title_DoubleClick; 
. . . 
private void Legend_DoubleClick(object sender, System.EventArgs e) 
       
            var legend = sender as ChartLegend; 
 
            Point p1 = legend.PointToClient(new Point(Control.MousePosition.X, Control.MousePosition.Y)); 
 
            ChartLegendItem item = legend.GetItemBy(p1); 
 
            if (item != null) 
           
                selectedItem = item; 
                PopupForm pop = new PopupForm(legend, selectedItem); 
                pop.ShowDialog(); 
           
 
            legend.Refresh(); 
       
 
At PopupForm 
ChartLegend chartlegend; 
ChartLegendItem legenditem; 
public PopupForm(ChartLegend legend, ChartLegendItem item) 
    InitializeComponent(); 
    chartlegend = legend; 
    legenditem = item; 
    textBox1.Text = item.Text; 
. . . 
private void button1_Click(object sender, EventArgs e) 
    legenditem.Text = textBox1.Text; 
    // Add your code to serialize the changes. 
    this.Close(); 
 
 
Please let us know your concern.  
 
Regards, 
Saravanan.  



AB Adam Bruss September 8, 2020 06:19 PM UTC

Hello Saravanan,

I have tried out the first solution for chart titles. It works well except that when you drag the text in the dockcontrol textbox, the dockcontrol moves around. One would drag text to highlight the text for example. Is there a way to prevent the dockcontrol from being allowed to dock while editing the textbox? I can attach a video if needed. After double clicking the title, try dragging the textbox text to see the problem.

Thanks,
Adam

P.S. I will try the legend solution later


SM Saravanan Madheswaran Syncfusion Team September 9, 2020 08:56 AM UTC

Hi Adam,   
  
We are glad to hear that the provided solution works at your end. Currently facing the “dock control moves around while editing” has been prevented and allows only to dock by setting the Behavior property of dock control as Dockable.    
  
Behavior property is an Enum type. By default, it has value as “All”, hence it allows both moving and docking.  
  
dockControl.Behavior = ChartDockingFlags.Dockable;   
  
For more reference,  


  
We will wait until get the confirmation of the provided solution for legend.  
 
Regards, 
Saravanan.  



AB Adam Bruss September 10, 2020 05:17 PM UTC

Hello Saravanan,

With your guidance about docking behavior I was able to improve the overall behavior. There is one remaining problem that occurs from the following steps.

1. Move chart title to a floating position 
2. edit the title
3. when the edit finishes, the title jumps to a vertical position somewhere else

I can't figure out what's causing it. Can you offer a solution or advice? I will attach a video and my source code.

Regards,
Adam

Attachment: video_and_source_eb8d32a2.zip


SM Saravanan Madheswaran Syncfusion Team September 11, 2020 12:35 PM UTC

Hi Adam,  
 
“The title orientation changed at double click” was an actual behavior of ChartTitle when it is in Floating position. It will be resolved by setting the orientation at double click event.  
 
private void Title_DoubleClick(object sender, System.EventArgs e) 
 . . .      
    (sender as ChartTitle).Orientation = ChartOrientation.Horizontal;     
 
Regards, 
Saravanan. 



AB Adam Bruss September 11, 2020 06:25 PM UTC

Hey Saravanan,

I've got the chart title edit working satisfactorily. 

I'm looking at the legend edit now. I tried to download the zip and it took me to a login in page saying I didn't have access to the file. Could you advise?

-Adam




YP Yuvaraj Palanisamy Syncfusion Team September 14, 2020 07:51 AM UTC

Hi Adam Bruss, 
 
Sorry for the inconvenience caused. 
 
Please get the from the below link, 
 
 
Regards, 
Yuvaraj 



AB Adam Bruss September 14, 2020 06:10 PM UTC

Hello,

The legend double click event only works when you click the legend icon, and not the legend text/title. I think the popup method may be sufficient but only if it can work when double clicking the legend text also. Otherwise users will double click the legend text and nothing will happen. Do you think there is a solution for this?

I can provide a video if needed.

Thanks,
Adam


YP Yuvaraj Palanisamy Syncfusion Team September 15, 2020 12:23 PM UTC

 
We have achieved your requirement “Update the Legend text when double click on Legend item” with the below code example.  
 
Code Snippet [C#]: 
 
private void Legend_DoubleClick(object sender, System.EventArgs e) 
{ 
    var legend = sender as ChartLegend;             
    ChartLegendItem item = null; 
 
    foreach (var legendItem in legend.Items) 
    { 
        if(legendItem.Bounds.Contains(new Rectangle((e as MouseEventArgs).X, (e as MouseEventArgs).Y, 1, 1))) 
        { 
            item = legendItem; 
        } 
    } 
              
    if (item != null) 
    { 
        selectedItem = item; 
        PopupForm pop = new PopupForm(legend, selectedItem); 
        pop.ShowDialog(); 
    } 
 
    legend.Refresh(); 
} 
 
 
Also, please find the modified sample from the below location. 
 
  
Regards, 
Yuvaraj 



AB Adam Bruss September 17, 2020 08:46 PM UTC

Thanks. The legend edit addendum works well. Both the chart title and legend edit are working for us now.


SM Saravanan Madheswaran Syncfusion Team September 18, 2020 06:06 AM UTC

 
We are glad that the reported problem resolved at your end. Please let us know, if you have any other queries. 
 
Regards, 
Saravanan.  



AB Adam Bruss September 18, 2020 03:04 PM UTC

Hello,

Yes I have a query about smith charts. I tried to enable the chart title double click edit for smith charts and the smith chart has no Title property. Please advise.

Thanks,
Adam


RS Ramya Soundar Rajan Syncfusion Team September 21, 2020 11:47 AM UTC

Hi Adam Bruss,   
  
Query: Smith chart has no Title property.  
  
We would like to let you know that for showing its title, smith chart has a name of Text property.  As it is in Chart, we have achieved the editing the text on its double click by adding the new TextBox element on the top of smith chart and providing the empty string to that Text property. Since by default, Text property is a string type without having the docking support.  
  
We have enabled its editing mode on its double click by changing its ReadOnly property and focus changes. Please find the complete sample in below  
   
    
 
Regards, 
Ramya S 



AB Adam Bruss September 21, 2020 02:14 PM UTC

Hi Ramya,

Thank you for the clever solution. 

I think it makes more sense for the smithchart control to have the docking support added to it. Then I can use the same solution as I have implemented for the non-smith chart control. Furthermore I don't see any reason the smithchart control can't have the docking support. They are both charts with titles and legends. 

Could you let me know if the docking support can be added to the smithchart control? And if so, which future release?

Thank you
Adam


YP Yuvaraj Palanisamy Syncfusion Team September 22, 2020 05:04 PM UTC

Hi Adam Bruss, 
 
We have validated your query and considered this as a feature request to provide a support for Windows Forms SmithChart title dock position.   
   
We will prioritize the features every release based on the demands and we do not have an immediate plan to implement this since we committed with already planned work. So, this feature will be available for any of our upcoming releases  
    
You can track the status of this feature from below link    
 
Please cast your vote to make it counts and If you have any more specifications/suggestions to the feature request, you can add it as a comment in the portal.   
 
Regards, 
Yuvaraj 


Loader.
Up arrow icon