Ask a questionAsk a question
 

AnswerDisplaying 12 months data using Line Chart

  • Saturday, October 17, 2009 4:35 AMihsan Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Dear all,

    I want to display Yearly Line graph which will be dsiplaying 12 months Data in the Graph.I manage to display the points in the Line Graph.but the problem is, it is only displaying only 3 months FEb,MAR,APR .but it supposed to display from JAN to DEC.Is there anyway i can set the number of values in the X- Axis?.

    Additionally After displaying the yearly Graph i want to display the monthly Graph,when the user clicks or selects any month from the yearly graph i want to display the monthly graph .How i can do that?.

    I manage to display the data as shown below except x-axis value.
    View Image Below.

    Real scenario


    Awaiting for your earliest reply.

    Thanks in Advance.
    Ihsan

Answers

  • Monday, October 19, 2009 4:05 PMCole Brand Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    I use something like the following in a loop in the back-code to show my tooltip:

    for (int j = 0; j < Chart1.Series[i].Points.Count; j++)
    {
        Chart1.Series[i].Points[j].ToolTip = "Summary on " + i.ToString() + ": #VALY, Time: #VALX";
    }

    However, this only shows a tooltip when they hover over the point. You could add a URL for the particular point, and perhaps use a GET call to another page. As an example:

    for (int j = 0; j < Chart1.Series[i].Points.Count; j++)
    {
        Chart1.Series[i].Points[j].Url = "~/MyGraphPage.aspx&ValY=" + "#VALY" + "&ValX=" + "#VALX";
                                                                          //I put the VALY and VALX in their own brackets so
                                                                          //you can visually spot them, but that's just a stylistic choice.
    }

    And combining them we could end up with:

    for (int j = 0; j < Chart1.Series[i].Points.Count; j++)
    {
        Chart1.Series[i].Points[j].ToolTip = "Summary on " + i.ToString() + ": #VALY, Time: #VALX";
        Chart1.Series[i].Points[j].Url = "~/MyGraphPage.aspx&ValY=" + "#VALY" + "&ValX=" + "#VALX";
                                                                          //I put the VALY and VALX in their own brackets so
                                                                          //you can visually spot them, but that's just a stylistic choice.
    }

    This is just one way to do this, but it seems to be in keeping with what you've already done.

    I think it's safe to point out that really this control exposes two types of element on render. It does an image (created by the dll) and it generates a standard HTML client-side IMAGEMAP element, and so while the map customization is made much more OO, it can't do anything more complicated than a standard map generator can do. It WILL, however, allow you to assign additional attributes.

    Also, since we're talking imagemaps, it's my understanding that the postback would still only be of the GET variety with the X and Y appended as two values if this were a serverside imagemap. (I haven't seen a "ismap" property yet, but it wouldn't surprise me if one exists - MSDN turns up nothing, and of course this package is too new for most online help groups)

    Hope this helps, doubt it does.
    Please don't forget (and feel free to remind me) to post if you got the answer you wanted, and select who really answered your post when you do so future visitors will know too! Remember, this is .NET 4.0 in a .NET 3.5 world, you're a pioneer right now.

