Browse DevX
Sign up for e-mail newsletters from DevX


Serve Business Graphics from Any XML Source : Page 3

Using the flexibility afforded by defining data in XML and parsing it with XPATH, you can develop a decoupled VB.NET application that serves up business graphics.




Building the Right Environment to Support AI, Machine Learning and Deep Learning

Configuring the chart object is a two-step process. The first step is to set the cosmetic properties of the chart as defined in the configuration file. The second is to load the data into the chart.

The CallCharter function (Listing 2) achieves this. It parses the configuration file to get a chart type and then builds a chart according to the <TYPE> setting in that file.

This function is easily expanded to allow the user to add new settings to the configuration XML file and have them parsed, effectively exposing the property model of the charting engine (in this case Microsoft OWC) to a user via a properties file.

At present, the configuration is quite simple, only the chart type, background and foreground colors, and the legend position are configurable.

The CallCharter function loads the data to the Charting engine, as specified in the XPath variables, with the following lines:

xNodeList = xmlSource.SelectNodes(strXPath)
xCatsNodeList = xmlSource.SelectNodes(strCategories)

These create the nodelist from the XPath variables that have been sliced out of the configuration document. It then walks through these NodeLists, creating a string array that gets loaded by the OWC, which recognizes this data structure for adding data series and data categories.

Figure 4: Stacked Bar Chart. This shows the use of multiple data series to define a stacked bar chart.

Figure 3: Sample Bar Chart. This bar chart is built up using an XPath where only players whose position is DEF or DEF-MID have their overall points plotted.

The Results
In addition to the pie chart shown above, I've provided two other examples of charts that were built with the charts.xml file included in the download (see Figures 3 and 4). You can add your own charts easily by amending this file.

You can modify the chart server to accept URL-driven data services. See the sidebar "Expanding the Functionality."

The revolution in data interchange brought about by XML has only just begun. New technologies are emerging every day that allow us to think about the information that we need in new and exciting ways. XPath, a simple innovation, has opened up new realms of possibility for automatic use of this data. This chart server is just a simple example of some very exciting things to come.

Laurence Moroney is a freelance enterprise architect who specializes in designing and implementing service-oriented applications and environments using .NET, J2EE, or (preferably) both. He has authored books on .NET and Web services security, and more than 30 professional articles. A former Wall Street architect, and security analyst, he also dabbles in journalism, reporting for professional sports. You can find his blog at http://www.philotic.com/blog.
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date