Consultor Eletrônico



Kbase P88765: How to access Microsoft Office Chart OCX?
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   10/16/2008
Status: Unverified

GOAL:

How to access Microsoft Office Chart OCX?

GOAL:

How to show progress data in a chart ?

FIX:

1 - Instantiate the Microsoft Office Chart OCX and create a button.

2 - Add code below to the Definitions Section:

DEFINE VARIABLE chConstants AS COM-HANDLE.

3 - Add code below to the ON Choose event OF Button-1:

/* Clear the contents of the chart workspace. This removes
any old charts that may already exist and leaves the chart workspace
completely empty. One chart object is then added. */

chCtrlFrame:ChartSpace:Clear.
chCtrlFrame:ChartSpace:Charts:ADD(0).
ASSIGN chConstants = chCtrlFrame:ChartSpace:Constants.

/* Add three series to the chart. */

chCtrlFrame:ChartSpace:Charts(0):SeriesCollection:ADD(0).
chCtrlFrame:ChartSpace:Charts(0):SeriesCollection:ADD(0).
chCtrlFrame:ChartSpace:Charts(0):SeriesCollection:Add(0).

/* Series one contains sales growth data for 1998.
Set the series caption (the text that appears in the legend)*/

chCtrlFrame:ChartSpace:Charts(0):SeriesCollection(0):Caption = "1998".
chCtrlFrame:ChartSpace:Charts(0):SeriesCollection(0):SetData(chConstants:chDimCategories, chConstants:chDataLiteral,"Car,Truck,Minivan,Sport-Utility").
chCtrlFrame:ChartSpace:Charts(0):SeriesCollection(0):SetData(chConstants:chDimValues, chConstants:chDataLiteral,"0.2,0.06,0.17,0.13").

/* Series two contains sales growth data for 1999.
Update the values array, then set the chart data. */

chCtrlFrame:ChartSpace:Charts(0):SeriesCollection(1):Caption = "1999".
chCtrlFrame:ChartSpace:Charts(0):SeriesCollection(1):SetData(chConstants:chDimCategories, chConstants:chDataLiteral,"Car,Truck,Minivan,Sport-Utility").
chCtrlFrame:ChartSpace:Charts(0):SeriesCollection(1):SetData(chConstants:chDimValues, chConstants:chDataLiteral,"0.38,0.82,0.28,0.62").

/* Series two contains sales growth data for 2000.
Update the values array, and then set the chart data.*/

chCtrlFrame:ChartSpace:Charts(0):SeriesCollection(2):Caption = "2000".
chCtrlFrame:ChartSpace:Charts(0):SeriesCollection(2):SetData(chConstants:chDimCategories, chConstants:chDataLiteral,"Car,Truck,Minivan,Sport-Utility").
chCtrlFrame:ChartSpace:Charts(0):SeriesCollection(2):SetData(chConstants:chDimValues, chConstants:chDataLiteral,"0.42,0.12,0.55,0.25").

/* Make the chart legend visible, format the left value axis as percentage,
and specify that value gridlines are at 10% intervals. */

chCtrlFrame:ChartSpace:Charts(0):HasLegend = True.
chCtrlFrame:ChartSpace:Charts(0):Axes(chConstants:chAxisPositionLeft):NumberFormat = "0%".
chCtrlFrame:ChartSpace:Charts(0):Axes(chConstants:chAxisPositionLeft):MajorUnit = 0.1.