All Replies

  • Saturday, October 17, 2009 7:18 PMCole Brand Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi Ihsan, did you manage to find out what has happened here?
    Can you confirm the data is positive and not zero for Oct - May? While this sounds like a stupid question, it's entirely plausible, and sometimes we overlook simple things.

    Additionally, the graph doesn't match the request, the graph shows Aug - Sep, but the request mentions Feb - Apr.

    I think some more explanation is necessary. Can you share any code or data for examples?

    That clears the graphing problem issue.

    The second question you have is related to "How can the user click on a region of the graph to see a narrower set of data". I think that the answer to this is going to require more input on your behalf. Is this for an ASP.NET or a desktop app? I know that the utilities for the desktop app are supposed to permit zooming, but on a webpage you'll need a repost. I see these as having two distinct solutions.

    Additionally, in the WebSamples download (which I strongly encourage you to download), they show an example of how to display a second graph when the user hovers over the first graph.

    Hope this helps.
    Please don't forget (and feel free to remind me) to post if you got the answer you wanted, and select who really answered your post when you do so future visitors will know too! Remember, this is .NET 4.0 in a .NET 3.5 world, you're a pioneer right now.
  • Sunday, October 18, 2009 3:00 PMihsan Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    HI,

    Thanks for your quick reply.

    I manage to solve the main problem which is displaying the 12 months data.My application is an asp.net application.

    Let me give you  small explanation about my system.i want to create a dashboard which will display yearly,monthly,Weekly,Daily,Hourly graph  based on the users selection.

    Now the second problem getting x and y axis values when the user clicks a particular point?.

    I have tried few ways to get the x and y axis as shown below.


    1)
           For Each series As Series In Me.Chart1.Series
                series.PostBackValue = "series:" + series.Name + ",#INDEX"
                ' series.PostBackValue = "series:" + series.Name + "X value \t= #VALX{d}\nY value \t= #VALY{C}\nRadius \t= #VALY2{P}"
            Next

        
    2)

            '   Chart1.Series("Series1").PostBackValue = "#AXISLABEL"
            '   Chart1.Series("Series1").ToolTip = "#AXISLABEL Region: #VAL{C}"

    3)
            Chart1.Series("Series1").ToolTip = "#VALX: #VAL{}"


    All returning some values but it is not giving x and y values.

    I hope this will help you to get more idea about the questions i asked.Thanks in advance.

    Best Regards
    Ihsan
  • Monday, October 19, 2009 4:05 PMCole Brand Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    I use something like the following in a loop in the back-code to show my tooltip:

    for (int j = 0; j < Chart1.Series[i].Points.Count; j++)
    {
        Chart1.Series[i].Points[j].ToolTip = "Summary on " + i.ToString() + ": #VALY, Time: #VALX";
    }

    However, this only shows a tooltip when they hover over the point. You could add a URL for the particular point, and perhaps use a GET call to another page. As an example:

    for (int j = 0; j < Chart1.Series[i].Points.Count; j++)
    {
        Chart1.Series[i].Points[j].Url = "~/MyGraphPage.aspx&ValY=" + "#VALY" + "&ValX=" + "#VALX";
                                                                          //I put the VALY and VALX in their own brackets so
                                                                          //you can visually spot them, but that's just a stylistic choice.
    }

    And combining them we could end up with:

    for (int j = 0; j < Chart1.Series[i].Points.Count; j++)
    {
        Chart1.Series[i].Points[j].ToolTip = "Summary on " + i.ToString() + ": #VALY, Time: #VALX";
        Chart1.Series[i].Points[j].Url = "~/MyGraphPage.aspx&ValY=" + "#VALY" + "&ValX=" + "#VALX";
                                                                          //I put the VALY and VALX in their own brackets so
                                                                          //you can visually spot them, but that's just a stylistic choice.
    }

    This is just one way to do this, but it seems to be in keeping with what you've already done.

    I think it's safe to point out that really this control exposes two types of element on render. It does an image (created by the dll) and it generates a standard HTML client-side IMAGEMAP element, and so while the map customization is made much more OO, it can't do anything more complicated than a standard map generator can do. It WILL, however, allow you to assign additional attributes.

    Also, since we're talking imagemaps, it's my understanding that the postback would still only be of the GET variety with the X and Y appended as two values if this were a serverside imagemap. (I haven't seen a "ismap" property yet, but it wouldn't surprise me if one exists - MSDN turns up nothing, and of course this package is too new for most online help groups)

    Hope this helps, doubt it does.
    Please don't forget (and feel free to remind me) to post if you got the answer you wanted, and select who really answered your post when you do so future visitors will know too! Remember, this is .NET 4.0 in a .NET 3.5 world, you're a pioneer right now.
  • Tuesday, October 20, 2009 7:14 AMihsan Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    HI Cole brand,

    I manage to found out what is the reason behind not displaying X- Axis value instead of point. Because I am adding the X-axis value as Date and Time. If i add it as string it is giving the value.

    Do you have any suggestions?.

    Best Regards
    ihsan

  • Saturday, November 07, 2009 1:58 AMihsan Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    HI,


    I still can not find the answer for if the X-axis is Date and Time i cant get the x-axis value when the user clicks any particular point in the chart.
    Any suggessions?.

    Best Regards
    Ihsan
  • Sunday, November 08, 2009 5:40 AMDhruv Patel Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Has Code
    Hello Ihsaan,

    Going through your problem, I suggest you to try this :
    For(int chartIndex=0; chartIndex<Somechart.Series.Count; chartIndex++)
    {
            // For your problem, you bind your DateTime value in query as Convert(varchar,datetimefield,datetimeformatcode) as datetimefield
            Somechart.Series[chartIndex].Tooltip = "#VALX";
    
            Somechart.Series[chartIndex].Url="newpagename.aspx?SeriesPoint=#VALX";
    }
    
    Hope, I would be helpful.
    Please don't forget to mark my reply as answer, if you think it helped in achieving desired solution.
  • Tuesday, November 10, 2009 12:05 PMihsan Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hi Patel,

    I tried ,still the same.i cant get the X Value.Surprisingly i can get the value of Y-Axis.If the x-axis string,then i can get the x-axis value .When the x-axis is dateandtime ,i can’t get the X-value.


    Any other suggestions?.


    Regards
    Ihsan

  • Tuesday, November 10, 2009 3:56 PMCole Brand Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

                    Chart1.Series["Top"].XValueType = ChartValueType.Date;
                    Chart1.Series["Top"].YValueType = ChartValueType.Double;
                    Chart1.Series["Top"].Points.DataBind( l , "myDate", "myValue", "Tooltip=myDate" );
                    foreach ( DataPoint dp in Chart1.Series["Top"].Points )
                        dp.ToolTip = "Date: " + dp.ToolTip.ToString() + "\r\nValue: #VALY";

    I happen to have a bit of this in some prototype code I'm working on. I see my Date just fine in the tooltip.
    Please don't forget (and feel free to remind me) to post if you got the answer you wanted, and select who really answered your post when you do so future visitors will know too! Remember, this is .NET 4.0 in a .NET 3.5 world, you're a pioneer right now.