Office Web Components Charting within Infopath - InfoPath Dev
in

InfoPath Dev

Office Web Components Charting within Infopath

Last post 06-09-2009 04:13 PM by kabeero. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 06-05-2009 08:56 AM

    Office Web Components Charting within Infopath

    Hello.  I have been trying to build a "reports"-type page in my Infopath form using the charting capabilities provided by Office Web Components/OWC.

    So far I have gotten my chart to be rendered into a .PNG image using the tutorial provided by Negovan (Link), but it can only be rendered by going to an aspx page, e.g. samplegraph.aspx.  Once this page is loaded the image is created.  The reason I cannot link this as a fixed image is because I am retrieving information from a database (which will be updated using this form) which can change the way the image looks, so I want this to be rendered using the form.

    I do not want my Infopath form to open an external window so I am skeptical about simply hyperlinking to an .aspx page.  My instincts tell me to write <img src="samplegraph.aspx" /> but I do not know if this will work, or even where to include it in my Infopath form.

    I understand OWC has introduced a custom control in Infopath called "Microsoft Office Chart 11.0" that is supposed to provide similar capabilities but I have been unable to get it to work.  I am pretty sure this could get the same kind of graph for me but I am not sure how to code it to retrieve from the database as the tutorial from Negovan has allowed me to do.

     

    Any advice or suggestions are appreciated.

  • 06-05-2009 12:28 PM In reply to

    Re: Office Web Components Charting within Infopath

    Update:

    One of the things I've tried so far is saving the chart as an image instead of exporting to a webpage.  I then put this code in a web service and returned the path's string value, which I was hoping to put into my infopath form as a <img src=path/> but I have yet to get this to work.  However, I am able to control where the image is stored, how it is opened, etc by doing this instead of going to an .aspx page so this is a better result.

    Does anyone have any clue how I can use this path to output as an image within my form?

  • 06-09-2009 04:13 PM In reply to

    Re: Office Web Components Charting within Infopath

     For those interested in coming up with a solution , here is what worked.

     

    To get an image to be displayed in Infopath I made a key value called my:value under the myFields subfolder in Data Sources.

    My web service was returning a path which I was assigning to this key value.

    A picture control  was linked to the my:value's XPath and "Allow users to upload an image" was disabled.

     

    To get this to work, I had to modify the code behind a button I was calling Generate Graph, and pulled up its C# code.

     Here, under the Clicked Event for the button control, I added the following:

     

    1.         public void CTRL2_6_Clicked(object sender, ClickedEventArgs e)
    2.         {   
    3.             GenerateGraph();
    4.         }
    5.         private void GenerateGraph()
    6.         {
    7.             string path = auto.Graph();
    8.             XPathNavigator xnDoc = this.MainDataSource.CreateNavigator();
    9.             XPathNavigator xnPath = xnDoc.SelectSingleNode("/dfs:myFields/my:value", this.NamespaceManager);
    10.             xnPath.SetValue(path);
    11.         }

    Note: auto is my webservice which I've instantiated in the InternalStartup() method which is provided by default.

Page 1 of 1 (3 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.