Graphics In Report
download and install ChartDirector for ASP/COM/VB
Add a Bitmap in Report and set method = calcBarchart
Add a method calcBarchart in Report
display container calcBarchart()
{
container con;
COM cd = new COM ("ChartDirector.API");
COM c, xAxis, yAxis, layer;
// COM
int samples = 1, maxSamples = 12;
image img = new image();
array data = new array(types::real);
array labels = new array(types::String);
str filename;
BinData binData = new BinData();
container imageContainer;
BS_SAL_T026 tmpTBL;
;
while select maxof(bsYearMonth),maxof(bsMonth),
sum(bsDSALContractTotalAmount) from tmpTBL
group by bsYearMonth
where tmpTBL.bsYear == YrEnd
{
while(samples < str2int(tmpTBL.bsMonth))
{
data.value(samples, 0.0);
labels.value(samples, strRFix(int2str(samples),2,"0"));
samples = samples + 1;
}
data.value(samples, tmpTBL.bsDSALContractTotalAmount);
labels.value(samples, tmpTBL.bsMonth);
samples = samples + 1;
}
while(samples < 13)
{
data.value(samples, 0.0);
labels.value(samples, strRFix(int2str(samples),2,"0"));
samples = samples + 1;
}
//data.value(samples, 0.0);
//creditMax.value(samples, tmpTBL.bsDSALContractTotalAmount);
//labels.value(samples, "A");
// First, create a suitably sized BarChart
c = COM::createFromVariant(cd.XYChart(500, 320));
c.setDefaultFonts("simsun.ttc","simsun.ttc","simsun.ttc","simsun.ttc");
// c.setFontStyle('verdana');
// Set the plotarea rectangle to start at (100, 40) and of
// 280 pixels in width and 240 in height
c.setPlotArea(100, 40, 280, 240);
// Add a legend box at (400, 100)
c.addLegend(400, 100);
// Add a title to the chart
c.addTitle("订货");
// Set the labels on the x axis
xAxis = c.xAxis();
xAxis.setLabels(labels);
xAxis.setTitle("月");
yAxis = c.yAxis();
yAxis.setTitle("金额");
layer = c.addBarLayer(data, -1, "金额");
//layer = c.addBarLayer(creditMax, -1, "CreditMax");
layer.set3D();
// output the chart
filename = winApi::getTempFilename(winApi::getTempPath(), "AXA") + ".jpg";
c.makeChart(filename);
//img.loadFile(filename);
binData.loadFile(filename);
imageContainer = binData.getData();
if (imageContainer)
{
img = new Image();
img.setData(imageContainer);
}
winAPI::deleteFile(filename);
return img.getData();
}
posted on 2008-09-02 16:33 lingdanglfw 阅读(266) 评论(0) 编辑 收藏 举报