none
Chart Control - Chart Area RRS feed

  • Question

  • Hi every body 

    I create chart with MS chart control . This chart "must" has two chart area .

    The name of first chart area  is chartarea1 and the second chart area name is chartarea2 .

    The second chart area (chartarea2) "should be" created through run time code and that code looks like this :

     Chart1.ChartAreas.Add("chartarea2")

     Chart1.Series("Series2").ChartArea = "chartarea2"

    NOW ...

    There is a button on the form that makes the second chart area (chartarea2) and set Series2 and graphs plotted correctly .

    So i do not want disable button after drawing and i want to by click again this button,re-plotted graph and replace graph on the  chartarea2 .

    Somebody help me ... 


    • Edited by ali-IRAN Thursday, April 28, 2016 9:59 AM
    Thursday, April 28, 2016 9:54 AM

Answers

  • Hi ali-IRAN,

    >>"So i do not want disable button after drawing and i want to by click again this button,re-plotted graph and replace graph on the  chartarea2 ."

    We need to determine whether the chartarea2 has been inserted into Chart1. If the answer is no, just insert it, otherwise, refresh Chart1. Code below is for your reference.

    Dim count As Integer = Chart1.ChartAreas.Where(Function(area)
                                                       Return area.Name.Equals("chartarea2")
                                                   End Function).Count()
    
    If (count = 0) Then
        Chart1.ChartAreas.Add("chartarea2")
        Chart1.Series("Series2").ChartArea = "chartarea2"
    Else
        Chart1.Refresh()
    End If
    Best Regards,
    Li Wang

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, April 29, 2016 5:13 AM