Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:05 pm
by ConcrdDev >> Wed, 23 Jan 2002 4:19:48 GMT
Its seems so long ago that I did this code - and I can't find the
help on it
and I'm not sure if I used any help to get it going anyway, which is
a
problem, as my client wants some changes done soon !!!
I thought I would copy you the two methods that I use to create two graphs.
The first is a line graph, plotting three sets of values, and the
second is
a histogram, plotting averages over a number of data samples, by
using this
code and replacing my references to data with your own references you
get it
to work.
Peter Gallagher
Concord Systems Ltd
p.s. Sorry about how the methods look below - I hope they cut/paste better
into your Jade App - Good Luck
The first one
reateRollMeanGraph( pJm : JobMaster) updating;
// --------------------------------------------------------------
// Created : 02 November 2000
// By : Peter
// Desc :
//
// --------------------------------------------------------------
vars
str : String;
n0,n1,n2 : Integer;
cht : CTWXChart;
idx,idx2 : Integer;
jme : JobMasterExtra;
min : Decimal[23,6];
max : Decimal[23,6];
med : Decimal[23,6];
mean : Decimal[23,6];
jm : JobMaster;
isMin,isMax : Boolean;
set : CPJMExtraSet;
jdetails : JobMasterExtra;
rollCount : Integer;
sampleCount : Integer;begin
// jme := myJMExtra;
jm := pJm;
cht := cTRollBars; // Set the form control to a local variable- makes
it easier to work with (not a trick)
create set transient;
createJMExtraSetData(jm,set);
min := jm.getMin;
max := jm.getMax;
mean := jm.calculateMean(rollCount , sampleCount);
// write jm.getMicron.dp0;
tbTarget.text := jm.getMicron.dp0;
tbRollCount.text := rollCount.String;
tbSampleCount.text := sampleCount.String;
tbTolerances.text := min.dp0 & ' - '&max.dp0;
tbMean.text := mean.dp1;
cht.setTitleString(0,'Roll Mean');
cht.setTitleFontSize(0,12);
cht.setTitleString(1,'');
cht.setTitleString(2,'Number of rolls sampled');
cht.setTitleFontSize(2,10);
cht.setTitleFontStyle(0,1);
cTRollBars.visible := true;
if min > 0 then
isMin := true;
endif;
if max > 0 then
isMax := true;
endif;
if isMin then
// setup the second data set
cht.setSDataEnable(1,true);
cht.setSDataType(1,0); // SIMPLE_XY_DATA_TYPE
cht.setSPlotType(1,0); // ST_LINEPLOT
cht.setSPlotLineColor(1,Green);
cht.setSDataNumPlotPoints(1,set.size +1);
endif;
if isMax then
// setup the third data set
cht.setSDataEnable(2,true);
cht.setSDataType(2,0); // SIMPLE_XY_DATA_TYPE
cht.setSPlotType(2,0); // ST_LINEPLOT
cht.setSPlotLineColor(2,Green);
cht.setSDataNumPlotPoints(2,set.size +1);
endif;
// setup the Fourth data set (median)
cht.setSDataEnable(3,true);
cht.setSDataType(3,0); // SIMPLE_XY_DATA_TYPE
cht.setSPlotType(3,0); // ST_LINEPLOT
cht.setSPlotLineColor(3,Red);
cht.setSDataNumPlotPoints(3,set.size +1);
cht.setSPlotType(0,0); // ST_LinePlot (0,1) bar plot
cht.setSPlotBarColor(0,Yellow);
cht.setAxisAutoAxis(1,true);
cht.setAxisTitleString(1,'Average Micron');
cht.setAxisLabelFontSize(1,8);
cht.setAxisTitleFontSize(1,10);
cht.setAxisMax(0,set.size +1 );
cht.rightPlotArea := 0.8;
file://write cht.rightPlotArea;
cht.setSDataNumPlotPoints(0,set.size +1);
file://write cht.getSDataNumPlotPoints(0);
idx := 0;
idx2 := 1;
foreach jme in set do
med := jme.CPJMExtra.calculateMean();
if med <> 0 then
cht.setXDataValues(0,0,idx);
cht.setYDataValues(0,0,0,med);
cht.setYDataValues(1,0,0,max);
cht.setXDataValues(0,idx2,idx2);
cht.setYDataValues(0,idx2,0,med);
cht.setYDataValues(1,idx2,0,max);
idx2 := idx2 + 1;
endif;
endforeach;
while idx < set.size +1 do
if isMin then
// min values
cht.setXDataValues(1,idx,idx);
cht.setYDataValues(1,idx,0,min);
endif;
if isMax then
// min values
cht.setXDataValues(2,idx,idx);
cht.setYDataValues(2,idx,0,max);
endif;
cht.setXDataValues(3,idx,idx);
cht.setYDataValues(3,idx,0,mean);
idx := idx +1;
endwhile;
cht.updateGraph;
end;
Second...
createJobHistogram( pJm : JobMaster) updating;
// --------------------------------------------------------------
// Created : 02 November 2000
// By : Peter
// Desc :
//
// --------------------------------------------------------------
vars
str : String;
n0,n1,n2 : Integer;
cht : CTWXChart;
idx,idx2 : Integer;
jme : JobMasterExtra;
min : Decimal[23,6];
max : Decimal[23,6];
med : Decimal[23,6];
mean : Decimal[23,6];
jm : JobMaster;
isMin,isMax : Boolean;
set : CPJMExtraSet;
jdetails : JobMasterExtra;
rollCount : Integer;
sampleCount : Integer;
da : DecimalArray;
startValue : Integer;
endValue : Integer;
plotCount : Integer;
gotStart : Boolean;
gotEnd : Boolean;
maxFrequency: Integer;begin
// jme := myJMExtra;
jm := pJm;
cht := cTJobRollHist; // change the control on the for to a
local
variable
da := jm.calcFrequency();
// work out the size of the graph
idx := 1;
while idx < 300 do
if da[idx] <> 0 then
if gotStart then
endValue := idx;
else
gotStart := true;
startValue := idx;
endValue := idx;
endif;
endif;
idx := idx + 1;
endwhile;
plotCount := endValue - startValue + 1;
// work out max Frequency
idx := startValue;
while idx < endValue do
if da[idx] > maxFrequency then
maxFrequency := da[idx].Integer;
endif;
idx := idx + 1;
endwhile;
cht.setTitleString(0,'Histogram');
cht.setTitleFontSize(0,12);
cht.setTitleString(1,'');
cht.setTitleString(2,'');
cht.setTitleFontSize(2,10);
cht.setTitleFontStyle(0,1);
cht.visible := true;
// this is the chart setup
cht.setSPlotType(0,1); // ST_BarPlot (0,1) bar plot
cht.setSPlotBarColor(0,Blue);
// cht.setAxisAutoAxis(1,true);
cht.setAxisMin(0,startValue - 1); // 0 = x axis
cht.setAxisMax(0,endValue + 1);
cht.setAxisMin(1,0); // 1 = y axis
cht.setAxisMax(1, maxFrequency);
cht.setAxisTitleString(1,'Frequency');
cht.setAxisLabelFontSize(1,8);
cht.setAxisTitleFontSize(1,10);
// cht.setAxisMax(0,plotCount +1 );
cht.rightPlotArea := 0.8;
// write cht.rightPlotArea;
cht.setSDataNumPlotPoints(0,endValue +1);
// write cht.getSDataNumPlotPoints(0);
// write 'PlotCount='&plotCount.String&Tab&'startValue='&startValue.String&Tab &'endVa
lue='&endValue.String;
idx := startValue;
idx2 := 1;
while idx < endValue do
med := da[idx];
cht.setXDataValues(0,idx,idx+1);
cht.setYDataValues(0,idx,0,med);
idx := idx + 1;
endwhile;
cht.updateGraph;
end;