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

Add Diagram Controls on Chart

Hi,

I need to add Diagram controls on the Chart Area above the plotted chart values. The diagram control needs to be fixed at that point. Is this possible?

1 Reply

AT Anandaraj T Syncfusion Team October 31, 2016 07:01 AM UTC

Hi Ani, 

Thanks for using Syncfusion products. 

We have prepared a simple sample for your requirement and it can be downloaded from the following link 

Query #1: I need to add Diagram controls on the chart area above the plotted chart values 

We can add Diagram controls as child controls to chart and place them at desired location. 

Please refer the following code snippet to add Diagram control on Chart 

[C#] 
 
            //Add diagram as a child control to Chart 
            this.chartControl1.Controls.Add(this.diagram1); 
 
            //Ensure size of the diagram control will not change after resizing 
            this.diagram1.Dock = DockStyle.None; 
            this.diagram1.Anchor = AnchorStyles.None; 


Query #2: The diagram control needs to be fixed at that point 

We can use the Paint event of Chart control and GetPointByValue method of ChartArea to place the diagram at fixed location. 

Please refer the following code snippet to achieve this 

[C#] 
 
            //Place diagram contol at fixed location using Paint event 
            this.chartControl1.Paint += chartControl1_Paint; 
 
        //Paint event of Chart 
        void chartControl1_Paint(object sender, PaintEventArgs e) 
        { 
            ChartControl chart = sender as ChartControl; 
            //Place diagram at a fixed location (eg: [4, 80]) 
            this.diagram1.Location = chart.ChartArea.GetPointByValue(new ChartPoint(4, 80)); 
        } 


Please let us know if you have any concern. 

Regards, 
Anand

Loader.
Up arrow icon