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; }
void GraphWidget::drawChart() { XYChart *c = new XYChart(size.width(), size.height() - 100, Chart::Transparent); c->setPlotArea(10, 50, c->getWidth() - 65, c->getHeight() - 10, 0x000000, -1, 0xC8C8C8, Chart::Transparent, Chart::Transparent); c->setClipping(); c->getLegend()->setLineStyleKey(); c->getLegend()->setFontSize(10); //遍历查询结果并绘制结果 int ea_result_count = ea_results.size(); //设置X轴的label for(int i = 0;i < ea_result_count;i++){ ExchangeRateResult *ea_result = ea_results[i]; DoubleArray x_data = getXData(i); DoubleArray y_data = ea_result->getYData(); double viewPortStartDate = m_ChartViewer->getValueAtViewPort("x", m_ChartViewer->getViewPortLeft()); double viewPortEndDate = m_ChartViewer->getValueAtViewPort("x", m_ChartViewer->getViewPortLeft() + m_ChartViewer->getViewPortWidth()); int startIndex = (int)floor(Chart::bSearch(x_data, viewPortStartDate)); int endIndex = (int)ceil(Chart::bSearch(x_data, viewPortEndDate)); int noOfPoints = endIndex - startIndex + 1; DoubleArray viewPortXData = DoubleArray(x_data.data + startIndex, noOfPoints); DoubleArray viewPortYData = DoubleArray(y_data.data + startIndex, noOfPoints); //添加图层 LineLayer *layer = c->addLineLayer(); layer->setLineWidth(1); //设置X轴 layer->setXData(viewPortXData); //设置Y轴 layer->addDataSet(viewPortYData, ea_result->getColor(), ea_result->getName().toUtf8().data())->setUseYAxis2(); } c->xAxis()->setLabelStyle("arial.ttf", 10); c->yAxis2()->setLabelStyle("arial.ttf", 10); c->xAxis()->setColors(0xC8C8C8, 0xC8C8C8); c->yAxis2()->setColors(0xC8C8C8, 0xC8C8C8); m_ChartViewer->syncDateAxisWithViewPort("x", c->xAxis()); c->yAxis()->setTickDensity(30); c->yAxis2()->setTickDensity(30); if (!m_ChartViewer->isInMouseMoveEvent()) { trackLineLegend(c, (0 == m_ChartViewer->getChart()) ? c->getPlotArea()->getRightX() : m_ChartViewer->getPlotAreaMouseX()); } delete m_ChartViewer->getChart(); m_ChartViewer->setChart(c); }
// // 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); }
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; }
void GraphWidget::drawFullChart(){ nameList.clear(); initChartViewer(); XYChart *c = new XYChart(size.width(), 100, Chart::Transparent); c->setPlotArea(10, 5, c->getWidth() - 65, c->getHeight() - 15, 0x000000, -1, 0xC8C8C8, Chart::Transparent, 0xffffff); c->xAxis()->setColors(Chart::Transparent); c->xAxis()->setLabelStyle("arial.ttf", 10); c->xAxis()->setLabelGap(-1); c->xAxis()->setLabelAlignment(1); c->yAxis()->setColors(Chart::Transparent, Chart::Transparent); //遍历查询结果并绘制结果 int ea_result_count = ea_results.size(); //设置X轴的label for(int i = 0;i < ea_result_count;i++){ ExchangeRateResult *ea_result = ea_results[i]; DoubleArray y_data = ea_result->getYData(); //添加图层 LineLayer *layer = c->addLineLayer(); layer->setFastLineMode(); layer->setLineWidth(1); //设置X轴 layer->setXData(getXData(i)); //设置Y轴 layer->addDataSet(y_data, ea_result->getColor(), ea_result->getName().toUtf8().data()); } c->xAxis()->setDateScale(m_ChartViewer->getValueAtViewPort("x", 0), m_ChartViewer->getValueAtViewPort("x", 1)); // c->xAxis()->setTickDensity(75); c->yAxis()->setRounding(false, false); delete m_ViewPortControl->getChart(); m_ViewPortControl->setChart(c); drawChart(); }
// // Draw the chart and display it in the given viewer // void ZoomScrollTrack2::drawChart(QChartViewer *viewer) { // Get the start date and end date that are visible on the chart. double viewPortStartDate = viewer->getValueAtViewPort("x", viewer->getViewPortLeft()); double viewPortEndDate = viewer->getValueAtViewPort("x", viewer->getViewPortLeft() + viewer->getViewPortWidth()); // Get the array indexes that corresponds to the visible start and end dates int startIndex = (int)floor(Chart::bSearch(m_timeStamps, viewPortStartDate)); int endIndex = (int)ceil(Chart::bSearch(m_timeStamps, viewPortEndDate)); int noOfPoints = endIndex - startIndex + 1; // Extract the part of the data array that are visible. DoubleArray viewPortTimeStamps = DoubleArray(m_timeStamps.data + startIndex, noOfPoints); DoubleArray viewPortDataSeriesA = DoubleArray(m_dataSeriesA.data + startIndex, noOfPoints); DoubleArray viewPortDataSeriesB = DoubleArray(m_dataSeriesB.data + startIndex, noOfPoints); DoubleArray viewPortDataSeriesC = DoubleArray(m_dataSeriesC.data + startIndex, noOfPoints); // // At this stage, we have extracted the visible data. We can use those data to plot the chart. // /////////////////////////////////////////////////////////////////////////////////////// // Configure overall chart appearance. /////////////////////////////////////////////////////////////////////////////////////// // Create an XYChart object of size 650 x 350 pixels, with a white (ffffff) background and grey // (aaaaaa) border XYChart *c = new XYChart(650, 350, 0xffffff, 0xaaaaaa); // Set the plotarea at (55, 55) with width 90 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(55, 55, c->getWidth() - 90, c->getHeight() - 90, c->linearGradientColor(0, 55, 0, c->getHeight() - 35, 0xf0f6ff, 0xa0c0ff), -1, Chart::Transparent, 0xffffff, 0xffffff); // As the data can lie outside the plotarea in a zoomed chart, we need enable clipping. c->setClipping(); // Add a title to the chart using 18 pts Times New Roman Bold Italic font c->addTitle(" Zooming and Scrolling with Track Line (2)", "timesbi.ttf", 18); // Add a legend box at (55, 30) using horizontal layout. Use 8pts Arial Bold as font. Set the // background and border color to Transparent and use line style legend key. LegendBox *b = c->addLegend(55, 30, false, "arialbd.ttf", 8); b->setBackground(Chart::Transparent); b->setLineStyleKey(); // Set the axis stem to transparent c->xAxis()->setColors(Chart::Transparent); c->yAxis()->setColors(Chart::Transparent); // Add axis title using 10pts Arial Bold Italic font c->yAxis()->setTitle("Ionic Temperature (C)", "arialbi.ttf", 10); /////////////////////////////////////////////////////////////////////////////////////// // Add data to chart /////////////////////////////////////////////////////////////////////////////////////// // // In this example, we represent the data by lines. You may modify the code below to use other // representations (areas, scatter plot, etc). // // Add a line layer for the lines, using a line width of 2 pixels LineLayer *layer = c->addLineLayer(); layer->setLineWidth(2); // In this demo, we do not have too many data points. In real code, the chart may contain a lot // of data points when fully zoomed out - much more than the number of horizontal pixels in this // plot area. So it is a good idea to use fast line mode. layer->setFastLineMode(); // Now we add the 3 data series to a line layer, using the color red (ff0000), green // (00cc00) and blue (0000ff) layer->setXData(viewPortTimeStamps); layer->addDataSet(viewPortDataSeriesA, 0xff3333, "Alpha"); layer->addDataSet(viewPortDataSeriesB, 0x008800, "Beta"); layer->addDataSet(viewPortDataSeriesC, 0x3333CC, "Gamma"); /////////////////////////////////////////////////////////////////////////////////////// // Configure axis scale and labelling /////////////////////////////////////////////////////////////////////////////////////// // Set the x-axis as a date/time axis with the scale according to the view port x range. viewer->syncDateAxisWithViewPort("x", c->xAxis()); // // In this demo, the time range can be from a few years to a few days. We demonstrate how to set // up different date/time format based on the time range. // // If all ticks are yearly aligned, then we use "yyyy" as the label format. c->xAxis()->setFormatCondition("align", 360 * 86400); c->xAxis()->setLabelFormat("{value|yyyy}"); // If all ticks are monthly aligned, then we use "mmm yyyy" in bold font as the first // label of a year, and "mmm" for other labels. c->xAxis()->setFormatCondition("align", 30 * 86400); c->xAxis()->setMultiFormat(Chart::StartOfYearFilter(), "<*font=bold*>{value|mmm yyyy}", Chart::AllPassFilter(), "{value|mmm}"); // If all ticks are daily algined, then we use "mmm dd<*br*>yyyy" in bold font as the // first label of a year, and "mmm dd" in bold font as the first label of a month, and // "dd" for other labels. c->xAxis()->setFormatCondition("align", 86400); c->xAxis()->setMultiFormat(Chart::StartOfYearFilter(), "<*block,halign=left*><*font=bold*>{value|mmm dd<*br*>yyyy}", Chart::StartOfMonthFilter(), "<*font=bold*>{value|mmm dd}"); c->xAxis()->setMultiFormat(Chart::AllPassFilter(), "{value|dd}"); // For all other cases (sub-daily ticks), use "hh:nn<*br*>mmm dd" for the first label of // a day, and "hh:nn" for other labels. c->xAxis()->setFormatCondition("else"); c->xAxis()->setMultiFormat(Chart::StartOfDayFilter(), "<*font=bold*>{value|hh:nn<*br*>mmm dd}", Chart::AllPassFilter(), "{value|hh:nn}"); /////////////////////////////////////////////////////////////////////////////////////// // Output the chart /////////////////////////////////////////////////////////////////////////////////////// // We need to update the track line too. If the mouse is moving on the chart (eg. if // the user drags the mouse on the chart to scroll it), the track line will be updated // in the MouseMovePlotArea event. Otherwise, we need to update the track line here. if ((!viewer->isInMouseMoveEvent()) && viewer->isMouseOnPlotArea()) trackLineLabel(c, viewer->getPlotAreaMouseX()); delete viewer->getChart(); viewer->setChart(c); }
int main(int argc, char *argv[]) { // In this example, the data points are unevenly spaced on the x-axis double dataY[] = {4.7, 4.7, 6.6, 2.2, 4.7, 4.0, 4.0, 5.1, 4.5, 4.5, 6.8, 4.5, 4, 2.1, 3, 2.5, 2.5, 3.1}; double dataX[] = {chartTime(1999, 7, 1), chartTime(2000, 1, 1), chartTime(2000, 2, 1), chartTime(2000, 4, 1), chartTime(2000, 5, 8), chartTime(2000, 7, 5), chartTime(2001, 3, 5), chartTime(2001, 4, 7), chartTime(2001, 5, 9), chartTime(2002, 2, 4), chartTime(2002, 4, 4), chartTime(2002, 5, 8), chartTime(2002, 7, 7), chartTime(2002, 8, 30), chartTime(2003, 1, 2), chartTime(2003, 2, 16), chartTime(2003, 11, 6), chartTime(2004, 1, 4)}; // Data points are assigned different symbols based on point type double pointType[] = {0, 1, 0, 1, 2, 1, 0, 0, 1, 1, 2, 2, 1, 0, 2, 1, 2, 0}; // Create a XYChart object of size 600 x 300 pixels, with a light purple (ffccff) // background, black border, 1 pixel 3D border effect and rounded corners. XYChart *c = new XYChart(600, 300, 0xffccff, 0x000000, 1); c->setRoundedFrame(); // Set the plotarea at (55, 58) and of size 520 x 195 pixels, with white (ffffff) // background. Set horizontal and vertical grid lines to grey (cccccc). c->setPlotArea(55, 58, 520, 195, 0xffffff, -1, -1, 0xcccccc, 0xcccccc); // Add a legend box at (55, 30) (top of the chart) with horizontal layout. Use 10 // pts Arial Bold Italic font. Set the background and border color to // Transparent. c->addLegend(55, 30, false, "arialbi.ttf", 10)->setBackground(Chart::Transparent) ; // Add a title box to the chart using 15 pts Times Bold Italic font. The text is // white (ffffff) on a purple (400040) background, with soft lighting effect from // the right side. c->addTitle("Multi-Symbol Line Chart Demo", "timesbi.ttf", 15, 0xffffff )->setBackground(0x400040, -1, Chart::softLighting(Chart::Right)); // Set the y axis label format to display a percentage sign c->yAxis()->setLabelFormat("{value}%"); // Set axis titles to use 9pt Arial Bold Italic font c->yAxis()->setTitle("Axis Title Placeholder", "arialbi.ttf", 9); c->xAxis()->setTitle("Axis Title Placeholder", "arialbi.ttf", 9); // Set axis labels to use Arial Bold font c->yAxis()->setLabelStyle("arialbd.ttf"); c->xAxis()->setLabelStyle("arialbd.ttf"); // We add the different data symbols using scatter layers. The scatter layers are // added before the line layer to make sure the data symbols stay on top of the // line layer. // We select the points with pointType = 0 (the non-selected points will be set // to NoValue), and use yellow (ffff00) 15 pixels high 5 pointed star shape // symbols for the points. (This example uses both x and y coordinates. For // charts that have no x explicitly coordinates, use an empty array as dataX.) c->addScatterLayer(DoubleArray(dataX, sizeof(dataX)/sizeof(dataX[0])), ArrayMath( DoubleArray(dataY, sizeof(dataY)/sizeof(dataY[0]))).selectEQZ(DoubleArray( pointType, sizeof(pointType)/sizeof(pointType[0])), Chart::NoValue), "Point Type 0", Chart::StarShape(5), 15, 0xffff00); // Similar to above, we select the points with pointType - 1 = 0 and use green // (ff00) 13 pixels high six-sided polygon as symbols. c->addScatterLayer(DoubleArray(dataX, sizeof(dataX)/sizeof(dataX[0])), ArrayMath( DoubleArray(dataY, sizeof(dataY)/sizeof(dataY[0]))).selectEQZ(ArrayMath( DoubleArray(pointType, sizeof(pointType)/sizeof(pointType[0]))).sub(1), Chart::NoValue), "Point Type 1", Chart::PolygonShape(6), 13, 0x00ff00); // Similar to above, we select the points with pointType - 2 = 0 and use red // (ff0000) 13 pixels high X shape as symbols. c->addScatterLayer(DoubleArray(dataX, sizeof(dataX)/sizeof(dataX[0])), ArrayMath( DoubleArray(dataY, sizeof(dataY)/sizeof(dataY[0]))).selectEQZ(ArrayMath( DoubleArray(pointType, sizeof(pointType)/sizeof(pointType[0]))).sub(2), Chart::NoValue), "Point Type 2", Chart::Cross2Shape(), 13, 0xff0000); // Finally, add a blue (0000ff) line layer with line width of 2 pixels LineLayer *layer = c->addLineLayer(DoubleArray(dataY, sizeof(dataY)/sizeof(dataY[0])), 0x0000ff); layer->setXData(DoubleArray(dataX, sizeof(dataX)/sizeof(dataX[0]))); layer->setLineWidth(2); // output the chart c->makeChart("multisymbolline.png"); //free up resources delete c; return 0; }
int main(int argc, char *argv[]) { // The data for the chart double data[] = {40, 15, 7, 5, 2}; // The labels for the chart const char *labels[] = {"Hard Disk", "PCB", "Printer", "CDROM", "Keyboard"}; // In the pareto chart, the line data are just the accumulation of the raw data, // scaled to a range of 0 - 100% ArrayMath lineData = ArrayMath(DoubleArray(data, sizeof(data)/sizeof(data[0]))); lineData.acc(); double scaleFactor = lineData.max() / 100; if (scaleFactor == 0) { // Avoid division by zero error for zero data scaleFactor = 1; } lineData.div(scaleFactor); // Create a XYChart object of size 480 x 300 pixels. Set background color to // brushed silver, with a grey (bbbbbb) border and 2 pixel 3D raised effect. Use // rounded corners. Enable soft drop shadow. XYChart *c = new XYChart(400, 300, Chart::brushedSilverColor(), 0xbbbbbb, 2); c->setRoundedFrame(); c->setDropShadow(); // Add a title to the chart using 15 points Arial Italic. Set top/bottom margins // to 12 pixels. TextBox *title = c->addTitle("Pareto Chart Demonstration", "ariali.ttf", 15); title->setMargin(0, 0, 12, 12); // Tentatively set the plotarea at (50, 40). Set the width to 100 pixels less // than the chart width, and the height to 80 pixels less than the chart height. // Use pale grey (f4f4f4) background, transparent border, and dark grey (444444) // dotted grid lines. c->setPlotArea(50, 40, c->getWidth() - 100, c->getHeight() - 80, 0xf4f4f4, -1, Chart::Transparent, c->dashLineColor(0x444444, Chart::DotLine)); // Add a line layer for the pareto line LineLayer *lineLayer = c->addLineLayer(); // Add the pareto line using deep blue (0000ff) as the color, with circle symbols lineLayer->addDataSet(lineData.result(), 0x0000ff)->setDataSymbol( Chart::CircleShape, 9, 0x0000ff, 0x0000ff); // Set the line width to 2 pixel lineLayer->setLineWidth(2); // Bind the line layer to the secondary (right) y-axis. lineLayer->setUseYAxis2(); // Add a multi-color bar layer using the given data. BarLayer *barLayer = c->addBarLayer(DoubleArray(data, sizeof(data)/sizeof(data[0])), IntArray(0, 0)); // Set soft lighting for the bars with light direction from the right barLayer->setBorderColor(Chart::Transparent, Chart::softLighting(Chart::Right)); // Set the labels on the x axis. c->xAxis()->setLabels(StringArray(labels, sizeof(labels)/sizeof(labels[0]))); // Set the secondary (right) y-axis scale as 0 - 100 with a tick every 20 units c->yAxis2()->setLinearScale(0, 100, 20); // Set the format of the secondary (right) y-axis label to include a percentage // sign c->yAxis2()->setLabelFormat("{value}%"); // Set the relationship between the two y-axes, which only differ by a scaling // factor c->yAxis()->syncAxis(c->yAxis2(), scaleFactor); // Set the format of the primary y-axis label foramt to show no decimal point c->yAxis()->setLabelFormat("{value|0}"); // Add a title to the primary y-axis c->yAxis()->setTitle("Frequency"); // Set all axes to transparent c->xAxis()->setColors(Chart::Transparent); c->yAxis()->setColors(Chart::Transparent); c->yAxis2()->setColors(Chart::Transparent); // Adjust the plot area size, such that the bounding box (inclusive of axes) is // 10 pixels from the left edge, just below the title, 10 pixels from the right // edge, and 20 pixels from the bottom edge. c->packPlotArea(10, title->getHeight(), c->getWidth() - 10, c->getHeight() - 20); // Output the chart c->makeChart("pareto.jpg"); //free up resources delete c; return 0; }
// // 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; }
int main(int argc, char *argv[]) { // In this example, the data points are unevenly spaced on the x-axis double dataY[] = {4.7, 4.7, 6.6, 2.2, 4.7, 4.0, 4.0, 5.1, 4.5, 4.5, 6.8, 4.5, 4, 2.1, 3, 2.5, 2.5, 3.1}; double dataX[] = {Chart::chartTime(1999, 7, 1), Chart::chartTime(2000, 1, 1), Chart::chartTime( 2000, 2, 1), Chart::chartTime(2000, 4, 1), Chart::chartTime(2000, 5, 8), Chart::chartTime( 2000, 7, 5), Chart::chartTime(2001, 3, 5), Chart::chartTime(2001, 4, 7), Chart::chartTime( 2001, 5, 9), Chart::chartTime(2002, 2, 4), Chart::chartTime(2002, 4, 4), Chart::chartTime( 2002, 5, 8), Chart::chartTime(2002, 7, 7), Chart::chartTime(2002, 8, 30), Chart::chartTime( 2003, 1, 2), Chart::chartTime(2003, 2, 16), Chart::chartTime(2003, 11, 6), Chart::chartTime( 2004, 1, 4)}; // Data points are assigned different symbols based on point type double pointType[] = {0, 1, 0, 1, 2, 1, 0, 0, 1, 1, 2, 2, 1, 0, 2, 1, 2, 0}; // Create a XYChart object of size 480 x 320 pixels. Use a vertical gradient color from pale // blue (e8f0f8) to sky blue (aaccff) spanning half the chart height as background. Set border // to blue (88aaee). Use rounded corners. Enable soft drop shadow. XYChart *c = new XYChart(480, 320); c->setBackground(c->linearGradientColor(0, 0, 0, c->getHeight() / 2, 0xe8f0f8, 0xaaccff), 0x88aaee); c->setRoundedFrame(); c->setDropShadow(); // Add a title to the chart using 15 points Arial Italic font. Set top/bottom margins to 12 // pixels. TextBox *title = c->addTitle("Multi-Symbol Line Chart Demo", "ariali.ttf", 15); title->setMargin(0, 0, 12, 12); // Tentatively set the plotarea to 50 pixels from the left edge to allow for the y-axis, and to // just under the title. Set the width to 65 pixels less than the chart width, and the height to // reserve 90 pixels at the bottom for the x-axis and the legend box. Use pale blue (e8f0f8) // background, transparent border, and grey (888888) dotted horizontal and vertical grid lines. c->setPlotArea(50, title->getHeight(), c->getWidth() - 65, c->getHeight() - title->getHeight() - 90, 0xe8f0f8, -1, Chart::Transparent, c->dashLineColor(0x888888, Chart::DotLine), -1); // Add a legend box where the bottom-center is anchored to the 12 pixels above the bottom-center // of the chart. Use horizontal layout and 8 points Arial font. LegendBox *legendBox = c->addLegend(c->getWidth() / 2, c->getHeight() - 12, false, "arialbd.ttf", 8); legendBox->setAlignment(Chart::BottomCenter); // Set the legend box background and border to pale blue (e8f0f8) and bluish grey (445566) legendBox->setBackground(0xe8f0f8, 0x445566); // Use rounded corners of 5 pixel radius for the legend box legendBox->setRoundedCorners(5); // Set the y axis label format to display a percentage sign c->yAxis()->setLabelFormat("{value}%"); // Set y-axis title to use 10 points Arial Bold Italic font c->yAxis()->setTitle("Axis Title Placeholder", "arialbi.ttf", 10); // Set axis labels to use Arial Bold font c->yAxis()->setLabelStyle("arialbd.ttf"); c->xAxis()->setLabelStyle("arialbd.ttf"); // We add the different data symbols using scatter layers. The scatter layers are added before // the line layer to make sure the data symbols stay on top of the line layer. // We select the points with pointType = 0 (the non-selected points will be set to NoValue), and // use yellow (ffff00) 15 pixels high 5 pointed star shape symbols for the points. (This example // uses both x and y coordinates. For charts that have no x explicitly coordinates, use an empty // array as dataX.) c->addScatterLayer(DoubleArray(dataX, (int)(sizeof(dataX) / sizeof(dataX[0]))), ArrayMath( DoubleArray(dataY, (int)(sizeof(dataY) / sizeof(dataY[0])))).selectEQZ(DoubleArray( pointType, (int)(sizeof(pointType) / sizeof(pointType[0]))), Chart::NoValue), "Point Type 0", Chart::StarShape(5), 15, 0xffff00); // Similar to above, we select the points with pointType - 1 = 0 and use green (ff00) 13 pixels // high six-sided polygon as symbols. c->addScatterLayer(DoubleArray(dataX, (int)(sizeof(dataX) / sizeof(dataX[0]))), ArrayMath( DoubleArray(dataY, (int)(sizeof(dataY) / sizeof(dataY[0])))).selectEQZ(ArrayMath( DoubleArray(pointType, (int)(sizeof(pointType) / sizeof(pointType[0])))).sub(1), Chart::NoValue), "Point Type 1", Chart::PolygonShape(6), 13, 0x00ff00); // Similar to above, we select the points with pointType - 2 = 0 and use red (ff0000) 13 pixels // high X shape as symbols. c->addScatterLayer(DoubleArray(dataX, (int)(sizeof(dataX) / sizeof(dataX[0]))), ArrayMath( DoubleArray(dataY, (int)(sizeof(dataY) / sizeof(dataY[0])))).selectEQZ(ArrayMath( DoubleArray(pointType, (int)(sizeof(pointType) / sizeof(pointType[0])))).sub(2), Chart::NoValue), "Point Type 2", Chart::Cross2Shape(), 13, 0xff0000); // Finally, add a blue (0000ff) line layer with line width of 2 pixels LineLayer *layer = c->addLineLayer(DoubleArray(dataY, (int)(sizeof(dataY) / sizeof(dataY[0]))), 0x0000ff); layer->setXData(DoubleArray(dataX, (int)(sizeof(dataX) / sizeof(dataX[0])))); layer->setLineWidth(2); // Adjust the plot area size, such that the bounding box (inclusive of axes) is 10 pixels from // the left edge, just below the title, 25 pixels from the right edge, and 8 pixels above the // legend box. c->packPlotArea(10, title->getHeight(), c->getWidth() - 25, c->layoutLegend()->getTopY() - 8); // Output the chart c->makeChart("multisymbolline.png"); //free up resources delete c; return 0; }
int main(int argc, char *argv[]) { // // We use a random number generator to simulate the data from 9:30am to 4:30pm // with one data point every 4 minutes. The total number of points during that // period is 106. (7 hours x 15 points/hour + 1) // int noOfPoints = 106; // Assume we have not reached the end of the day yet, and only 85 points are // available. Create a random table object of 1 col x 85 rows, using 9 as seed. RanTable *rantable = new RanTable(9, 1, 85); // Set the 1st column to start with 1800 and with random delta from -5 to 5. rantable->setCol(0, 1800, -5, 5); // Get the data as the 1st column of the random table DoubleArray data = rantable->getCol(0); // The x-axis labels for the chart const char *labels[] = {"-", "10am", "-", " ", "-", "12am", "-", " ", "-", "2pm", "-", " ", "-", "4pm", "-"}; // // Now we obtain the data into arrays, we can start to draw the chart using // ChartDirector // // Create a XYChart object of size 180 x 180 pixels with a blue background // (0x9c9cce) XYChart *c = new XYChart(180, 180, 0x9c9cce); // Add titles to the top and bottom of the chart using 7.5pt Arial font. The text // is white 0xffffff on a deep blue 0x31319C background. c->addTitle(Chart::Top, "STAR TECH INDEX 2003-01-28", "arial.ttf", 7.5, 0xffffff, 0x31319c); c->addTitle(Chart::Bottom, "LATEST STI:1809.41 (+14.51)", "arial.ttf", 7.5, 0xffffff, 0x31319c); // Set the plotarea at (31, 21) and of size 145 x 124 pixels, with a pale yellow // (0xffffc8) background. c->setPlotArea(31, 21, 145, 124, 0xffffc8); // Add custom text at (176, 21) (top right corner of plotarea) using 11pt Times // Bold Italic font/red (0xc09090) color c->addText(176, 21, "Chart Demo", "timesbi.ttf", 11, 0xc09090)->setAlignment( Chart::TopRight); // Use 7.5 pts Arial as the y axis label font c->yAxis()->setLabelStyle("", 7.5); // Set the labels on the x axis by spreading the labels evenly between the first // point (index = 0) and the last point (index = noOfPoints - 1) c->xAxis()->setLinearScale(0, noOfPoints - 1, StringArray(labels, sizeof(labels)/sizeof(labels[0]))); // Use 7.5 pts Arial as the x axis label font c->xAxis()->setLabelStyle("", 7.5); // Add a deep blue (0x000080) line layer to the chart c->addLineLayer(data, 0x000080); // Output the chart c->makeChart("compactline.png"); //free up resources delete rantable; delete c; return 0; }
//只是一个demo,有内存泄露的 QWidget * Widget::addLineWithErrorSymbols() { // The data with error information double data[] = {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 errData[] = {5, 6, 5.1, 6.5, 6.6, 8, 5.4, 5.1, 4.6, 5.0, 5.2, 6.0, 4.9, 5.6, 4.8, 6.2, 7.4, 7.1, 6.0, 6.6, 7.1, 50.3, 5.5, 7.9, 6.1}; // The labels for the 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 600 x 300 pixels, with a light grey (eeeeee) background, // black border, 1 pixel 3D border effect and rounded corners. XYChart *c = new XYChart(600, 300, 0xeeeeee, 0x000000, 1); c->setRoundedFrame(0xaafaaf); // Set the plotarea at (55, 55) and of size 520 x 195 pixels, with white (ffffff) background. // Set horizontal and vertical grid lines to grey (cccccc). c->setPlotArea(55, 55, 520, 195, 0xffffff, -1, -1, 0xcccccc, 0xcccccc); // Add a title box to the chart using 15pt Times Bold Italic font. The title is in CDML and // includes embedded images for highlight. The text is on a light grey (dddddd) background, with // glass lighting effect. c->addTitle( "<*block,valign=absmiddle*><*img=star.png*><*img=star.png*> Molecular Temperature Control " "<*img=star.png*><*img=star.png*><*/*>", "timesbi.ttf", 15)->setBackground(0xdddddd, 0, Chart::glassEffect());//增加玻璃效果 // Add a title to the y axis c->yAxis()->setTitle("Temperature"); // Add a title to the x axis using CMDL c->xAxis()->setTitle("<*block,valign=absmiddle*><*img=clock.png*> Elapsed Time (hour)<*/*>"); // Set the labels on the x axis. c->xAxis()->setLabels(StringArray(labels, (int)(sizeof(labels) / sizeof(labels[0])))); // Display 1 out of 3 labels on the x-axis. Show minor ticks for remaining labels. c->xAxis()->setLabelStep(3, 1); // Set the axes width to 2 pixels c->xAxis()->setWidth(2); c->yAxis()->setWidth(2); // Add a line layer to the chart LineLayer *lineLayer = c->addLineLayer(); // Add a blue (0xff) data set to the line layer, with yellow (0xffff80) diamond symbols lineLayer->addDataSet(DoubleArray(data, (int)(sizeof(data) / sizeof(data[0]))), 0x0000ff )->setDataSymbol(Chart::DiamondSymbol, 12, 0xffff80); // Set the line width to 2 pixels lineLayer->setLineWidth(2); // Add a box whisker layer to the chart. Use the upper and lower mark of the box whisker layer // to act as error zones. The upper and lower marks are computed using the ArrayMath object. BoxWhiskerLayer *errLayer = c->addBoxWhiskerLayer(DoubleArray(), DoubleArray(), ArrayMath( DoubleArray(data, (int)(sizeof(data) / sizeof(data[0])))).add(DoubleArray(errData, (int)( sizeof(errData) / sizeof(errData[0])))), ArrayMath(DoubleArray(data, (int)(sizeof(data) / sizeof(data[0])))).sub(DoubleArray(errData, (int)(sizeof(errData) / sizeof(errData[0])))), DoubleArray(data, (int)(sizeof(data) / sizeof(data[0]))), Chart::Transparent, 0xbb6633); // Set the line width to 2 pixels errLayer->setLineWidth(2); // Set the error zone to occupy half the space between the symbols errLayer->setDataGap(0.5); // Add a custom CDML text at the bottom right of the plot area as the logo c->addText(575, 247, "<*block,valign=absmiddle*><*img=small_molecule.png*> <*block*>" "<*font=timesbi.ttf,size=10,color=804040*>Molecular\nEngineering<*/*>")->setAlignment( Chart::BottomRight); // Output the chart c->makeChart("errline.png"); QWidget * _w= new QWidget(); QChartViewer * _v = new QChartViewer(_w); _v->setChart(c); //free up resources //delete c; return _w; }
int main(int argc, char *argv[]) { // The data for the 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}; // The labels for the bottom x axis. Note the "-" means a minor tick. const char *labels0[] = {"0\nJun 4", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "0\nJun 5"}; // The labels for the top x axis. Note that "-" means a minor tick. const char *labels1[] = {"Jun 3\n12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "Jun 4\n0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}; // Create a XYChart object of size 310 x 310 pixels XYChart *c = new XYChart(310, 310); // Set the plotarea at (50, 50) and of size 200 x 200 pixels c->setPlotArea(50, 50, 200, 200); // Add a title to the primary (left) y axis c->yAxis()->setTitle("US Dollars"); // Set the tick length to -4 pixels (-ve means ticks inside the plot area) c->yAxis()->setTickLength(-4); // Add a title to the secondary (right) y axis c->yAxis2()->setTitle("HK Dollars (1 USD = 7.8 HKD)"); // Set the tick length to -4 pixels (-ve means ticks inside the plot area) c->yAxis2()->setTickLength(-4); // Synchronize the y-axis such that y2 = 7.8 x y1 c->syncYAxis(7.8); // Add a title to the bottom x axis c->xAxis()->setTitle("Hong Kong Time"); // Set the labels on the x axis. c->xAxis()->setLabels(StringArray(labels0, sizeof(labels0)/sizeof(labels0[0]))); // Display 1 out of 3 labels on the x-axis. Show minor ticks for remaining // labels. c->xAxis()->setLabelStep(3, 1); // Set the major tick length to -4 pixels and minor tick length to -2 pixels (-ve // means ticks inside the plot area) c->xAxis()->setTickLength(-4, -2); // Set the distance between the axis labels and the axis to 6 pixels c->xAxis()->setLabelGap(6); // Add a title to the top x-axis c->xAxis2()->setTitle("New York Time"); // Set the labels on the x axis. c->xAxis2()->setLabels(StringArray(labels1, sizeof(labels1)/sizeof(labels1[0]))); // Display 1 out of 3 labels on the x-axis. Show minor ticks for remaining // labels. c->xAxis2()->setLabelStep(3, 1); // Set the major tick length to -4 pixels and minor tick length to -2 pixels (-ve // means ticks inside the plot area) c->xAxis2()->setTickLength(-4, -2); // Set the distance between the axis labels and the axis to 6 pixels c->xAxis2()->setLabelGap(6); // Add a line layer to the chart with a line width of 2 pixels c->addLineLayer(DoubleArray(data0, sizeof(data0)/sizeof(data0[0])), -1, "Red Transactions")->setLineWidth(2); // Add an area layer to the chart with no area boundary line c->addAreaLayer(DoubleArray(data1, sizeof(data1)/sizeof(data1[0])), -1, "Green Transactions")->setLineWidth(0); // output the chart c->makeChart("dualxaxis.png"); //free up resources delete c; return 0; }
int main(int argc, char *argv[]) { // The data for the chart double data0[] = {42, 49, Chart::NoValue, 38, 64, 56, 29, 41, 44, 57}; double data1[] = {65, 75, 47, 34, 42, 49, 73, Chart::NoValue, 90, 69, 66, 78}; double data2[] = {Chart::NoValue, Chart::NoValue, 25, 28, 38, 20, 22, Chart::NoValue, 25, 33, 30, 24}; const char *labels[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; // Create a XYChart object of size 600 x 360 pixels. Set background color to // brushed silver, with a 2 pixel 3D border. Use rounded corners. XYChart *c = new XYChart(600, 360, Chart::brushedSilverColor(), Chart::Transparent, 2); c->setRoundedFrame(); // Add a title using 18 pts Times New Roman Bold Italic font. #Set top/bottom // margins to 6 pixels. TextBox *title = c->addTitle("Product Line Global Revenue", "timesbi.ttf", 18); title->setMargin(0, 0, 6, 6); // Add a separator line just under the title c->addLine(10, title->getHeight(), c->getWidth() - 11, title->getHeight(), Chart::LineColor); // Add a legend box where the top-center is anchored to the horizontal center of // the chart, just under the title. Use horizontal layout and 10 points Arial // Bold font, and transparent background and border. LegendBox *legendBox = c->addLegend(c->getWidth() / 2, title->getHeight(), false, "arialbd.ttf", 10); legendBox->setAlignment(Chart::TopCenter); legendBox->setBackground(Chart::Transparent, Chart::Transparent); // Tentatively set the plotarea at (70, 75) and of 460 x 240 pixels in size. Use // transparent border and black (000000) grid lines c->setPlotArea(70, 75, 460, 240, -1, -1, Chart::Transparent, 0x000000, -1); // Set the x axis labels c->xAxis()->setLabels(StringArray(labels, sizeof(labels)/sizeof(labels[0]))); // Show the same scale on the left and right y-axes c->syncYAxis(); // Set y-axis tick density to 30 pixels. ChartDirector auto-scaling will use this // as the guideline when putting ticks on the y-axis. c->yAxis()->setTickDensity(30); // Set all axes to transparent c->xAxis()->setColors(Chart::Transparent); c->yAxis()->setColors(Chart::Transparent); c->yAxis2()->setColors(Chart::Transparent); // Set the x-axis margins to 15 pixels, so that the horizontal grid lines can // extend beyond the leftmost and rightmost vertical grid lines c->xAxis()->setMargin(15, 15); // 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); // Add axis title using 10pts Arial Bold Italic font c->yAxis()->setTitle("Revenue in USD millions", "arialbi.ttf", 10); c->yAxis2()->setTitle("Revenue in USD millions", "arialbi.ttf", 10); // Add the first line. The missing data will be represented as gaps in the line // (the default behaviour) LineLayer *layer0 = c->addLineLayer(); layer0->addDataSet(DoubleArray(data0, sizeof(data0)/sizeof(data0[0])), 0xff0000, "Quantum Computer")->setDataSymbol(Chart::GlassSphere2Shape, 11); layer0->setLineWidth(3); // Add the second line. The missing data will be represented by using dash lines // to bridge the gap LineLayer *layer1 = c->addLineLayer(); layer1->addDataSet(DoubleArray(data1, sizeof(data1)/sizeof(data1[0])), 0x00ff00, "Atom Synthesizer")->setDataSymbol(Chart::GlassSphere2Shape, 11); layer1->setLineWidth(3); layer1->setGapColor(c->dashLineColor(0x00ff00)); // Add the third line. The missing data will be ignored - just join the gap with // the original line style. LineLayer *layer2 = c->addLineLayer(); layer2->addDataSet(DoubleArray(data2, sizeof(data2)/sizeof(data2[0])), 0xff6600, "Proton Cannon")->setDataSymbol(Chart::GlassSphere2Shape, 11); layer2->setLineWidth(3); layer2->setGapColor(Chart::SameAsMainColor); // layout the legend so we can get the height of the legend box c->layoutLegend(); // Adjust the plot area size, such that the bounding box (inclusive of axes) is // 15 pixels from the left edge, just under the legend box, 16 pixels from the // right edge, and 25 pixels from the bottom edge. c->packPlotArea(15, legendBox->getTopY() + legendBox->getHeight(), c->getWidth() - 16, c->getHeight() - 25); // Output the chart c->makeChart("missingpoints.jpg"); //free up resources delete c; return 0; }