The i-Technology Media!
Register | Log in
   
 
.NET  ·  AJAX  ·  CLOUD  ·  ECLIPSE  ·  FLEX  ·  OPEN WEB  ·  iPHONE  ·  JAVA  ·  LINUX  ·  OPEN SOURCE  ·  ORACLE  ·  PBDJ  ·  SEARCH  ·  SILVERLIGHT  ·  SOA  ·  VIRTUALIZATION  ·  WEB 2.0  ·  WIRELESS  ·  XML
Comments
Drool, Britannia? Is the UK Failing the Cloud?
By Roger Strukhoff
Richard Davies wrote: The UK has a good crop of technology pioneers in cloud computing - for example ElasticHosts, FlexiScale, Flexiant, OnApp - and also some strong government initiatives such as G-Cloud. We will have to see whether this kind of technical leadership converts into swift mass-market adoption or not.
Jan. 8, 2012 11:38 AM EST
read more & respond »
Cloud Expo on Google News
Did you read today's front page stories & breaking news?

Cloud Expo & Virtualization 2011 West
Keynotes
Oracle
Opening Keynote | An Enterprise Cloud for Business-Critical Applications
Abiquo
Day 2 Keynote | The Enterprise Cloud Tightrope - Balancing for Success
Akamai
Day 3 Keynote | The DNA of an Enterprise Cloud
DIAMOND SPONSOR:
Oracle
Many Clouds, Many Choices'Cloud
PLATINUM PLUS SPONSORS:
Abiquo
Enterprise Cloud Best Practices - Town Hall - Join the discussion…
PLATINUM SPONSORS:
Intel
Progressing Toward the Federated, Automated and Client-Aware Cloud
New Relic
How to build an app with Twitter-like throughput
Rackspace
Computing in the Cloud Era
GOLD SPONSORS:
Gale Technologies
Practical Cloud Migration
IBM
Re-think IT. Re-inventing Business.
Intel/McAfee
Identity Driven Security in the Cloud
PerspecSys
Hackers Hackers Everywhere, Is My Public Cloud That Safe?
Red Hat
Unlock the Value of the Cloud
SHI
Mission Critical Applications and the Cloud - Myth or Reality?
SoftLayer
Not Your Grandpa's Cloud
Terremark
Integrating Enterprise Clouds
VMware
Upgrade to a vCloud
POWER PANELS:
Cloud Expo Silicon Valley: CTO Power Panel
Cloud Expo Silicon Valley: CEO Power Panel
Cloud Expo Silicon Valley: Cloud SuperStars Panel
Cloud Expo Silicon Valley: CloudNOW Panel
Click For 2010 West
Event Webcasts
Cloud Expo & Virtualization 2011 East
DIAMOND SPONSOR:
Dell
Dell & VMware Deliver the Enterprise Hybrid Cloud
PLATINUM PLUS SPONSORS:
Abiquo
Are Financial Services Organizations Risking Security by Avoiding Cloud Computing?
Oracle
From Consolidation to Enterprise Private PaaS
PLATINUM SPONSORS:
Intel
Driving the Transformation to Next Generation Cloud Data Centers
Rackspace
The Inevitability of an Open Cloud
GOLD SPONSORS:
CA Technologies
Follow YOUR path to Cloud Computing
Interxion
Who Keeps the Cloud in the Air?
Microsoft
Patterns for Cloud Computing
PerspecSys
War in the Clouds: Are you ready?
ServiceMesh
The Big Win: Stop Playing Small-Ball with Your Cloud Strategy
Terremark
Evaluating Enterprise Clouds
Xiotech
Cloud Storage: Myths and Realities
POWER PANELS:
Cloud Expo New York: CTO Power Panel
Cloud Expo New York: CEO Power Panel
Cloud Expo New York: CMO Power Panel
Cloud Expo New York: Wrap-Up Power Panel
Click For 2010 West
Event Webcasts
Live Google News by SYS-CON!
Top Three Links You Must Click On


