翻譯|使用教程|編輯:黃竹雯|2018-12-07 11:11:44.000|閱讀 1078 次
概述:Web圖表控件ChartDirector連載教程分享之3D散點圖,內附下載和鏈接。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
ChartDirector是一個非常理想的圖表工具,它擁有廣泛的圖表類型、分層架構、實時互動的大數據表、普遍適應于各種應用程序以及支持PDF和SVG圖標等的優點。此系列連載旨在介紹ChartDirector的實用教程,供大家學習討論。
此示例演示了創建3D散點圖的基本步驟:
以下代碼可在“cppdemo / threedscatter”中找到。Mf版本的代碼可在“mfcdemo / mfcdemo”中找到(僅限Windows版本)。QT版本的代碼可在“qtdemo / qtdemo”中找到。
#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; }
此示例通過包含下劃線,使用替代視角和連續著色來擴展3D散點圖(1)示例。
下拉線是從數據點下降到XY平面的線。它們有助于可視化點的“高度”(z坐標),如果沒有太多數據點,則可能很有用。
以下代碼可在“cppdemo / threedscatter”中找到。Mf版本的代碼可在“mfcdemo / mfcdemo”中找到(僅限Windows版本)。QT版本的代碼可在“qtdemo / qtdemo”中找到。
#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(3); DoubleArray xData = r->getSeries(20, 100, -10, 10); DoubleArray yData = r->getSeries(20, 100, -10, 10); DoubleArray zData = r->getSeries(20, 100, -10, 10); // Create a ThreeDScatterChart object of size 720 x 520 pixels ThreeDScatterChart *c = new ThreeDScatterChart(720, 520); // Add a title to the chart using 20 points Times New Roman Italic font c->addTitle("3D Scatter Chart (2) ", "timesi.ttf", 20); // Set the center of the plot region at (350, 240), and set width x depth x height to 360 x 360 // x 270 pixels c->setPlotRegion(350, 240, 360, 360, 270); // Set the elevation and rotation angles to 15 and 30 degrees c->setViewAngle(15, 30); // Add a scatter group to the chart using 13 pixels glass sphere symbols, in which the color // depends on the z value of the symbol ThreeDScatterGroup *g = c->addScatterGroup(xData, yData, zData, "", Chart::GlassSphere2Shape, 13, Chart::SameAsMainColor); // Add grey (888888) drop lines to the symbols g->setDropLine(0x888888); // Add a color axis (the legend) in which the left center is anchored at (645, 220). Set the // length to 200 pixels and the labels on the right side. Use smooth gradient coloring. c->setColorAxis(645, 220, Chart::Left, 200, Chart::Right)->setColorGradient(); // 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("threedscatter2.png"); //free up resources delete r; delete c; return 0; }
更多實用教程將會以連載的形式展現,敬請關注~
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn