本文整理汇总了C++中XYChart类的典型用法代码示例。如果您正苦于以下问题:C++ XYChart类的具体用法?C++ XYChart怎么用?C++ XYChart使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了XYChart类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
// The data for the area chart
double data0[] = {42, 49, 33, 38, 51, 46, 29, 41, 44, 57, 59, 52, 37, 34, 51, 56, 56, 60, 70,
76, 63, 67, 75, 64, 51};
double data1[] = {50, 45, 47, 34, 42, 49, 63, 62, 73, 59, 56, 50, 64, 60, 67, 67, 58, 59, 73,
77, 84, 82, 80, 84, 89};
double data2[] = {61, 79, 85, 66, 53, 39, 24, 21, 37, 56, 37, 22, 21, 33, 13, 17, 4, 23, 16, 25,
9, 10, 5, 7, 16};
const char *labels[] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12",
"13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24"};
// Create a XYChart object of size 500 x 300 pixels
XYChart *c = new XYChart(500, 300);
// Set the plotarea at (90, 30) and of size 300 x 240 pixels.
c->setPlotArea(90, 30, 300, 240);
// Add a legend box at (405, 100)
c->addLegend(405, 100);
// Add a title to the chart
c->addTitle("Daily System Load");
// Add a title to the y axis. Draw the title upright (font angle = 0)
c->yAxis()->setTitle("Database\nQueries\n(per sec)")->setFontAngle(0);
// Set the labels on the x axis.
c->xAxis()->setLabels(StringArray(labels, (int)(sizeof(labels) / sizeof(labels[0]))));
// Display 1 out of 2 labels on the x-axis. Show minor ticks for remaining labels.
c->xAxis()->setLabelStep(2, 1);
// Add an area layer
AreaLayer *layer = c->addAreaLayer();
// Draw the area layer in 3D
layer->set3D();
// Add the three data sets to the area layer
layer->addDataSet(DoubleArray(data0, (int)(sizeof(data0) / sizeof(data0[0]))), -1, "Server # 1")
;
layer->addDataSet(DoubleArray(data1, (int)(sizeof(data1) / sizeof(data1[0]))), -1, "Server # 2")
;
layer->addDataSet(DoubleArray(data2, (int)(sizeof(data2) / sizeof(data2[0]))), -1, "Server # 3")
;
// Output the chart
c->makeChart("threedstackarea.png");
//free up resources
delete c;
return 0;
}
开发者ID:BIbiLion,项目名称:LSWuqiankun,代码行数:54,代码来源:threedstackarea.cpp
示例2: main
int main(int argc, char *argv[])
{
// The data for the line chart
double data0[] = {60.2, 51.7, 81.3, 48.6, 56.2, 68.9, 52.8};
double data1[] = {30.0, 32.7, 33.9, 29.5, 32.2, 28.4, 29.8};
const char *labels[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
// Create a XYChart object of size 300 x 180 pixels, with a pale yellow (0xffffc0) background, a
// black border, and 1 pixel 3D border effect.
XYChart *c = new XYChart(300, 180, 0xffffc0, 0x000000, 1);
// Set the plotarea at (45, 35) and of size 240 x 120 pixels, with white background. Turn on
// both horizontal and vertical grid lines with light grey color (0xc0c0c0)
c->setPlotArea(45, 35, 240, 120, 0xffffff, -1, -1, 0xc0c0c0, -1);
// Add a legend box at (45, 12) (top of the chart) using horizontal layout and 8pt Arial font
// Set the background and border color to Transparent.
c->addLegend(45, 12, false, "", 8)->setBackground(Chart::Transparent);
// Add a title to the chart using 9pt Arial Bold/white font. Use a 1 x 2 bitmap pattern as the
// background.
int pattern1[] = {0x004000, 0x008000};
c->addTitle("Server Load (Jun 01 - Jun 07)", "arialbd.ttf", 9, 0xffffff)->setBackground(
c->patternColor(IntArray(pattern1, (int)(sizeof(pattern1) / sizeof(pattern1[0]))), 2));
// Set the y axis label format to nn%
c->yAxis()->setLabelFormat("{value}%");
// Set the labels on the x axis
c->xAxis()->setLabels(StringArray(labels, (int)(sizeof(labels) / sizeof(labels[0]))));
// Add a line layer to the chart
LineLayer *layer = c->addLineLayer();
// Add the first line. Plot the points with a 7 pixel square symbol
layer->addDataSet(DoubleArray(data0, (int)(sizeof(data0) / sizeof(data0[0]))), 0xcf4040, "Peak"
)->setDataSymbol(Chart::SquareSymbol, 7);
// Add the second line. Plot the points with a 9 pixel dismond symbol
layer->addDataSet(DoubleArray(data1, (int)(sizeof(data1) / sizeof(data1[0]))), 0x40cf40,
"Average")->setDataSymbol(Chart::DiamondSymbol, 9);
// Enable data label on the data points. Set the label format to nn%.
layer->setDataLabelFormat("{value|0}%");
// Output the chart
c->makeChart("symbolline.png");
//free up resources
delete c;
return 0;
}
开发者ID:BIbiLion,项目名称:LSWuqiankun,代码行数:52,代码来源:symbolline.cpp
示例3: main
int main(int argc, char *argv[])
{
// The data for the bar chart
double data0[] = {100, 125, 156, 147, 87, 124, 178, 109, 140, 106, 192, 122};
double data1[] = {122, 156, 179, 211, 198, 177, 160, 220, 190, 188, 220, 270};
double data2[] = {167, 190, 213, 267, 250, 320, 212, 199, 245, 267, 240, 310};
const char *labels[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug",
"Sept", "Oct", "Nov", "Dec"};
// Create a XYChart object of size 580 x 280 pixels
XYChart *c = new XYChart(580, 280);
// Add a title to the chart using 14 pts Arial Bold Italic font
c->addTitle("Product Revenue For Last 3 Years", "arialbi.ttf", 14);
// Set the plot area at (50, 50) and of size 500 x 200. Use two alternative
// background colors (f8f8f8 and ffffff)
c->setPlotArea(50, 50, 500, 200, 0xf8f8f8, 0xffffff);
// Add a legend box at (50, 25) using horizontal layout. Use 8pts Arial as font,
// with transparent background.
c->addLegend(50, 25, false, "arial.ttf", 8)->setBackground(Chart::Transparent);
// Set the x axis labels
c->xAxis()->setLabels(StringArray(labels, sizeof(labels)/sizeof(labels[0])));
// Draw the ticks between label positions (instead of at label positions)
c->xAxis()->setTickOffset(0.5);
// Add a multi-bar layer with 3 data sets
BarLayer *layer = c->addBarLayer(Chart::Side);
layer->addDataSet(DoubleArray(data0, sizeof(data0)/sizeof(data0[0])), 0xff8080,
"Year 2003");
layer->addDataSet(DoubleArray(data1, sizeof(data1)/sizeof(data1[0])), 0x80ff80,
"Year 2004");
layer->addDataSet(DoubleArray(data2, sizeof(data2)/sizeof(data2[0])), 0x8080ff,
"Year 2005");
// Set 50% overlap between bars
layer->setOverlapRatio(0.5);
// Add a title to the y-axis
c->yAxis()->setTitle("Revenue (USD in millions)");
// output the chart
c->makeChart("overlapbar.png");
//free up resources
delete c;
return 0;
}
开发者ID:vopl,项目名称:sp,代码行数:51,代码来源:overlapbar.cpp
示例4: main
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QChartViewer viewer;
//
// Draw Chart and set to QChartViewer
//
// The data for the bar chart
double data[] = {85, 156, 179.5, 211, 123};
// The labels for the bar chart
const char *labels[] = {"Mon", "Tue", "Wed", "Thu", "Fri"};
// Create a XYChart object of size 250 x 250 pixels
XYChart *c = new XYChart(250, 250);
// Set the plotarea at (30, 20) and of size 200 x 200 pixels
c->setPlotArea(30, 20, 200, 200);
// Add a bar chart layer using the given data
c->addBarLayer(DoubleArray(data, sizeof(data)/sizeof(data[0])));
// Set the labels on the x axis.
c->xAxis()->setLabels(StringArray(labels, sizeof(labels)/sizeof(labels[0])));
// Output the chart
viewer.setChart(c);
// Include tool tip for the chart
viewer.setImageMap(
c->getHTMLImageMap("", "", "title='{xLabel}: US${value}K'"));
// In this sample project, we do not need to chart object any more, so we
// delete it now.
delete c;
//
// Show the viewer
//
viewer.show();
return app.exec();
}
开发者ID:BIbiLion,项目名称:LSWuqiankun,代码行数:45,代码来源:helloworld.cpp
示例5: main
int main(int argc, char *argv[])
{
// The XY points for the scatter chart
double dataX[] = {200, 400, 300, 250, 500};
double dataY[] = {40, 100, 50, 150, 250};
// The custom symbols for the points
const char *symbols[] = {"robot1.png", "robot2.png", "robot3.png", "robot4.png",
"robot5.png"};
// Create a XYChart object of size 450 x 400 pixels
XYChart *c = new XYChart(450, 400);
// Set the plotarea at (55, 40) and of size 350 x 300 pixels, with a light grey
// border (0xc0c0c0). Turn on both horizontal and vertical grid lines with light
// grey color (0xc0c0c0)
c->setPlotArea(55, 40, 350, 300, -1, -1, 0xc0c0c0, 0xc0c0c0, -1);
// Add a title to the chart using 18 pts Times Bold Itatic font.
c->addTitle("Battle Robots", "timesbi.ttf", 18);
// Add a title to the y axis using 12 pts Arial Bold Italic font
c->yAxis()->setTitle("Speed (km/s)", "arialbi.ttf", 12);
// Add a title to the y axis using 12 pts Arial Bold Italic font
c->xAxis()->setTitle("Range (km)", "arialbi.ttf", 12);
// Set the axes line width to 3 pixels
c->xAxis()->setWidth(3);
c->yAxis()->setWidth(3);
// Add each point of the data as a separate scatter layer, so that they can have
// a different symbol
int i;
for(i = 0; i < sizeof(dataX) / sizeof(dataX[0]); ++i) {
double coor1[] = {dataX[i]};
double coor2[] = {dataY[i]};
c->addScatterLayer(DoubleArray(coor1, sizeof(coor1)/sizeof(coor1[0])),
DoubleArray(coor2, sizeof(coor2)/sizeof(coor2[0])))->getDataSet(0
)->setDataSymbol(symbols[i]);
}
// Output the chart
c->makeChart("scattersymbols.png");
//free up resources
delete c;
return 0;
}
开发者ID:BunnyWei,项目名称:Anthropometric-Data-Analysis-Software,代码行数:49,代码来源:scattersymbols.cpp
示例6: main
int main(int argc, char *argv[])
{
// The data for the bar chart
double data0[] = {100, 125, 245, 147, 67};
double data1[] = {85, 156, 179, 211, 123};
double data2[] = {97, 87, 56, 267, 157};
const char *labels[] = {"Mon", "Tue", "Wed", "Thu", "Fri"};
// Create a XYChart object of size 400 x 240 pixels
XYChart *c = new XYChart(400, 240);
// Add a title to the chart using 10 pt Arial font
c->addTitle(" Average Weekday Network Load", "", 10);
// Set the plot area at (50, 25) and of size 320 x 180. Use two alternative
// background colors (0xffffc0 and 0xffffe0)
c->setPlotArea(50, 25, 320, 180, 0xffffc0, 0xffffe0);
// Add a legend box at (55, 18) using horizontal layout. Use 8 pt Arial font,
// with transparent background
c->addLegend(55, 18, false, "", 8)->setBackground(Chart::Transparent);
// Add a title to the y-axis
c->yAxis()->setTitle("Throughput (MBytes Per Hour)");
// Reserve 20 pixels at the top of the y-axis for the legend box
c->yAxis()->setTopMargin(20);
// Set the x axis labels
c->xAxis()->setLabels(StringArray(labels, sizeof(labels)/sizeof(labels[0])));
// Add a multi-bar layer with 3 data sets and 3 pixels 3D depth
BarLayer *layer = c->addBarLayer(Chart::Side, 3);
layer->addDataSet(DoubleArray(data0, sizeof(data0)/sizeof(data0[0])), 0xff8080,
"Server #1");
layer->addDataSet(DoubleArray(data1, sizeof(data1)/sizeof(data1[0])), 0x80ff80,
"Server #2");
layer->addDataSet(DoubleArray(data2, sizeof(data2)/sizeof(data2[0])), 0x8080ff,
"Server #3");
// output the chart
c->makeChart("multibar.png");
//free up resources
delete c;
return 0;
}
开发者ID:vopl,项目名称:sp,代码行数:47,代码来源:multibar.cpp
示例7: main
int main(int argc, char *argv[])
{
// The data for the line chart
double data[] = {30, 28, 40, 55, 75, 68, 54, 60, 50, 62, 75, 65, 75, 91, 60, 55,
53, 35, 50, 66, 56, 48, 52, 65, 62};
// The labels for the line chart
const char *labels[] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10",
"11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23",
"24"};
// Create a XYChart object of size 250 x 250 pixels
XYChart *c = new XYChart(250, 250);
// Set the plotarea at (30, 20) and of size 200 x 200 pixels
c->setPlotArea(30, 20, 200, 200);
// Add a line chart layer using the given data
c->addLineLayer(DoubleArray(data, sizeof(data)/sizeof(data[0])));
// Set the labels on the x axis.
c->xAxis()->setLabels(StringArray(labels, sizeof(labels)/sizeof(labels[0])));
// Display 1 out of 3 labels on the x-axis.
c->xAxis()->setLabelStep(3);
// output the chart
c->makeChart("simpleline.png");
//free up resources
delete c;
return 0;
}
开发者ID:vopl,项目名称:sp,代码行数:33,代码来源:simpleline.cpp
示例8: main
int main(int argc, char *argv[])
{
// The data for the area chart
double data[] = {30, 28, 40, 55, 75, 68, 54, 60, 50, 62, 75, 65, 75, 89, 60, 55,
53, 35, 50, 66, 56, 48, 52, 65, 62};
// The labels for the area chart
const char *labels[] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10",
"11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23",
"24"};
// Create a XYChart object of size 300 x 300 pixels
XYChart *c = new XYChart(300, 300);
// Set the plotarea at (45, 30) and of size 200 x 200 pixels
c->setPlotArea(45, 30, 200, 200);
// Add a title to the chart using 12 pts Arial Bold Italic font
c->addTitle("Daily Server Utilization", "arialbi.ttf", 12);
// Add a title to the y axis
c->yAxis()->setTitle("MBytes");
// Add a title to the x axis
c->xAxis()->setTitle("June 12, 2001");
// Add a green (0x00ff00) 3D area chart layer using the give data
c->addAreaLayer(DoubleArray(data, sizeof(data)/sizeof(data[0])), 0x00ff00
)->set3D();
// Set the labels on the x axis.
c->xAxis()->setLabels(StringArray(labels, sizeof(labels)/sizeof(labels[0])));
// Display 1 out of 3 labels on the x-axis.
c->xAxis()->setLabelStep(3);
// Output the chart
c->makeChart("threedarea.png");
//free up resources
delete c;
return 0;
}
开发者ID:BunnyWei,项目名称:Anthropometric-Data-Analysis-Software,代码行数:43,代码来源:threedarea.cpp
示例9: main
int main(int argc, char *argv[])
{
// The data for the area chart
double data[] = {30, 28, 40, 55, 75, 68, 54, 60, 50, 62, 75, 65, 75, 89, 60, 55, 53, 35, 50, 66,
56, 48, 52, 65, 62};
// The labels for the area chart
double labels[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
22, 23, 24};
// Create a XYChart object of size 320 x 320 pixels
XYChart *c = new XYChart(320, 320);
// Swap the x and y axis to become a rotated chart
c->swapXY();
// Set the y axis on the top side (right + rotated = top)
c->setYAxisOnRight();
// Reverse the x axis so it is pointing downwards
c->xAxis()->setReverse();
// Set the plotarea at (50, 50) and of size 200 x 200 pixels. Enable horizontal and vertical
// grids by setting their colors to grey (0xc0c0c0).
c->setPlotArea(50, 50, 250, 250)->setGridColor(0xc0c0c0, 0xc0c0c0);
// Add a line chart layer using the given data
c->addAreaLayer(DoubleArray(data, (int)(sizeof(data) / sizeof(data[0]))), c->gradientColor(50,
0, 300, 0, 0xffffff, 0x0000ff));
// Set the labels on the x axis. Append "m" after the value to show the unit.
c->xAxis()->setLabels(DoubleArray(labels, (int)(sizeof(labels) / sizeof(labels[0]))),
"{value} m");
// Display 1 out of 3 labels.
c->xAxis()->setLabelStep(3);
// Add a title to the x axis
c->xAxis()->setTitle("Depth");
// Add a title to the y axis
c->yAxis()->setTitle("Carbon Dioxide Concentration (ppm)");
// Output the chart
c->makeChart("rotatedarea.png");
//free up resources
delete c;
return 0;
}
开发者ID:BIbiLion,项目名称:LSWuqiankun,代码行数:50,代码来源:rotatedarea.cpp
示例10: main
int main(int argc, char *argv[])
{
// the names of the tasks
const char *labels[] = {"Market Research", "Define Specifications",
"Overall Archiecture", "Project Planning", "Detail Design",
"Software Development", "Test Plan", "Testing and QA", "User Documentation"};
// the planned start dates and end dates for the tasks
double startDate[] = {chartTime(2004, 8, 16), chartTime(2004, 8, 30), chartTime(
2004, 9, 13), chartTime(2004, 9, 20), chartTime(2004, 9, 27), chartTime(2004,
10, 4), chartTime(2004, 10, 25), chartTime(2004, 11, 1), chartTime(2004, 11,
8)};
double endDate[] = {chartTime(2004, 8, 30), chartTime(2004, 9, 13), chartTime(
2004, 9, 27), chartTime(2004, 10, 4), chartTime(2004, 10, 11), chartTime(
2004, 11, 8), chartTime(2004, 11, 8), chartTime(2004, 11, 22), chartTime(
2004, 11, 22)};
// the actual start dates and end dates for the tasks up to now
double actualStartDate[] = {chartTime(2004, 8, 16), chartTime(2004, 8, 27),
chartTime(2004, 9, 9), chartTime(2004, 9, 18), chartTime(2004, 9, 22)};
double actualEndDate[] = {chartTime(2004, 8, 27), chartTime(2004, 9, 9),
chartTime(2004, 9, 27), chartTime(2004, 10, 2), chartTime(2004, 10, 8)};
// Create a XYChart object of size 620 x 280 pixels. Set background color to
// light green (ccffcc) with 1 pixel 3D border effect.
XYChart *c = new XYChart(620, 280, 0xccffcc, 0x000000, 1);
// Add a title to the chart using 15 points Times Bold Itatic font, with white
// (ffffff) text on a dark green (0x6000) background
c->addTitle("Mutli-Layer Gantt Chart Demo", "timesbi.ttf", 15, 0xffffff
)->setBackground(0x006000);
// Set the plotarea at (140, 55) and of size 460 x 200 pixels. Use alternative
// white/grey background. Enable both horizontal and vertical grids by setting
// their colors to grey (c0c0c0). Set vertical major grid (represents month
// boundaries) 2 pixels in width
c->setPlotArea(140, 55, 460, 200, 0xffffff, 0xeeeeee, Chart::LineColor, 0xc0c0c0,
0xc0c0c0)->setGridWidth(2, 1, 1, 1);
// swap the x and y axes to create a horziontal box-whisker chart
c->swapXY();
// Set the y-axis scale to be date scale from Aug 16, 2004 to Nov 22, 2004, with
// ticks every 7 days (1 week)
c->yAxis()->setDateScale(chartTime(2004, 8, 16), chartTime(2004, 11, 22), 86400 *
7);
// Add a red (ff0000) dash line to represent the current day
c->yAxis()->addMark(chartTime(2004, 10, 8), c->dashLineColor(0xff0000,
Chart::DashLine));
// Set multi-style axis label formatting. Month labels are in Arial Bold font in
// "mmm d" format. Weekly labels just show the day of month and use minor tick
// (by using '-' as first character of format string).
c->yAxis()->setMultiFormat(Chart::StartOfMonthFilter(),
"<*font=arialbd.ttf*>{value|mmm d}", Chart::StartOfDayFilter(), "-{value|d}")
;
// Set the y-axis to shown on the top (right + swapXY = top)
c->setYAxisOnRight();
// Set the labels on the x axis
c->xAxis()->setLabels(StringArray(labels, sizeof(labels)/sizeof(labels[0])));
// Reverse the x-axis scale so that it points downwards.
c->xAxis()->setReverse();
// Set the horizontal ticks and grid lines to be between the bars
c->xAxis()->setTickOffset(0.5);
// Use blue (0000aa) as the color for the planned schedule
int plannedColor = 0x0000aa;
// Use a red hash pattern as the color for the actual dates. The pattern is
// created as a 4 x 4 bitmap defined in memory as an array of colors.
int pattern1[] = {0xffffff, 0xffffff, 0xffffff, 0xff0000, 0xffffff, 0xffffff,
0xff0000, 0xffffff, 0xffffff, 0xff0000, 0xffffff, 0xffffff, 0xff0000,
0xffffff, 0xffffff, 0xffffff};
int actualColor = c->patternColor(IntArray(pattern1,
sizeof(pattern1)/sizeof(pattern1[0])), 4);
// Add a box whisker layer to represent the actual dates. We add the actual dates
// layer first, so it will be the top layer.
BoxWhiskerLayer *actualLayer = c->addBoxLayer(DoubleArray(actualStartDate,
sizeof(actualStartDate)/sizeof(actualStartDate[0])), DoubleArray(
actualEndDate, sizeof(actualEndDate)/sizeof(actualEndDate[0])), actualColor,
"Actual");
// Set the bar height to 8 pixels so they will not block the bottom bar
actualLayer->setDataWidth(8);
// Add a box-whisker layer to represent the planned schedule date
c->addBoxLayer(DoubleArray(startDate, sizeof(startDate)/sizeof(startDate[0])),
DoubleArray(endDate, sizeof(endDate)/sizeof(endDate[0])), plannedColor,
"Planned")->setBorderColor(Chart::SameAsMainColor);
// Add a legend box on the top right corner (595, 60) of the plot area with 8 pt
// Arial Bold font. Use a semi-transparent grey (80808080) background.
LegendBox *b = c->addLegend(595, 60, false, "arialbd.ttf", 8);
b->setAlignment(Chart::TopRight);
//.........这里部分代码省略.........
开发者ID:vopl,项目名称:sp,代码行数:101,代码来源:layergantt.cpp
示例11: r
//
// Draw the chart and display it in the given viewer
//
void TrackAxis::drawChart(QChartViewer *viewer)
{
// Data for the chart as 2 random data series
RanSeries r(127);
DoubleArray data0 = r.getSeries(180, 10, -1.5, 1.5);
DoubleArray data1 = r.getSeries(180, 150, -15, 15);
DoubleArray timeStamps = r.getDateSeries(180, Chart::chartTime(2011, 1, 1), 86400);
// Create a XYChart object of size 670 x 400 pixels
XYChart *c = new XYChart(670, 400);
// Add a title to the chart using 18 pts Times New Roman Bold Italic font
c->addTitle("Plasma Stabilizer Energy Usage", "timesbi.ttf", 18);
// Set the plotarea at (50, 55) with width 100 pixels less than chart width, and height 90 pixels
// less than chart height. Use a vertical gradient from light blue (f0f6ff) to sky blue (a0c0ff)
// as background. Set border to transparent and grid lines to white (ffffff).
c->setPlotArea(50, 55, c->getWidth() - 100, c->getHeight() - 90, c->linearGradientColor(0, 55, 0,
c->getHeight() - 35, 0xf0f6ff, 0xa0c0ff), -1, Chart::Transparent, 0xffffff, 0xffffff);
// Add a legend box at (50, 25) using horizontal layout. Use 10pts Arial Bold as font. Set the
// background and border color to Transparent.
c->addLegend(50, 25, false, "arialbd.ttf", 10)->setBackground(Chart::Transparent);
// Set axis label style to 8pts Arial Bold
c->xAxis()->setLabelStyle("arialbd.ttf", 8);
c->yAxis()->setLabelStyle("arialbd.ttf", 8);
c->yAxis2()->setLabelStyle("arialbd.ttf", 8);
// Set the axis stem to transparent
c->xAxis()->setColors(Chart::Transparent);
c->yAxis()->setColors(Chart::Transparent);
c->yAxis2()->setColors(Chart::Transparent);
// Configure x-axis label format
c->xAxis()->setMultiFormat(Chart::StartOfYearFilter(), "{value|mm/yyyy} ",
Chart::StartOfMonthFilter(), "{value|mm}");
// Add axis title using 10pts Arial Bold Italic font
c->yAxis()->setTitle("Power Usage (Watt)", "arialbi.ttf", 10);
c->yAxis2()->setTitle("Effective Load (kg)", "arialbi.ttf", 10);
// Add a line layer to the chart using a line width of 2 pixels.
LineLayer *layer = c->addLineLayer();
layer->setLineWidth(2);
// Add 2 data series to the line layer
layer->setXData(timeStamps);
layer->addDataSet(data0, 0xcc0000, "Power Usage");
layer->addDataSet(data1, 0x008800, "Effective Load")->setUseYAxis2();
// Set the chart image to the QChartViewer
viewer->setChart(c);
}
开发者ID:BIbiLion,项目名称:LSWuqiankun,代码行数:57,代码来源:trackaxis.cpp
示例12: XYChart
//
// Draw chart
//
void RealtimeChart::drawChart()
{
// Create an XYChart object 600 x 270 pixels in size, with light white (ffffff)
// background, white (000000) border, no raised effect, and with a rounded frame.
XYChart *c = new XYChart(645, 270, 0xffffff, 0xffffff, 0);
QColor bgColor = palette().color(backgroundRole()).rgb();
//c->setRoundedFrame((bgColor.red() << 16) + (bgColor.green() << 8) + bgColor.blue());
// Set the plotarea at (55, 62) and of size 520 x 175 pixels. Use white (ffffff)
// background. Enable both horizontal and vertical grids by setting their colors to
// grey (cccccc). Set clipping mode to clip the data lines to the plot area.
c->setPlotArea(55, 62, 580, 185, 0xffffff, -1, -1, 0xcccccc, 0xcccccc);
c->setClipping();
// Add a title to the chart using 15 pts Times New Roman Bold Italic font, with a light
// grey (dddddd) background, black (000000) border, and a glass like raised effect.
c->addTitle(m_mainTitle, "arialbd.ttf", 15);
// Add a legend box at the top of the plot area with 9pts Arial Bold font. We set the
// legend box to the same width as the plot area and use grid layout (as opposed to
// flow or top/down layout). This distributes the 3 legend icons evenly on top of the
// plot area.
LegendBox *b = c->addLegend2(55, 33, 3, "arialbd.ttf", 9);
b->setBackground(Chart::Transparent, Chart::Transparent);
b->setWidth(580);
// Configure the y-axis with a 10pts Arial Bold axis title
c->yAxis()->setTitle(m_yTitle, "arialbd.ttf", 10);
// Configure the x-axis to auto-scale with at least 75 pixels between major tick and
// 15 pixels between minor ticks. This shows more minor grid lines on the chart.
c->xAxis()->setTickDensity(75, 15);
// Set the axes width to 2 pixels
c->xAxis()->setWidth(2);
c->yAxis()->setWidth(2);
// Now we add the data to the chart.
double lastTime = m_timeStamps[sampleSize - 1];
if (lastTime != Chart::NoValue)
{
// Set up the x-axis to show the time range in the data buffer
c->xAxis()->setDateScale(lastTime - DataInterval * sampleSize / 1000, lastTime);
// Set the x-axis label format
c->xAxis()->setLabelFormat("{value|hh:nn:ss}");
// Create a line layer to plot the lines
LineLayer *layer = c->addLineLayer();
// The x-coordinates are the timeStamps.
layer->setXData(DoubleArray(m_timeStamps, sampleSize));
// The 3 data series are used to draw 3 lines. Here we put the latest data values
// as part of the data set name, so you can see them updated in the legend box.
char buffer[1024];
sprintf(buffer, "%s: <*bgColor=FFCCCC*> %.2f ", m_labelA, m_dataSeriesA[sampleSize - 1]);
layer->addDataSet(DoubleArray(m_dataSeriesA, sampleSize), 0xff0000, buffer);
sprintf(buffer, "%s: <*bgColor=CCFFCC*> %.2f ", m_labelB, m_dataSeriesB[sampleSize - 1]);
layer->addDataSet(DoubleArray(m_dataSeriesB, sampleSize), 0x00cc00, buffer);
}
// Set the chart image to the WinChartViewer
m_ChartViewer->setChart(c);
delete c;
}
开发者ID:aquarius20th,项目名称:QTrojanAssessment,代码行数:71,代码来源:realtimechart.cpp
示例13: main
int main(int argc, char *argv[])
{
// The tasks for the gantt chart
const char *labels[] = {"Market Research", "Define Specifications",
"Overall Archiecture", "Project Planning", "Detail Design",
"Software Development", "Test Plan", "Testing and QA", "User Documentation"};
// The task index, start date, end date and color for each bar
double taskNo[] = {0, 0, 1, 2, 3, 4, 5, 6, 6, 7, 8, 8};
double startDate[] = {chartTime(2004, 8, 16), chartTime(2004, 10, 4), chartTime(
2004, 8, 30), chartTime(2004, 9, 13), chartTime(2004, 9, 20), chartTime(2004,
9, 27), chartTime(2004, 10, 4), chartTime(2004, 10, 4), chartTime(2004, 10,
25), chartTime(2004, 11, 1), chartTime(2004, 10, 18), chartTime(2004, 11, 8)}
;
double endDate[] = {chartTime(2004, 8, 30), chartTime(2004, 10, 18), chartTime(
2004, 9, 13), chartTime(2004, 9, 27), chartTime(2004, 10, 4), chartTime(2004,
10, 11), chartTime(2004, 11, 8), chartTime(2004, 10, 18), chartTime(2004, 11,
8), chartTime(2004, 11, 22), chartTime(2004, 11, 1), chartTime(2004, 11, 22)}
;
int colors[] = {0x00cc00, 0x00cc00, 0x00cc00, 0x0000cc, 0x0000cc, 0xcc0000,
0xcc0000, 0x0000cc, 0xcc0000, 0xcc0000, 0x00cc00, 0xcc0000};
// Create a XYChart object of size 620 x 325 pixels. Set background color to
// light red (0xffcccc), with 1 pixel 3D border effect.
XYChart *c = new XYChart(620, 325, 0xffcccc, 0x000000, 1);
// Add a title to the chart using 15 points Times Bold Itatic font, with white
// (ffffff) text on a dark red (800000) background
c->addTitle("Mutli-Color Gantt Chart Demo", "timesbi.ttf", 15, 0xffffff
)->setBackground(0x800000);
// Set the plotarea at (140, 55) and of size 460 x 200 pixels. Use alternative
// white/grey background. Enable both horizontal and vertical grids by setting
// their colors to grey (c0c0c0). Set vertical major grid (represents month
// boundaries) 2 pixels in width
c->setPlotArea(140, 55, 460, 200, 0xffffff, 0xeeeeee, Chart::LineColor, 0xc0c0c0,
0xc0c0c0)->setGridWidth(2, 1, 1, 1);
// swap the x and y axes to create a horziontal box-whisker chart
c->swapXY();
// Set the y-axis scale to be date scale from Aug 16, 2004 to Nov 22, 2004, with
// ticks every 7 days (1 week)
c->yAxis()->setDateScale(chartTime(2004, 8, 16), chartTime(2004, 11, 22), 86400 *
7);
// Set multi-style axis label formatting. Month labels are in Arial Bold font in
// "mmm d" format. Weekly labels just show the day of month and use minor tick
// (by using '-' as first character of format string).
c->yAxis()->setMultiFormat(Chart::StartOfMonthFilter(),
"<*font=arialbd.ttf*>{value|mmm d}", Chart::StartOfDayFilter(), "-{value|d}")
;
// Set the y-axis to shown on the top (right + swapXY = top)
c->setYAxisOnRight();
// Set the labels on the x axis
c->xAxis()->setLabels(StringArray(labels, sizeof(labels)/sizeof(labels[0])));
// Reverse the x-axis scale so that it points downwards.
c->xAxis()->setReverse();
// Set the horizontal ticks and grid lines to be between the bars
c->xAxis()->setTickOffset(0.5);
// Add some symbols to the chart to represent milestones. The symbols are added
// using scatter layers. We need to specify the task index, date, name, symbol
// shape, size and color.
double coor1[] = {1};
double date1[] = {chartTime(2004, 9, 13)};
c->addScatterLayer(DoubleArray(coor1, sizeof(coor1)/sizeof(coor1[0])),
DoubleArray(date1, sizeof(date1)/sizeof(date1[0])), "Milestone 1",
Chart::Cross2Shape(), 13, 0xffff00);
double coor2[] = {3};
double date2[] = {chartTime(2004, 10, 4)};
c->addScatterLayer(DoubleArray(coor2, sizeof(coor2)/sizeof(coor2[0])),
DoubleArray(date2, sizeof(date2)/sizeof(date2[0])), "Milestone 2",
Chart::StarShape(5), 15, 0xff00ff);
double coor3[] = {5};
double date3[] = {chartTime(2004, 11, 8)};
c->addScatterLayer(DoubleArray(coor3, sizeof(coor3)/sizeof(coor3[0])),
DoubleArray(date3, sizeof(date3)/sizeof(date3[0])), "Milestone 3",
Chart::TriangleSymbol, 13, 0xff9933);
// Add a multi-color box-whisker layer to represent the gantt bars
BoxWhiskerLayer *layer = c->addBoxWhiskerLayer2(DoubleArray(startDate,
sizeof(startDate)/sizeof(startDate[0])), DoubleArray(endDate,
sizeof(endDate)/sizeof(endDate[0])), DoubleArray(), DoubleArray(),
DoubleArray(), IntArray(colors, sizeof(colors)/sizeof(colors[0])));
layer->setXData(DoubleArray(taskNo, sizeof(taskNo)/sizeof(taskNo[0])));
layer->setBorderColor(Chart::SameAsMainColor);
// Divide the plot area height ( = 200 in this chart) by the number of tasks to
// get the height of each slot. Use 80% of that as the bar height.
layer->setDataWidth(200 * 4 / 5 / (sizeof(labels) / sizeof(labels[0])));
// Add a legend box at (140, 265) - bottom of the plot area. Use 8 pts Arial Bold
// as the font with auto-grid layout. Set the width to the same width as the plot
// area. Set the backgorund to grey (dddddd).
LegendBox *legendBox = c->addLegend2(140, 265, Chart::AutoGrid, "arialbd.ttf", 8)
//.........这里部分代码省略.........
开发者ID:BunnyWei,项目名称:Anthropometric-Data-Analysis-Software,代码行数:101,代码来源:colorgantt.cpp
示例14: main
int main(int argc, char *argv[])
{
// The XYZ points for the bubble chart
double dataX0[] = {150, 300, 1000, 1700};
double dataY0[] = {12, 60, 25, 65};
double dataZ0[] = {20, 50, 50, 85};
double dataX1[] = {500, 1000, 1300};
double dataY1[] = {35, 50, 75};
double dataZ1[] = {30, 55, 95};
// Create a XYChart object of size 450 x 420 pixels
XYChart *c = new XYChart(450, 420);
// Set the plotarea at (55, 65) and of size 350 x 300 pixels, with a light grey
// border (0xc0c0c0). Turn on both horizontal and vertical grid lines with light
// grey color (0xc0c0c0)
c->setPlotArea(55, 65, 350, 300, -1, -1, 0xc0c0c0, 0xc0c0c0, -1);
// Add a legend box at (50, 30) (top of the chart) with horizontal layout. Use 12
// pts Times Bold Italic font. Set the background and border color to
// Transparent.
c->addLegend(50, 30, false, "timesbi.ttf", 12)->setBackground(Chart::Transparent)
;
// Add a title to the chart using 18 pts Times Bold Itatic font.
c->addTitle("Product Comparison Chart", "timesbi.ttf", 18);
// Add a title to the y axis using 12 pts Arial Bold Italic font
c->yAxis()->setTitle("Capacity (tons)", "arialbi.ttf", 12);
// Add a title to the x axis using 12 pts Arial Bold Italic font
c->xAxis()->setTitle("Range (miles)", "arialbi.ttf", 12);
// Set the axes line width to 3 pixels
c->xAxis()->setWidth(3);
c->yAxis()->setWidth(3);
// Add (dataX0, dataY0) as a scatter layer with semi-transparent red (0x80ff3333)
// circle symbols, where the circle size is modulated by dataZ0. This creates a
// bubble effect.
c->addScatterLayer(DoubleArray(dataX0, sizeof(dataX0)/sizeof(dataX0[0])),
DoubleArray(dataY0, sizeof(dataY0)/sizeof(dataY0[0])), "Technology AAA",
Chart::CircleSymbol, 9, 0x80ff3333, 0x80ff3333)->setSymbolScale(DoubleArray(
dataZ0, sizeof(dataZ0)/sizeof(dataZ0[0])));
// Add (dataX1, dataY1) as a scatter layer with semi-transparent green
// (0x803333ff) circle symbols, where the circle size is modulated by dataZ1.
// This creates a bubble effect.
c->addScatterLayer(DoubleArray(dataX1, sizeof(dataX1)/sizeof(dataX1[0])),
DoubleArray(dataY1, sizeof(dataY1)/sizeof(dataY1[0])), "Technology BBB",
Chart::CircleSymbol, 9, 0x803333ff, 0x803333ff)->setSymbolScale(DoubleArray(
dataZ1, sizeof(dataZ1)/sizeof(dataZ1[0])));
// Output the chart
c->makeChart("bubble.png");
//free up resources
delete c;
return 0;
}
开发者ID:BunnyWei,项目名称:Anthropometric-Data-Analysis-Software,代码行数:61,代码来源:bubble.cpp
示例15: main
int main(int argc, char *argv[])
{
// The data for the area chart
double data0[] = {42, 49, 33, 38, 51, 46, 29, 41, 44, 57, 59, 52, 37, 34, 51, 56,
56, 60, 70, 76, 63, 67, 75, 64, 51};
double data1[] = {50, 55, 47, 34, 42, 49, 63, 62, 73, 59, 56, 50, 64, 60, 67, 67,
58, 59, 73, 77, 84, 82, 80, 84, 98};
double data2[] = {87, 89, 85, 66, 53, 39, 24, 21, 37, 56, 37, 23, 21, 33, 13, 17,
14, 23, 16, 25, 29, 30, 45, 47, 46};
// The timestamps on the x-axis
double labels[] = {chartTime(1996, 1, 1), chartTime(1996, 4, 1), chartTime(1996,
7, 1), chartTime(1996, 10, 1), chartTime(1997, 1, 1), chartTime(1997, 4, 1),
chartTime(1997, 7, 1), chartTime(1997, 10, 1), chartTime(1998, 1, 1),
chartTime(1998, 4, 1), chartTime(1998, 7, 1), chartTime(1998, 10, 1),
chartTime(1999, 1, 1), chartTime(1999, 4, 1), chartTime(1999, 7, 1),
chartTime(1999, 10, 1), chartTime(2000, 1, 1), chartTime(2000, 4, 1),
chartTime(2000, 7, 1), chartTime(2000, 10, 1), chartTime(2001, 1, 1),
chartTime(2001, 4, 1), chartTime(2001, 7, 1), chartTime(2001, 10, 1),
chartTime(2002, 1, 1)};
// Create a XYChart object of size 500 x 280 pixels, using 0xffffcc as background
// color, with a black border, and 1 pixel 3D border effect
XYChart *c = new XYChart(500, 280, 0xffffcc, 0, 1);
// Set the plotarea at (50, 45) and of size 320 x 200 pixels with white
// background. Enable horizontal and vertical grid lines using the grey
// (0xc0c0c0) color.
c->setPlotArea(50, 45, 320, 200, 0xffffff)->setGridColor(0xc0c0c0, 0xc0c0c0);
// Add a legend box at (370, 45) using vertical layout and 8 points Arial Bold
// font.
LegendBox *legendBox = c->addLegend(370, 45, true, "arialbd.ttf", 8);
// Set the legend box background and border to transparent
legendBox->setBackground(Chart::Transparent, Chart::Transparent);
// Set the legend box icon size to 16 x 32 pixels to match with custom icon size
legendBox->setKeySize(16, 32);
// Add a title to the chart using 14 points Times Bold Itatic font and white font
// color, and 0x804020 as the background color
c->addTitle("Quarterly Product Sales", "timesbi.ttf", 14, 0xffffff
)->setBackground(0x804020);
// Set the labels on the x axis.
c->xAxis()->setLabels(DoubleArray(labels, sizeof(labels)/sizeof(labels[0])));
// Set multi-style axis label formatting. Start of year labels are displayed as
// yyyy. For other labels, just show minor tick.
c->xAxis()->setMultiFormat(Chart::StartOfYearFilter(), "{value|yyyy}",
Chart::AllPassFilter(), "-");
// Add a percentage area layer to the chart
AreaLayer *layer = c->addAreaLayer(Chart::Percentage);
// Add the three data sets to the area layer, using icons images with labels as
// data set names
layer->addDataSet(DoubleArray(data0, sizeof(data0)/sizeof(data0[0])), 0x40ddaa77,
"<*block,valign=absmiddle*><*img=service.png*> Service<*/*>");
layer->addDataSet(DoubleArray(data1, sizeof(data1)/sizeof(data1[0])), 0x40aadd77,
"<*block,valign=absmiddle*><*img=software.png*> Software<*/*>");
layer->addDataSet(DoubleArray(data2, sizeof(data2)/sizeof(data2[0])), 0x40aa77dd,
"<*block,valign=absmiddle*><*img=computer.png*> Hardware<*/*>");
// For a vertical stacked chart with positive data only, the last data set is
// always on top. However, in a vertical legend box, the last data set is at the
// bottom. This can be reversed by using the setLegend method.
layer->setLegend(Chart::ReverseLegend);
// Output the chart
c->makeChart("percentarea.png");
//free up resources
delete c;
return 0;
}
开发者ID:BunnyWei,项目名称:Anthropometric-Data-Analysis-Software,代码行数:77,代码来源:percentarea.cpp
示例16: main
int main(int argc, char *argv[])
{
// The data for the area chart
double data[] = {3.0, 2.8, 4.0, 5.5, 7.5, 6.8, 5.4, 6.0, 5.0, 6.2, 7.5, 6.5, 7.5,
8.1, 6.0, 5.5, 5.3, 3.5, 5.0, 6.6, 5.6, 4.8, 5.2, 6.5, 6.2};
// The labels for the area chart
const char *labels[] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10",
"11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23",
"24"};
// Create a XYChart object of size 300 x 180 pixels. Set the background to pale
// yellow (0xffffa0) with a black border (0x0)
XYChart *c = new XYChart(300, 180, 0xffffa0, 0x000000);
// Set the plotarea at (45, 35) and of size 240 x 120 pixels. Set the background
// to white (0xffffff). Set both horizontal and vertical grid lines to black
// (&H0&) dotted lines (pattern code 0x0103)
c->setPlotArea(45, 35, 240, 120, 0xffffff, -1, -1, c->dashLineColor(0x000000,
0x000103), c->dashLineColor(0x000000, 0x000103));
// Add a title to the chart using 10 pts Arial Bold font. Use a 1 x 2 bitmap
// pattern as the background. Set the border to black (0x0).
|
请发表评论