Features
Using the Microsoft Chart Controls in PowerBuilder
Adding new charting capabilities to PowerBuilder applications

By: Bruce Armstrong
Aug. 27, 2009 08:45 AM

You may not be aware of this, but Microsoft now provides a rather powerful charting control free of charge as an add-in for .NET 3.5. It's available for download at http://xrl.us/ben3pm. Because it supports 35 different chart types (see Figure 1), it can add significant new charting capability to PowerBuilder applications.

As a .NET visual control we should be able to use it "natively" within PowerBuilder .NET targets once PB 12 is released. However, for those using the current (pre-12.0) versions of PowerBuilder, and those who will still be creating Win32 target applications even after moving to PB 12, it would still be nice to be able to use that control. This article will show you how to do that.

As with other .NET visual controls I've implemented in PowerBuilder in previous PBDJ articles, we'll be using the Microsoft Interop Forms Toolkit (http://xrl.us/beo995) to create a COM wrapper for the control. Once we've done that, we need to create methods, properties, and events on the wrapper that PowerBuilder will use to interact with the underlying control.

For example, there's no direct method for getting the data out of a PowerBuilder DataWindow and into the Microsoft Chart Control.

Even in DataWindow.NET, there's no good way of getting the data out of a DataWindow in the System.Data.Dataset object type that most .NET data-aware controls use. What I've done is created a SetData method on the wrapper that takes the data as an XML string, converts that to a DataSet, and then assigns that to the chart control:

public int SetData ( String xml)
{
System.IO.StringReader sr;
sr = new System.IO.StringReader(xml);
dataset.ReadXml(sr);
chart.DataSource = dataset;
chart.DataBind();
return 1;
}

In addition, the chart type value for the control is set through an enumerated value on a .NET class. Since PowerBuilder can't use that in a Win32 target, I created a method on the wrapper that takes the chart type designed as a string and then determines the applicable enumerated value based on it:

public int SetChartType(String type)
{
switch(type)
{
case "Area":
series.ChartType = SeriesChartType.Area ;
break;
case "Bar":
series.ChartType = SeriesChartType.Bar;
break;
case "BoxPlot":
series.ChartType = SeriesChartType.BoxPlot;
break;
.
.
.
default:
series.ChartType = SeriesChartType.Line ;
break;
}
return 1;
}

In PowerBuilder, I created a new Standard User Object of type olecontrol, and then indicated that I want to base it on the InteropUserControl wrapper I created. I can create additional wrapper functions on this user object that make the control more "PB friendly." Now I have a visual user control I can drop onto any window in any application.

In the example code that you can download from the PBDJ site, I'm using the following code to initially create the chart in the sample window:

string                           ls_xml
u_ds_salaries               lds_salaries

lds_salaries = CREATE u_ds_salaries
ls_xml = lds_salaries.Object.DataWindow.Data.XML
Destroy lds_salaries

ole_chart.of_setdata( ls_xml )
ole_chart.of_addseries( "Salaries" )
ole_chart.of_setXseries( "emp_lname" )
ole_chart.of_setYseries( "salary" )
ole_chart.of_Setcharttype( "Line" )

u_ds_salaries is just a datastore user object that contains a DataWindow that contains employee data from the PowerBuilder example database. I've stored the data in the DataWindow so that you don't need to worry about configuring a database connection to run the sample. There are also a number of minor wrapper functions being called on the interop user control that I haven't mentioned here for brevity. In this particular sample, when the user selects a different graph type from the radio buttons, I just pass the new chart type selected to the SetChartType method.

That's all there is to it. About 300 lines of C# code that I had to add to the interop control, and significantly less than that in the PowerBuilder sample. Obviously, you'll want to extend the control to make use of more of the underlying functionality of the Microsoft Chart Controls, but the sample should give you a significant start.

Published Aug. 27, 2009— Reads 5,686 — Feedback 1
Copyright © 2009 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
About Bruce Armstrong
Bruce Armstrong is a development lead with Integrated Data Services (www.get-integrated.com). A charter member of TeamSybase, he has been using PowerBuilder since version 1.0.B. He was a contributing author to SYS-CON's PowerBuilder 4.0 Secrets of the Masters and the editor of SAMs' PowerBuilder 9: Advanced Client/Server Development.

Add Your Feedback

In order to post a comment you need to be registered and logged in.

Register | Sign-in

Reader Feedback: Page 1 of 1

#1
Dimitri Joosten commented on 8 Sep 2009

Hi Bruce, this technique is very usefull! I am evaluating it now and see how I can use it in the (near) future! Thanks!


Subscribe to the World's Most Powerful Newsletters
Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021

SYS-CON Featured Whitepapers

ADS BY GOOGLE

Breaking Java News
Make No Mistake, This Scott Tucker is Focused on Track Records
Julia Roberts and Meryl Streep Are Attached to AUGUST: OSAGE COUNTY
Huntsman Breaks Ground on New Asia Pacific Technology Center
Grupo Elektra to Acquire Advance America for $10.50 Per Share
Interfor Announces the Retirement of Sandy Fulton, Chief Operating Officer
Champion Racer Reflects on Recent Success
Desmarais To Increase Working Interests at Barrhead and Bigoray
Divestment of Sony Ericsson completed
Permaswage Suzhou Co. Ltd. Receives AS9100 Accreditation
111th Canton Fair Opens in April

ADVERTISE   |   MAGAZINE SUBSCRIPTIONS   |   FREE BREAKING-NEWSLETTERS!   |   SYS-CON.TV   |   BLOG-N-PLAY!   |   WEBCAST   |   EDUCATION   |   RESEARCH

.NET Developer's Journal - .NETDJ   |   ColdFusion Developer's Journal - CFDJ   |   Eclipse Developer's Journal - EDJ   |   Enterprise Open Source Magazine - EOS
Open Web Developer's Journal - OPENWEB   |   iPhone Developer's Journal - iPHONE   |   Virtualization - Virtualization   |   Java Developer's Journal - JDJ   |   Linux.SYS-CON.com
PowerBuilder Developer's Journal - PBDJ   |   SEO / SEM Journal - SJ   |   SOAWorld Magazine - SOAWM   |   IT Solutions Guide - ITSG   |   Symbian Developer's Journal - SDJ
WebLogic Developer's Journal - WLDJ   |   WebSphere Journal - WJ   |   Wireless Business & Technology - WBT   |   XML-Journal - XMLJ   |   Internet Video - iTV
Flex Developer's Journal - Flex   |   AJAXWorld Magazine - AWM   |   Silverlight Developer's Journal - SLDJ   |   PHP.SYS-CON.com   |   Web 2.0 Journal - WEB2
Apache   |   CMS   |   CRM   |   HP   |   Oracle Journal   |   Perl   |   Python   |   Red Hat   |   Ruby on Rails   |   SAP   |   SaaS

SYS-CON MEDIA:   ABOUT US   |   CONTACT US   |   COMPANY NEWS   |   CAREERS   |   SITE MAP
SYS-CON EVENTS:   |  AJAXWorld Conference & Expo  |  iPhone Developer Summit  |  Cloud Computing Conference & Expo  |  SOA World Conference & Expo  |  Virtualization Conference & Expo
INTERNATIONAL SITES:   India  |  U.K.  |  Canada  |  Germany  |  France  |  Australia  |  Italy  |  Spain  |  Netherlands  |  Brazil  |  Belgium
 Terms of Use & Our Privacy Statement     About Newsfeeds / Video Feeds
Copyright ©1994-2008 SYS-CON Publications, Inc. All Rights Reserved. All marks are trademarks of SYS-CON Media.
Reproduction in whole or in part in any form or medium without express written permission of SYS-CON Publications, Inc. is prohibited.
 
close this window