Build 4.0.0.86 of xlsgen adds a new trend line to the list of existing trend lines : moving median.
Moving median (N=5 values in the data window)The moving median, as the name suggests, builds on a median computed inside a moving data window (subset of the series of data). The series of the median values as the window moves makes the trend line. The median is a measure by which half of the data is below it, and the other half is above it. Wikipedia
article. Compared to a moving average, the moving median reflects a lot less brutal changes, which are sometimes viewed, depending on the business using it, as skewed or useless values.
And here is how to create it :
C/C++ code |
xlsgen::IXlsWorksheetPtr wksht001 = workbook->AddWorksheet( L"Sheet1" );
// data wksht001->Cell[2][2]->HtmlFloat = L"<font color=#000000 size=11 name=\"Calibri\">50</font>"; wksht001->Cell[3][2]->HtmlFloat = L"<font color=#000000 size=11 name=\"Calibri\">30</font>"; wksht001->Cell[4][2]->HtmlFloat = L"<font color=#000000 size=11 name=\"Calibri\">100</font>"; wksht001->Cell[5][2]->HtmlFloat = L"<font color=#000000 size=11 name=\"Calibri\">40</font>"; wksht001->Cell[6][2]->HtmlFloat = L"<font color=#000000 size=11 name=\"Calibri\">200</font>"; wksht001->Cell[7][2]->HtmlFloat = L"<font color=#000000 size=11 name=\"Calibri\">70</font>"; wksht001->Cell[8][2]->HtmlFloat = L"<font color=#000000 size=11 name=\"Calibri\">100</font>"; wksht001->Cell[9][2]->HtmlFloat = L"<font color=#000000 size=11 name=\"Calibri\">10</font>"; wksht001->Cell[10][2]->HtmlFloat = L"<font color=#000000 size=11 name=\"Calibri\">150</font>"; wksht001->Cell[11][2]->HtmlFloat = L"<font color=#000000 size=11 name=\"Calibri\">250</font>";
// chart xlsgen::IXlsChartPtr chart001s0 = wksht001->NewChart(xlsgen::charttype_bar2D, 5, 1, 20, 8);
xlsgen::IXlsChartDynamicDataSourceSeriesPtr serie001s0ss0 = chart001s0->DynamicDataSource->AddSerie(); serie001s0ss0->SeriesValuesFormula = L"Sheet1!$B$2:$B$11"; chart001s0->SeriesByIndex[1]->TrendLines[1]->Show = xlsgen::charttrendline_movingmedian; // moving median trendline chart001s0->SeriesByIndex[1]->TrendLines[1]->MovingAveragePeriods = 5; // N=5
wksht001->Export->ExportAsPDF(L"moving_median.pdf"); // ask xlsgen to compute and render it
workbook->Close();
|