From 46904270c5f5db6b9156bf5ad185011d68582fdb 2012-08-27 11:03:12 From: sauimone Date: 2012-08-27 11:03:12 Subject: [PATCH] barchart doc review updates --- diff --git a/doc/src/examples-barchart.qdoc b/doc/src/examples-barchart.qdoc index 30ff9a1..5921663 100644 --- a/doc/src/examples-barchart.qdoc +++ b/doc/src/examples-barchart.qdoc @@ -7,33 +7,41 @@ \image examples_barchart.png + The barsets are used in same way in all barcharts. + To illustrate difference between various barcharts, we use same data in examples. Data that barchart visualizes, is defined by QBarSet instances. Here we create the sets and append data - to them. + to them. The data is appended here with << operator. Alternatively the append method could be used. \snippet ../examples/barchart/main.cpp 1 - We create the series and append the sets to it. The barseries groups the data from sets to categories. + We create the series and append the barsets to it. The series takes ownership of the barsets. The series groups the data from sets to categories. First value of each set are gropuped together at first category second value to second category and so on. \snippet ../examples/barchart/main.cpp 2 - Then we create a chart and add the series to it. + Here we create the chart object and add the series to it. We set the title for chart with setTitle and then turn on animations of the series by calling + setAnimationOptions(QChart::SeriesAnimations) \snippet ../examples/barchart/main.cpp 3 - We define the categories here and add them to QCategoriesAxis which we then set to be the x-axis of the chart. + To have categories displayed on axis, we need to create a QBarCategoryAxis for that. Here we create a category axis with list of categories and + set it to be the x-axis of the chart. The chart takes ownership of axis. For y-axis we use default axis, which is created and scaled to series data + by calling createDefaultAxes of the chart. Note that the call for createDefaultAxes must be before we set the category axis. Otherwise the default axis will + override the category axis. \snippet ../examples/barchart/main.cpp 4 - And we also want to show the legend. + We also want to show the legend. To do that, we get the legend pointer from chart and set it to visible. We also place the legend to bottom of the chart by setting it's alignment + to Qt::AlignBottom. \snippet ../examples/barchart/main.cpp 5 - Finally we add the chart onto a view. + Finally we add the chart onto a view. We also turn on the antialiasing for the chartView. \snippet ../examples/barchart/main.cpp 6 - And it is ready to be shown in a window. + Chart is ready to be shown. We set the chart to be central widget of the window. + We also set the size for the chart window and show it. \snippet ../examples/barchart/main.cpp 7 -*/ +*/ \ No newline at end of file diff --git a/doc/src/examples-horizontalbarchart.qdoc b/doc/src/examples-horizontalbarchart.qdoc index 9106dec..dff8cf0 100644 --- a/doc/src/examples-horizontalbarchart.qdoc +++ b/doc/src/examples-horizontalbarchart.qdoc @@ -3,37 +3,46 @@ \title HorizontalBarChart Example \subtitle - The example shows how to create a horizontal bar chart. HorizontalBarChart shows the data in sets as separate bars, which are grouped in categories. + The example shows how to create a horizontal bar chart. QHorizontalBarChart shows the data in sets as separate bars, which are grouped in categories. QHorizontalBarChart works just like + QBarChart, except that the bars are drawn horizontally on the chart. \image examples_horizontalbarchart.png + The barsets are used in same way in all barcharts. + To illustrate difference between various barcharts, we use same data in examples. Data that barchart visualizes, is defined by QBarSet instances. Here we create the sets and append data - to them. + to them. The data is appended here with << operator. Alternatively the append method could be used. \snippet ../examples/horizontalbarchart/main.cpp 1 - We create the series and append the sets to it. The horizontalbarseries groups the data from sets to categories. + We create the series and append the barsets to it. The series takes ownership of the barsets. The series groups the data from sets to categories. First value of each set are gropuped together at first category second value to second category and so on. \snippet ../examples/horizontalbarchart/main.cpp 2 - Then we create a chart and add the series to it. + Here we create the chart object and add the series to it. We set the title for chart with setTitle and then turn on animations of the series by calling + setAnimationOptions(QChart::SeriesAnimations) \snippet ../examples/horizontalbarchart/main.cpp 3 - We define the categories here and add them to QCategoriesAxis which we then set to be the x-axis of the chart. + To have categories displayed on axis, we need to create a QBarCategoryAxis for that. Here we create a category axis with list of categories and + set it to be the y-axis of the chart. The chart takes ownership of axis. For x-axis we use default axis, which is created and scaled to series data + by calling createDefaultAxes of the chart. Note that the call for createDefaultAxes must be before we set the category axis. Otherwise the default axis will + override the category axis. \snippet ../examples/horizontalbarchart/main.cpp 4 - And we also want to show the legend. + We also want to show the legend. To do that, we get the legend pointer from chart and set it to visible. We also place the legend to bottom of the chart by setting it's alignment + to Qt::AlignBottom. \snippet ../examples/horizontalbarchart/main.cpp 5 - Finally we add the chart onto a view. + Finally we add the chart onto a view. We also turn on the antialiasing for the chartView. \snippet ../examples/horizontalbarchart/main.cpp 6 - And it is ready to be shown in a window. + Chart is ready to be shown. We set the chart to be central widget of the window. + We also set the size for the chart window and show it. \snippet ../examples/horizontalbarchart/main.cpp 7 */ diff --git a/doc/src/examples-horizontalpercentbarchart.qdoc b/doc/src/examples-horizontalpercentbarchart.qdoc index 953a5af..c5e3dde 100644 --- a/doc/src/examples-horizontalpercentbarchart.qdoc +++ b/doc/src/examples-horizontalpercentbarchart.qdoc @@ -6,12 +6,48 @@ The example shows how to create simple horizontal percent bar chart. Horizontal percent bar chart shows the data in set as percentage of all sets, per category. - \image examples_horizontalpercentbarchart.png - Creating horizontal percent bar chart is just like creating a regular \l {BarChart Example} {bar chart}, except that for a horizontal percent bar chart, we use QHorizontalPercentBarSeries api instead of QBarSeries. Also, in the \l {BarChart Example} {bar chart} we used nice numbers algorithm to make the y axis numbering look better. With percent bar chart there is no need for that, because the maximum y-axis value is always 100. + + \image examples_horizontalpercentbarchart.png + + The barsets are used in same way in all barcharts. + To illustrate difference between various barcharts, we use same data in examples. + Data that barchart visualizes, is defined by QBarSet instances. Here we create the sets and append data + to them. The data is appended here with << operator. Alternatively the append method could be used. + + \snippet ../examples/horizontalpercentbarchart/main.cpp 1 + + We create the series and append the barsets to it. The series takes ownership of the barsets. The series groups the data from sets to categories. + First value of each set are gropuped together at first category second value to second category and so on. + + \snippet ../examples/horizontalpercentbarchart/main.cpp 2 + + Here we create the chart object and add the series to it. We set the title for chart with setTitle and then turn on animations of the series by calling + setAnimationOptions(QChart::SeriesAnimations) \snippet ../examples/horizontalpercentbarchart/main.cpp 3 + + To have categories displayed on axis, we need to create a QBarCategoryAxis for that. Here we create a category axis with list of categories and + set it to be the y-axis of the chart. The chart takes ownership of axis. For x-axis we use default axis, which is created and scaled to series data + by calling createDefaultAxes of the chart. Note that the call for createDefaultAxes must be before we set the category axis. Otherwise the default axis will + override the category axis. + + \snippet ../examples/horizontalpercentbarchart/main.cpp 4 + + We also want to show the legend. To do that, we get the legend pointer from chart and set it to visible. We also place the legend to bottom of the chart by setting it's alignment + to Qt::AlignBottom. + + \snippet ../examples/horizontalpercentbarchart/main.cpp 5 + + Finally we add the chart onto a view. We also turn on the antialiasing for the chartView. + + \snippet ../examples/horizontalpercentbarchart/main.cpp 6 + + Chart is ready to be shown. We set the chart to be central widget of the window. + We also set the size for the chart window and show it. + + \snippet ../examples/horizontalpercentbarchart/main.cpp 7 */ diff --git a/doc/src/examples-horizontalstackedbarchart.qdoc b/doc/src/examples-horizontalstackedbarchart.qdoc index 4ae259d..9bb8ec8 100644 --- a/doc/src/examples-horizontalstackedbarchart.qdoc +++ b/doc/src/examples-horizontalstackedbarchart.qdoc @@ -5,11 +5,46 @@ The example shows how to create simple stacked horizontal bar chart. Stacked bar chart shows the data in sets as bars that are stacked on top of each other. The stacking is done per category. + Creating stacked horizontal bar chart is just like creating a regular \l {BarChart Example} {bar chart}, except that for a + stacked horizontal bar chart, we use QHorizontalStackedBarSeries api instead of QBarSeries. \image examples_horizontalstackedbarchart.png - Creating stacked horizontal bar chart is just like creating a regular \l {BarChart Example} {bar chart}, except that for a - stacked horizontal bar chart, we use QHorizontalStackedBarSeries api instead of QBarSeries. + The barsets are used in same way in all barcharts. + To illustrate difference between various barcharts, we use same data in examples. + Data that barchart visualizes, is defined by QBarSet instances. Here we create the sets and append data + to them. The data is appended here with << operator. Alternatively the append method could be used. + + \snippet ../examples/horizontalstackedbarchart/main.cpp 1 + + We create the series and append the barsets to it. The series takes ownership of the barsets. The series groups the data from sets to categories. + First value of each set are gropuped together at first category second value to second category and so on. + + \snippet ../examples/horizontalstackedbarchart/main.cpp 2 + + Here we create the chart object and add the series to it. We set the title for chart with setTitle and then turn on animations of the series by calling + setAnimationOptions(QChart::SeriesAnimations) \snippet ../examples/horizontalstackedbarchart/main.cpp 3 -*/ + + To have categories displayed on axis, we need to create a QBarCategoryAxis for that. Here we create a category axis with list of categories and + set it to be the y-axis of the chart. The chart takes ownership of axis. For x-axis we use default axis, which is created and scaled to series data + by calling createDefaultAxes of the chart. Note that the call for createDefaultAxes must be before we set the category axis. Otherwise the default axis will + override the category axis. + + \snippet ../examples/horizontalstackedbarchart/main.cpp 4 + + We also want to show the legend. To do that, we get the legend pointer from chart and set it to visible. We also place the legend to bottom of the chart by setting it's alignment + to Qt::AlignBottom. + + \snippet ../examples/horizontalstackedbarchart/main.cpp 5 + + Finally we add the chart onto a view. We also turn on the antialiasing for the chartView. + + \snippet ../examples/horizontalstackedbarchart/main.cpp 6 + + Chart is ready to be shown. We set the chart to be central widget of the window. + We also set the size for the chart window and show it. + + \snippet ../examples/horizontalstackedbarchart/main.cpp 7 +*/ \ No newline at end of file diff --git a/doc/src/examples-percentbarchart.qdoc b/doc/src/examples-percentbarchart.qdoc index c572314..99e397d 100644 --- a/doc/src/examples-percentbarchart.qdoc +++ b/doc/src/examples-percentbarchart.qdoc @@ -6,12 +6,48 @@ The example shows how to create simple percent bar chart. Percent bar chart shows the data in set as percentage of all sets, per category. - \image examples_percentbarchart.png - Creating percent bar chart is just like creating a regular \l {BarChart Example} {bar chart}, except that for a percent bar chart, we use QPercentBarSeries api instead of QBarSeries. Also, in the \l {BarChart Example} {bar chart} we used nice numbers algorithm to make the y axis numbering look better. With percent bar chart there is no need for that, because the maximum y-axis value is always 100. + + \image examples_percentbarchart.png + + The barsets are used in same way in all barcharts. + To illustrate difference between various barcharts, we use same data in examples. + Data that barchart visualizes, is defined by QBarSet instances. Here we create the sets and append data + to them. The data is appended here with << operator. Alternatively the append method could be used. + + \snippet ../examples/percentbarchart/main.cpp 1 + + We create the series and append the barsets to it. The series takes ownership of the barsets. The series groups the data from sets to categories. + First value of each set are gropuped together at first category second value to second category and so on. + + \snippet ../examples/percentbarchart/main.cpp 2 + + Here we create the chart object and add the series to it. We set the title for chart with setTitle and then turn on animations of the series by calling + setAnimationOptions(QChart::SeriesAnimations) \snippet ../examples/percentbarchart/main.cpp 3 + + To have categories displayed on axis, we need to create a QBarCategoryAxis for that. Here we create a category axis with list of categories and + set it to be the x-axis of the chart. The chart takes ownership of axis. For y-axis we use default axis, which is created and scaled to series data + by calling createDefaultAxes of the chart. Note that the call for createDefaultAxes must be before we set the category axis. Otherwise the default axis will + override the category axis. + + \snippet ../examples/percentbarchart/main.cpp 4 + + We also want to show the legend. To do that, we get the legend pointer from chart and set it to visible. We also place the legend to bottom of the chart by setting it's alignment + to Qt::AlignBottom. + + \snippet ../examples/percentbarchart/main.cpp 5 + + Finally we add the chart onto a view. We also turn on the antialiasing for the chartView. + + \snippet ../examples/percentbarchart/main.cpp 6 + + Chart is ready to be shown. We set the chart to be central widget of the window. + We also set the size for the chart window and show it. + + \snippet ../examples/percentbarchart/main.cpp 7 */ diff --git a/doc/src/examples-stackedbarchart.qdoc b/doc/src/examples-stackedbarchart.qdoc index 903ef55..b49b3fe 100644 --- a/doc/src/examples-stackedbarchart.qdoc +++ b/doc/src/examples-stackedbarchart.qdoc @@ -5,11 +5,50 @@ The example shows how to create simple stacked bar chart. Stacked bar chart shows the data in sets as bars that are stacked on top of each other. The stacking is done per category. + The example shows how to create simple stacked bar chart. Stacked bar chart shows the data in sets as bars that are + stacked on top of each other. The stacking is done per category. + Creating stacked bar chart is just like creating a regular \l {BarChart Example} {bar chart}, except that for a + stacked bar chart, we use QStackedBarSeries api instead of QBarSeries. \image examples_stackedbarchart.png - Creating stacked bar chart is just like creating a regular \l {BarChart Example} {bar chart}, except that for a - stacked bar chart, we use QStackedBarSeries api instead of QBarSeries. + The barsets are used in same way in all barcharts. + To illustrate difference between various barcharts, we use same data in examples. + Data that barchart visualizes, is defined by QBarSet instances. Here we create the sets and append data + to them. The data is appended here with << operator. Alternatively the append method could be used. + + \snippet ../examples/stackedbarchart/main.cpp 1 + + We create the series and append the barsets to it. The series takes ownership of the barsets. The series groups the data from sets to categories. + First value of each set are gropuped together at first category second value to second category and so on. + + \snippet ../examples/stackedbarchart/main.cpp 2 + + Here we create the chart object and add the series to it. We set the title for chart with setTitle and then turn on animations of the series by calling + setAnimationOptions(QChart::SeriesAnimations) \snippet ../examples/stackedbarchart/main.cpp 3 + + To have categories displayed on axis, we need to create a QBarCategoryAxis for that. Here we create a category axis with list of categories and + set it to be the x-axis of the chart. The chart takes ownership of axis. For y-axis we use default axis, which is created and scaled to series data + by calling createDefaultAxes of the chart. Note that the call for createDefaultAxes must be before we set the category axis. Otherwise the default axis will + override the category axis. + + \snippet ../examples/stackedbarchart/main.cpp 4 + + We also want to show the legend. To do that, we get the legend pointer from chart and set it to visible. We also place the legend to bottom of the chart by setting it's alignment + to Qt::AlignBottom. + + \snippet ../examples/stackedbarchart/main.cpp 5 + + Finally we add the chart onto a view. We also turn on the antialiasing for the chartView. + + \snippet ../examples/stackedbarchart/main.cpp 6 + + Chart is ready to be shown. We set the chart to be central widget of the window. + We also set the size for the chart window and show it. + + \snippet ../examples/stackedbarchart/main.cpp 7 */ + + diff --git a/examples/barchart/main.cpp b/examples/barchart/main.cpp index cae476b..91c6a3f 100644 --- a/examples/barchart/main.cpp +++ b/examples/barchart/main.cpp @@ -60,7 +60,6 @@ int main(int argc, char *argv[]) QChart* chart = new QChart(); chart->addSeries(series); chart->setTitle("Simple barchart example"); - chart->createDefaultAxes(); //![3] //![4] @@ -68,6 +67,7 @@ int main(int argc, char *argv[]) categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; QBarCategoryAxis* axis = new QBarCategoryAxis(); axis->append(categories); + chart->createDefaultAxes(); chart->setAxisX(axis,series); //![4] diff --git a/examples/horizontalbarchart/main.cpp b/examples/horizontalbarchart/main.cpp index 9ac5693..48bb5fd 100644 --- a/examples/horizontalbarchart/main.cpp +++ b/examples/horizontalbarchart/main.cpp @@ -54,14 +54,12 @@ int main(int argc, char *argv[]) series->append(set2); series->append(set3); series->append(set4); - //![2] //![3] QChart* chart = new QChart(); chart->addSeries(series); chart->setTitle("Simple horizontal barchart example"); - chart->createDefaultAxes(); chart->setAnimationOptions(QChart::SeriesAnimations); //![3] @@ -70,6 +68,7 @@ int main(int argc, char *argv[]) categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; QBarCategoryAxis* axis = new QBarCategoryAxis(); axis->append(categories); + chart->createDefaultAxes(); chart->setAxisY(axis,series); //![4] diff --git a/examples/horizontalpercentbarchart/main.cpp b/examples/horizontalpercentbarchart/main.cpp index 0972cc7..e2af62a 100644 --- a/examples/horizontalpercentbarchart/main.cpp +++ b/examples/horizontalpercentbarchart/main.cpp @@ -61,7 +61,6 @@ int main(int argc, char *argv[]) QChart* chart = new QChart(); chart->addSeries(series); chart->setTitle("Simple horizontal percent barchart example"); - chart->createDefaultAxes(); chart->setAnimationOptions(QChart::SeriesAnimations); //![3] diff --git a/examples/horizontalstackedbarchart/main.cpp b/examples/horizontalstackedbarchart/main.cpp index e03839a..80dd03d 100644 --- a/examples/horizontalstackedbarchart/main.cpp +++ b/examples/horizontalstackedbarchart/main.cpp @@ -61,7 +61,6 @@ int main(int argc, char *argv[]) QChart* chart = new QChart(); chart->addSeries(series); chart->setTitle("Simple horizontal stacked barchart example"); - chart->createDefaultAxes(); chart->setAnimationOptions(QChart::SeriesAnimations); //![3] diff --git a/examples/stackedbarchart/main.cpp b/examples/stackedbarchart/main.cpp index 292e486..d2774ce 100644 --- a/examples/stackedbarchart/main.cpp +++ b/examples/stackedbarchart/main.cpp @@ -59,7 +59,6 @@ int main(int argc, char *argv[]) QChart* chart = new QChart(); chart->addSeries(series); chart->setTitle("Simple stackedbarchart example"); - chart->createDefaultAxes(); //![3] //![4] @@ -67,6 +66,7 @@ int main(int argc, char *argv[]) categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; QBarCategoryAxis* axis = new QBarCategoryAxis(); axis->append(categories); + chart->createDefaultAxes(); chart->setAxisX(axis,series); //![4]