原創(chuàng)|使用教程|編輯:郝浩|2013-03-11 16:08:05.000|閱讀 5378 次
概述:用Excel做三維散點圖無法滿足需求,后來下載了Web圖表控件ChartDirector,做出來的效果還不錯。今天就跟大家演示一下如何用ChartDirector創(chuàng)建三維散點圖。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
曾經(jīng)嘗試用Excel做三維散點圖,但發(fā)現(xiàn)Excel繪制出來的實質(zhì)還是一個二維圖表,無法滿足需求,后來下載了Web圖表控件ChartDirector,剛好它支持三維散點圖樣式,做出來的效果還不錯。今天就跟大家演示一下如何用ChartDirector創(chuàng)建三維散點圖。
1、用ThreeDScatterChart.ThreeDScatterChart創(chuàng)建一個ThreeDScatterChart對象
2、用ThreeDChart.setPlotRegion指定繪圖區(qū)域的位置和大小
3、用ThreeDScatterChart.addScatterGroup向圖表添加一組散點。在本例中,標記顏色設(shè)置為SameAsMainColor,顏色會根據(jù)Z坐標的顏色軸進行變化,顏色軸的訪問可以用ThreeDChart.colorAxis。
4、用ThreeDChart.setColorAxis設(shè)置顏色軸的位置
5、分別用BaseChart.addTitle 和 Axis.setTitle添加圖表和軸標題
6、最后用BaseChart.makeChart生成圖表
#include "chartdir.h" int main(int argc, char *argv[]) { // The XYZ data for the 3D scatter chart as 3 random data series RanSeries *r = new RanSeries(0); DoubleArray xData = r->getSeries(100, 100, -10, 10); DoubleArray yData = r->getSeries(100, 0, 0, 20); DoubleArray zData = r->getSeries(100, 100, -10, 10); // Create a ThreeDScatterChart object of size 720 x 600 pixels ThreeDScatterChart *c = new ThreeDScatterChart(720, 600); // Add a title to the chart using 20 points Times New Roman Italic font c->addTitle("3D Scatter Chart (1) ", "timesi.ttf", 20); // Set the center of the plot region at (350, 280), and set width x depth x // height to 360 x 360 x 270 pixels c->setPlotRegion(350, 280, 360, 360, 270); // Add a scatter group to the chart using 11 pixels glass sphere symbols, in // which the color depends on the z value of the symbol c->addScatterGroup(xData, yData, zData, "", Chart::GlassSphere2Shape, 11, Chart::SameAsMainColor); // Add a color axis (the legend) in which the left center is anchored at (645, // 270). Set the length to 200 pixels and the labels on the right side. c->setColorAxis(645, 270, Chart::Left, 200, Chart::Right); // Set the x, y and z axis titles using 10 points Arial Bold font c->xAxis()->setTitle("X-Axis Place Holder", "arialbd.ttf", 10); c->yAxis()->setTitle("Y-Axis Place Holder", "arialbd.ttf", 10); c->zAxis()->setTitle("Z-Axis Place Holder", "arialbd.ttf", 10); // Output the chart c->makeChart("threedscatter.png"); //free up resources delete r; delete c; return 0; }
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自:慧都控件