From c544258484ff4fd5d2b88402fbaa5d154b89a3a2 Mon Sep 17 00:00:00 2001 From: Titta Heikkala Date: Tue, 1 Jul 2014 07:10:00 +0300 Subject: Qt Charts project file structure change Charts repository structure is changed to follow the structure of a Qt Add-On module. The task includes following changes: - All macros and definitions named 'commercial' have been renamed. - Compile errors related to QString and qSort usage have been fixed. - Old demos are moved under examples. The QML examples now support only Qt Quick 2.0, the support for Qt Quick 1 is removed. - The QML examples with multiple views are updated so that they are usable also with touch devices. - Unnecessary version checks are removed from examples. - The build stamp has been removed as it was only meant for Charts development purposes and it's no longer needed. Also development build related debug prints are removed as __DATE__ can't be used for all OS thus it doesn't make much sense. - Documentation structure has been updated based on the new module structure. The raw HTML files have been removed. Demos are combined to examples. - Unnecessary .qdocinc files are no longer needed. The content is moved to the corresponding .cpp files. - The Charts widget designer plugin is updated according to the module change. - The test cases updated according to the project structure change. Tests are added also for version 2.0. - cmake modules generation is not needed with Qt 5.4 and Qt Charts so it's disabled. - The new module name and version are updated to the plugin.qmltypes file. Task-number: QTRD-2844, QTRD-3217, QTRD-3218, QTRD-3277, QTRD-3228, QTRD-2526, QTRD-3233, QTRD-3222 Change-Id: Ib7fb26057cde710ffaf6bc780c8bf52a16f45160 Reviewed-by: Miikka Heikkinen --- examples/areachart/areachart.pro | 5 - examples/areachart/main.cpp | 81 ----- examples/barchart/barchart.pro | 6 - examples/barchart/main.cpp | 93 ------ examples/barmodelmapper/barmodelmapper.pro | 16 - examples/barmodelmapper/customtablemodel.cpp | 107 ------ examples/barmodelmapper/customtablemodel.h | 51 --- examples/barmodelmapper/main.cpp | 30 -- examples/barmodelmapper/tablewidget.cpp | 117 ------- examples/barmodelmapper/tablewidget.h | 34 -- examples/boxplotchart/acme_data.txt | 13 - examples/boxplotchart/boxdatareader.cpp | 79 ----- examples/boxplotchart/boxdatareader.h | 43 --- examples/boxplotchart/boxplotchart.pro | 13 - examples/boxplotchart/boxplotdata.qrc | 6 - examples/boxplotchart/boxwhisk_data.txt | 13 - examples/boxplotchart/main.cpp | 105 ------ examples/charts/areachart/areachart.pro | 5 + examples/charts/areachart/main.cpp | 81 +++++ examples/charts/audio/audio.pro | 15 + examples/charts/audio/main.cpp | 31 ++ examples/charts/audio/widget.cpp | 82 +++++ examples/charts/audio/widget.h | 52 +++ examples/charts/audio/xyseriesiodevice.cpp | 57 ++++ examples/charts/audio/xyseriesiodevice.h | 47 +++ examples/charts/barchart/barchart.pro | 6 + examples/charts/barchart/main.cpp | 93 ++++++ examples/charts/barmodelmapper/barmodelmapper.pro | 16 + .../charts/barmodelmapper/customtablemodel.cpp | 107 ++++++ examples/charts/barmodelmapper/customtablemodel.h | 51 +++ examples/charts/barmodelmapper/main.cpp | 30 ++ examples/charts/barmodelmapper/tablewidget.cpp | 112 +++++++ examples/charts/barmodelmapper/tablewidget.h | 34 ++ examples/charts/boxplotchart/acme_data.txt | 13 + examples/charts/boxplotchart/boxdatareader.cpp | 79 +++++ examples/charts/boxplotchart/boxdatareader.h | 43 +++ examples/charts/boxplotchart/boxplotchart.pro | 13 + examples/charts/boxplotchart/boxplotdata.qrc | 6 + examples/charts/boxplotchart/boxwhisk_data.txt | 13 + examples/charts/boxplotchart/main.cpp | 105 ++++++ examples/charts/callout/callout.cpp | 119 +++++++ examples/charts/callout/callout.h | 52 +++ examples/charts/callout/callout.pro | 15 + examples/charts/callout/main.cpp | 31 ++ examples/charts/callout/view.cpp | 123 +++++++ examples/charts/callout/view.h | 59 ++++ examples/charts/chartinteractions/chart.cpp | 101 ++++++ examples/charts/chartinteractions/chart.h | 53 +++ .../charts/chartinteractions/chartinteractions.pro | 11 + examples/charts/chartinteractions/chartview.cpp | 50 +++ examples/charts/chartinteractions/chartview.h | 45 +++ examples/charts/chartinteractions/main.cpp | 74 ++++ examples/charts/charts.pro | 60 ++++ examples/charts/chartthemes/chartthemes.pro | 7 + examples/charts/chartthemes/main.cpp | 35 ++ examples/charts/chartthemes/themewidget.cpp | 372 +++++++++++++++++++++ examples/charts/chartthemes/themewidget.h | 77 +++++ examples/charts/customchart/customchart.pro | 6 + examples/charts/customchart/main.cpp | 131 ++++++++ examples/charts/datetimeaxis/datetimeaxis.pro | 8 + examples/charts/datetimeaxis/main.cpp | 100 ++++++ examples/charts/datetimeaxis/sun_spots.txt | 284 ++++++++++++++++ examples/charts/datetimeaxis/sundata.qrc | 5 + examples/charts/donutbreakdown/donutbreakdown.pro | 12 + .../charts/donutbreakdown/donutbreakdownchart.cpp | 110 ++++++ .../charts/donutbreakdown/donutbreakdownchart.h | 42 +++ examples/charts/donutbreakdown/main.cpp | 77 +++++ examples/charts/donutbreakdown/mainslice.cpp | 57 ++++ examples/charts/donutbreakdown/mainslice.h | 48 +++ examples/charts/donutchart/donutchart.pro | 5 + examples/charts/donutchart/main.cpp | 62 ++++ examples/charts/dynamicspline/chart.cpp | 72 ++++ examples/charts/dynamicspline/chart.h | 56 ++++ examples/charts/dynamicspline/dynamicspline.pro | 7 + examples/charts/dynamicspline/main.cpp | 42 +++ examples/charts/examples.pri | 17 + .../horizontalbarchart/horizontalbarchart.pro | 6 + examples/charts/horizontalbarchart/main.cpp | 96 ++++++ .../horizontalpercentbarchart.pro | 6 + examples/charts/horizontalpercentbarchart/main.cpp | 94 ++++++ .../horizontalstackedbarchart.pro | 6 + examples/charts/horizontalstackedbarchart/main.cpp | 94 ++++++ examples/charts/legend/legend.pro | 10 + examples/charts/legend/main.cpp | 37 ++ examples/charts/legend/mainwidget.cpp | 247 ++++++++++++++ examples/charts/legend/mainwidget.h | 78 +++++ examples/charts/legendmarkers/legendmarkers.pro | 10 + examples/charts/legendmarkers/main.cpp | 35 ++ examples/charts/legendmarkers/mainwidget.cpp | 177 ++++++++++ examples/charts/legendmarkers/mainwidget.h | 62 ++++ examples/charts/lineandbar/lineandbar.pro | 6 + examples/charts/lineandbar/main.cpp | 111 ++++++ examples/charts/linechart/linechart.pro | 5 + examples/charts/linechart/main.cpp | 67 ++++ examples/charts/logvalueaxis/logvalueaxis.pro | 5 + examples/charts/logvalueaxis/main.cpp | 75 +++++ examples/charts/modeldata/customtablemodel.cpp | 110 ++++++ examples/charts/modeldata/customtablemodel.h | 51 +++ examples/charts/modeldata/main.cpp | 30 ++ examples/charts/modeldata/modeldata.pro | 16 + examples/charts/modeldata/tablewidget.cpp | 112 +++++++ examples/charts/modeldata/tablewidget.h | 34 ++ examples/charts/multiaxis/main.cpp | 92 +++++ examples/charts/multiaxis/multiaxis.pro | 5 + examples/charts/nesteddonuts/main.cpp | 29 ++ examples/charts/nesteddonuts/nesteddonuts.pro | 8 + examples/charts/nesteddonuts/widget.cpp | 128 +++++++ examples/charts/nesteddonuts/widget.h | 47 +++ examples/charts/percentbarchart/main.cpp | 93 ++++++ .../charts/percentbarchart/percentbarchart.pro | 6 + examples/charts/piechart/main.cpp | 70 ++++ examples/charts/piechart/piechart.pro | 5 + .../charts/piechartcustomization/brushtool.cpp | 100 ++++++ examples/charts/piechartcustomization/brushtool.h | 53 +++ .../charts/piechartcustomization/customslice.cpp | 48 +++ .../charts/piechartcustomization/customslice.h | 44 +++ examples/charts/piechartcustomization/main.cpp | 34 ++ .../charts/piechartcustomization/mainwidget.cpp | 360 ++++++++++++++++++++ examples/charts/piechartcustomization/mainwidget.h | 93 ++++++ examples/charts/piechartcustomization/pentool.cpp | 141 ++++++++ examples/charts/piechartcustomization/pentool.h | 60 ++++ .../piechartcustomization.pro | 16 + .../charts/piechartdrilldown/drilldownchart.cpp | 54 +++ examples/charts/piechartdrilldown/drilldownchart.h | 47 +++ .../charts/piechartdrilldown/drilldownslice.cpp | 63 ++++ examples/charts/piechartdrilldown/drilldownslice.h | 49 +++ examples/charts/piechartdrilldown/main.cpp | 77 +++++ .../charts/piechartdrilldown/piechartdrilldown.pro | 11 + examples/charts/polarchart/chartview.cpp | 111 ++++++ examples/charts/polarchart/chartview.h | 41 +++ examples/charts/polarchart/main.cpp | 137 ++++++++ examples/charts/polarchart/polarchart.pro | 6 + examples/charts/qmlaxes/main.cpp | 50 +++ examples/charts/qmlaxes/qml/qmlaxes/View1.qml | 68 ++++ examples/charts/qmlaxes/qml/qmlaxes/View2.qml | 60 ++++ examples/charts/qmlaxes/qml/qmlaxes/View3.qml | 68 ++++ examples/charts/qmlaxes/qml/qmlaxes/main.qml | 80 +++++ examples/charts/qmlaxes/qmlaxes.pro | 7 + examples/charts/qmlaxes/resources.qrc | 8 + examples/charts/qmlboxplot/main.cpp | 50 +++ examples/charts/qmlboxplot/qml/qmlboxplot/main.qml | 41 +++ examples/charts/qmlboxplot/qmlboxplot.pro | 9 + examples/charts/qmlboxplot/resources.qrc | 5 + examples/charts/qmlchart/main.cpp | 50 +++ examples/charts/qmlchart/qml/qmlchart/View1.qml | 54 +++ examples/charts/qmlchart/qml/qmlchart/View10.qml | 42 +++ examples/charts/qmlchart/qml/qmlchart/View11.qml | 43 +++ examples/charts/qmlchart/qml/qmlchart/View12.qml | 77 +++++ examples/charts/qmlchart/qml/qmlchart/View2.qml | 45 +++ examples/charts/qmlchart/qml/qmlchart/View3.qml | 45 +++ examples/charts/qmlchart/qml/qmlchart/View4.qml | 108 ++++++ examples/charts/qmlchart/qml/qmlchart/View5.qml | 56 ++++ examples/charts/qmlchart/qml/qmlchart/View6.qml | 43 +++ examples/charts/qmlchart/qml/qmlchart/View7.qml | 43 +++ examples/charts/qmlchart/qml/qmlchart/View8.qml | 42 +++ examples/charts/qmlchart/qml/qmlchart/View9.qml | 43 +++ examples/charts/qmlchart/qml/qmlchart/main.qml | 91 +++++ examples/charts/qmlchart/qmlchart.pro | 7 + examples/charts/qmlchart/resources.qrc | 17 + examples/charts/qmlcustomizations/main.cpp | 49 +++ .../qml/qmlcustomizations/main.qml | 102 ++++++ .../charts/qmlcustomizations/qmlcustomizations.pro | 7 + examples/charts/qmlcustomizations/resources.qrc | 5 + examples/charts/qmlcustomlegend/main.cpp | 49 +++ .../qml/qmlcustomlegend/AnimatedAreaSeries.qml | 30 ++ .../qml/qmlcustomlegend/ChartViewHighlighted.qml | 77 +++++ .../qml/qmlcustomlegend/ChartViewSelector.qml | 100 ++++++ .../qml/qmlcustomlegend/ChartViewStacked.qml | 117 +++++++ .../qml/qmlcustomlegend/CustomLegend.qml | 136 ++++++++ .../qmlcustomlegend/qml/qmlcustomlegend/main.qml | 66 ++++ .../charts/qmlcustomlegend/qmlcustomlegend.pro | 7 + examples/charts/qmlcustomlegend/resources.qrc | 10 + examples/charts/qmlf1legends/main.cpp | 49 +++ .../qmlf1legends/qml/qmlf1legends/SpeedsXml.qml | 95 ++++++ .../charts/qmlf1legends/qml/qmlf1legends/main.qml | 95 ++++++ examples/charts/qmlf1legends/qmlf1legends.pro | 7 + examples/charts/qmlf1legends/resources.qrc | 6 + examples/charts/qmloscilloscope/datasource.cpp | 91 +++++ examples/charts/qmloscilloscope/datasource.h | 49 +++ examples/charts/qmloscilloscope/main.cpp | 56 ++++ .../qml/qmloscilloscope/ControlPanel.qml | 88 +++++ .../qml/qmloscilloscope/MultiButton.qml | 60 ++++ .../qml/qmloscilloscope/ScopeView.qml | 115 +++++++ .../qmloscilloscope/qml/qmloscilloscope/main.qml | 61 ++++ .../charts/qmloscilloscope/qmloscilloscope.pro | 11 + examples/charts/qmloscilloscope/resources.qrc | 8 + examples/charts/qmlpiechart/main.cpp | 49 +++ .../charts/qmlpiechart/qml/qmlpiechart/main.qml | 54 +++ examples/charts/qmlpiechart/qmlpiechart.pro | 7 + examples/charts/qmlpiechart/qmlpiechart.svg | 93 ++++++ examples/charts/qmlpiechart/resources.qrc | 5 + examples/charts/qmlpolarchart/main.cpp | 49 +++ .../qmlpolarchart/qml/qmlpolarchart/View1.qml | 69 ++++ .../qmlpolarchart/qml/qmlpolarchart/View2.qml | 90 +++++ .../qmlpolarchart/qml/qmlpolarchart/View3.qml | 77 +++++ .../qmlpolarchart/qml/qmlpolarchart/main.qml | 80 +++++ examples/charts/qmlpolarchart/qmlpolarchart.pro | 7 + examples/charts/qmlpolarchart/resources.qrc | 8 + examples/charts/qmlweather/main.cpp | 59 ++++ examples/charts/qmlweather/qml/qmlweather/main.qml | 201 +++++++++++ examples/charts/qmlweather/qmlweather.pro | 7 + examples/charts/qmlweather/resources.qrc | 5 + examples/charts/scatterchart/chartview.cpp | 98 ++++++ examples/charts/scatterchart/chartview.h | 35 ++ examples/charts/scatterchart/main.cpp | 40 +++ examples/charts/scatterchart/scatterchart.pro | 9 + examples/charts/scatterinteractions/chartview.cpp | 79 +++++ examples/charts/scatterinteractions/chartview.h | 46 +++ examples/charts/scatterinteractions/main.cpp | 35 ++ .../scatterinteractions/scatterinteractions.pro | 9 + examples/charts/splinechart/main.cpp | 68 ++++ examples/charts/splinechart/splinechart.pro | 5 + examples/charts/stackedbarchart/main.cpp | 93 ++++++ .../charts/stackedbarchart/stackedbarchart.pro | 5 + .../stackedbarchartdrilldown/drilldownchart.cpp | 60 ++++ .../stackedbarchartdrilldown/drilldownchart.h | 46 +++ .../stackedbarchartdrilldown/drilldownseries.cpp | 46 +++ .../stackedbarchartdrilldown/drilldownseries.h | 48 +++ examples/charts/stackedbarchartdrilldown/main.cpp | 113 +++++++ .../stackedbarchartdrilldown.pro | 6 + examples/charts/temperaturerecords/main.cpp | 88 +++++ .../temperaturerecords/temperaturerecords.pro | 6 + examples/charts/zoomlinechart/chart.cpp | 63 ++++ examples/charts/zoomlinechart/chart.h | 48 +++ examples/charts/zoomlinechart/chartview.cpp | 100 ++++++ examples/charts/zoomlinechart/chartview.h | 49 +++ examples/charts/zoomlinechart/main.cpp | 62 ++++ examples/charts/zoomlinechart/zoomlinechart.pro | 7 + examples/customchart/customchart.pro | 6 - examples/customchart/main.cpp | 131 -------- examples/datetimeaxis/datetimeaxis.pro | 8 - examples/datetimeaxis/main.cpp | 100 ------ examples/datetimeaxis/sun_spots.txt | 284 ---------------- examples/datetimeaxis/sundata.qrc | 5 - examples/donutbreakdown/donutbreakdown.pro | 12 - examples/donutbreakdown/donutbreakdownchart.cpp | 110 ------ examples/donutbreakdown/donutbreakdownchart.h | 42 --- examples/donutbreakdown/main.cpp | 77 ----- examples/donutbreakdown/mainslice.cpp | 57 ---- examples/donutbreakdown/mainslice.h | 48 --- examples/donutchart/donutchart.pro | 5 - examples/donutchart/main.cpp | 62 ---- examples/examples.pri | 33 -- examples/examples.pro | 45 +-- examples/horizontalbarchart/horizontalbarchart.pro | 6 - examples/horizontalbarchart/main.cpp | 96 ------ .../horizontalpercentbarchart.pro | 6 - examples/horizontalpercentbarchart/main.cpp | 94 ------ .../horizontalstackedbarchart.pro | 6 - examples/horizontalstackedbarchart/main.cpp | 94 ------ examples/legend/legend.pro | 10 - examples/legend/main.cpp | 37 -- examples/legend/mainwidget.cpp | 247 -------------- examples/legend/mainwidget.h | 78 ----- examples/legendmarkers/legendmarkers.pro | 10 - examples/legendmarkers/main.cpp | 35 -- examples/legendmarkers/mainwidget.cpp | 177 ---------- examples/legendmarkers/mainwidget.h | 62 ---- examples/lineandbar/lineandbar.pro | 6 - examples/lineandbar/main.cpp | 111 ------ examples/linechart/linechart.pro | 5 - examples/linechart/main.cpp | 67 ---- examples/logvalueaxis/logvalueaxis.pro | 5 - examples/logvalueaxis/main.cpp | 75 ----- examples/modeldata/customtablemodel.cpp | 110 ------ examples/modeldata/customtablemodel.h | 51 --- examples/modeldata/main.cpp | 30 -- examples/modeldata/modeldata.pro | 16 - examples/modeldata/tablewidget.cpp | 117 ------- examples/modeldata/tablewidget.h | 34 -- examples/multiaxis/main.cpp | 92 ----- examples/multiaxis/multiaxis.pro | 5 - examples/percentbarchart/main.cpp | 93 ------ examples/percentbarchart/percentbarchart.pro | 6 - examples/piechart/main.cpp | 70 ---- examples/piechart/piechart.pro | 5 - examples/piechartdrilldown/drilldownchart.cpp | 54 --- examples/piechartdrilldown/drilldownchart.h | 47 --- examples/piechartdrilldown/drilldownslice.cpp | 63 ---- examples/piechartdrilldown/drilldownslice.h | 49 --- examples/piechartdrilldown/main.cpp | 77 ----- examples/piechartdrilldown/piechartdrilldown.pro | 11 - examples/polarchart/chartview.cpp | 111 ------ examples/polarchart/chartview.h | 41 --- examples/polarchart/main.cpp | 137 -------- examples/polarchart/polarchart.pro | 6 - examples/qmlboxplot/main.cpp | 43 --- examples/qmlboxplot/qml/qmlboxplot/main.qml | 40 --- .../qmlapplicationviewer/qmlapplicationviewer.cpp | 177 ---------- .../qmlapplicationviewer/qmlapplicationviewer.h | 46 --- .../qmlapplicationviewer/qmlapplicationviewer.pri | 13 - examples/qmlboxplot/qmlboxplot.pro | 11 - examples/qmlboxplot/resources.qrc | 5 - examples/qmlpiechart/main.cpp | 43 --- examples/qmlpiechart/qml/qmlpiechart/main.qml | 53 --- .../qmlapplicationviewer/qmlapplicationviewer.cpp | 177 ---------- .../qmlapplicationviewer/qmlapplicationviewer.h | 46 --- .../qmlapplicationviewer/qmlapplicationviewer.pri | 13 - examples/qmlpiechart/qmlpiechart.pro | 9 - examples/qmlpiechart/qmlpiechart.svg | 93 ------ examples/qmlpiechart/resources.qrc | 5 - examples/scatterchart/chartview.cpp | 98 ------ examples/scatterchart/chartview.h | 35 -- examples/scatterchart/main.cpp | 40 --- examples/scatterchart/scatterchart.pro | 9 - examples/scatterinteractions/chartview.cpp | 79 ----- examples/scatterinteractions/chartview.h | 46 --- examples/scatterinteractions/main.cpp | 35 -- .../scatterinteractions/scatterinteractions.pro | 9 - examples/splinechart/main.cpp | 68 ---- examples/splinechart/splinechart.pro | 5 - examples/stackedbarchart/main.cpp | 93 ------ examples/stackedbarchart/stackedbarchart.pro | 5 - .../stackedbarchartdrilldown/drilldownchart.cpp | 60 ---- examples/stackedbarchartdrilldown/drilldownchart.h | 46 --- .../stackedbarchartdrilldown/drilldownseries.cpp | 46 --- .../stackedbarchartdrilldown/drilldownseries.h | 48 --- examples/stackedbarchartdrilldown/main.cpp | 113 ------- .../stackedbarchartdrilldown.pro | 6 - examples/temperaturerecords/main.cpp | 88 ----- examples/temperaturerecords/temperaturerecords.pro | 6 - examples/zoomlinechart/chart.cpp | 63 ---- examples/zoomlinechart/chart.h | 48 --- examples/zoomlinechart/chartview.cpp | 100 ------ examples/zoomlinechart/chartview.h | 49 --- examples/zoomlinechart/main.cpp | 62 ---- examples/zoomlinechart/zoomlinechart.pro | 7 - 327 files changed, 12047 insertions(+), 6326 deletions(-) delete mode 100644 examples/areachart/areachart.pro delete mode 100644 examples/areachart/main.cpp delete mode 100644 examples/barchart/barchart.pro delete mode 100644 examples/barchart/main.cpp delete mode 100644 examples/barmodelmapper/barmodelmapper.pro delete mode 100644 examples/barmodelmapper/customtablemodel.cpp delete mode 100644 examples/barmodelmapper/customtablemodel.h delete mode 100644 examples/barmodelmapper/main.cpp delete mode 100644 examples/barmodelmapper/tablewidget.cpp delete mode 100644 examples/barmodelmapper/tablewidget.h delete mode 100644 examples/boxplotchart/acme_data.txt delete mode 100644 examples/boxplotchart/boxdatareader.cpp delete mode 100644 examples/boxplotchart/boxdatareader.h delete mode 100644 examples/boxplotchart/boxplotchart.pro delete mode 100644 examples/boxplotchart/boxplotdata.qrc delete mode 100644 examples/boxplotchart/boxwhisk_data.txt delete mode 100644 examples/boxplotchart/main.cpp create mode 100644 examples/charts/areachart/areachart.pro create mode 100644 examples/charts/areachart/main.cpp create mode 100644 examples/charts/audio/audio.pro create mode 100644 examples/charts/audio/main.cpp create mode 100644 examples/charts/audio/widget.cpp create mode 100644 examples/charts/audio/widget.h create mode 100644 examples/charts/audio/xyseriesiodevice.cpp create mode 100644 examples/charts/audio/xyseriesiodevice.h create mode 100644 examples/charts/barchart/barchart.pro create mode 100644 examples/charts/barchart/main.cpp create mode 100644 examples/charts/barmodelmapper/barmodelmapper.pro create mode 100644 examples/charts/barmodelmapper/customtablemodel.cpp create mode 100644 examples/charts/barmodelmapper/customtablemodel.h create mode 100644 examples/charts/barmodelmapper/main.cpp create mode 100644 examples/charts/barmodelmapper/tablewidget.cpp create mode 100644 examples/charts/barmodelmapper/tablewidget.h create mode 100644 examples/charts/boxplotchart/acme_data.txt create mode 100644 examples/charts/boxplotchart/boxdatareader.cpp create mode 100644 examples/charts/boxplotchart/boxdatareader.h create mode 100644 examples/charts/boxplotchart/boxplotchart.pro create mode 100644 examples/charts/boxplotchart/boxplotdata.qrc create mode 100644 examples/charts/boxplotchart/boxwhisk_data.txt create mode 100644 examples/charts/boxplotchart/main.cpp create mode 100644 examples/charts/callout/callout.cpp create mode 100644 examples/charts/callout/callout.h create mode 100644 examples/charts/callout/callout.pro create mode 100644 examples/charts/callout/main.cpp create mode 100644 examples/charts/callout/view.cpp create mode 100644 examples/charts/callout/view.h create mode 100644 examples/charts/chartinteractions/chart.cpp create mode 100644 examples/charts/chartinteractions/chart.h create mode 100644 examples/charts/chartinteractions/chartinteractions.pro create mode 100644 examples/charts/chartinteractions/chartview.cpp create mode 100644 examples/charts/chartinteractions/chartview.h create mode 100644 examples/charts/chartinteractions/main.cpp create mode 100644 examples/charts/charts.pro create mode 100644 examples/charts/chartthemes/chartthemes.pro create mode 100644 examples/charts/chartthemes/main.cpp create mode 100644 examples/charts/chartthemes/themewidget.cpp create mode 100644 examples/charts/chartthemes/themewidget.h create mode 100644 examples/charts/customchart/customchart.pro create mode 100644 examples/charts/customchart/main.cpp create mode 100644 examples/charts/datetimeaxis/datetimeaxis.pro create mode 100644 examples/charts/datetimeaxis/main.cpp create mode 100644 examples/charts/datetimeaxis/sun_spots.txt create mode 100644 examples/charts/datetimeaxis/sundata.qrc create mode 100644 examples/charts/donutbreakdown/donutbreakdown.pro create mode 100644 examples/charts/donutbreakdown/donutbreakdownchart.cpp create mode 100644 examples/charts/donutbreakdown/donutbreakdownchart.h create mode 100644 examples/charts/donutbreakdown/main.cpp create mode 100644 examples/charts/donutbreakdown/mainslice.cpp create mode 100644 examples/charts/donutbreakdown/mainslice.h create mode 100644 examples/charts/donutchart/donutchart.pro create mode 100644 examples/charts/donutchart/main.cpp create mode 100644 examples/charts/dynamicspline/chart.cpp create mode 100644 examples/charts/dynamicspline/chart.h create mode 100644 examples/charts/dynamicspline/dynamicspline.pro create mode 100644 examples/charts/dynamicspline/main.cpp create mode 100644 examples/charts/examples.pri create mode 100644 examples/charts/horizontalbarchart/horizontalbarchart.pro create mode 100644 examples/charts/horizontalbarchart/main.cpp create mode 100644 examples/charts/horizontalpercentbarchart/horizontalpercentbarchart.pro create mode 100644 examples/charts/horizontalpercentbarchart/main.cpp create mode 100644 examples/charts/horizontalstackedbarchart/horizontalstackedbarchart.pro create mode 100644 examples/charts/horizontalstackedbarchart/main.cpp create mode 100644 examples/charts/legend/legend.pro create mode 100644 examples/charts/legend/main.cpp create mode 100644 examples/charts/legend/mainwidget.cpp create mode 100644 examples/charts/legend/mainwidget.h create mode 100644 examples/charts/legendmarkers/legendmarkers.pro create mode 100644 examples/charts/legendmarkers/main.cpp create mode 100644 examples/charts/legendmarkers/mainwidget.cpp create mode 100644 examples/charts/legendmarkers/mainwidget.h create mode 100644 examples/charts/lineandbar/lineandbar.pro create mode 100644 examples/charts/lineandbar/main.cpp create mode 100644 examples/charts/linechart/linechart.pro create mode 100644 examples/charts/linechart/main.cpp create mode 100644 examples/charts/logvalueaxis/logvalueaxis.pro create mode 100644 examples/charts/logvalueaxis/main.cpp create mode 100644 examples/charts/modeldata/customtablemodel.cpp create mode 100644 examples/charts/modeldata/customtablemodel.h create mode 100644 examples/charts/modeldata/main.cpp create mode 100644 examples/charts/modeldata/modeldata.pro create mode 100644 examples/charts/modeldata/tablewidget.cpp create mode 100644 examples/charts/modeldata/tablewidget.h create mode 100644 examples/charts/multiaxis/main.cpp create mode 100644 examples/charts/multiaxis/multiaxis.pro create mode 100644 examples/charts/nesteddonuts/main.cpp create mode 100644 examples/charts/nesteddonuts/nesteddonuts.pro create mode 100644 examples/charts/nesteddonuts/widget.cpp create mode 100644 examples/charts/nesteddonuts/widget.h create mode 100644 examples/charts/percentbarchart/main.cpp create mode 100644 examples/charts/percentbarchart/percentbarchart.pro create mode 100644 examples/charts/piechart/main.cpp create mode 100644 examples/charts/piechart/piechart.pro create mode 100644 examples/charts/piechartcustomization/brushtool.cpp create mode 100644 examples/charts/piechartcustomization/brushtool.h create mode 100644 examples/charts/piechartcustomization/customslice.cpp create mode 100644 examples/charts/piechartcustomization/customslice.h create mode 100644 examples/charts/piechartcustomization/main.cpp create mode 100644 examples/charts/piechartcustomization/mainwidget.cpp create mode 100644 examples/charts/piechartcustomization/mainwidget.h create mode 100644 examples/charts/piechartcustomization/pentool.cpp create mode 100644 examples/charts/piechartcustomization/pentool.h create mode 100644 examples/charts/piechartcustomization/piechartcustomization.pro create mode 100644 examples/charts/piechartdrilldown/drilldownchart.cpp create mode 100644 examples/charts/piechartdrilldown/drilldownchart.h create mode 100644 examples/charts/piechartdrilldown/drilldownslice.cpp create mode 100644 examples/charts/piechartdrilldown/drilldownslice.h create mode 100644 examples/charts/piechartdrilldown/main.cpp create mode 100644 examples/charts/piechartdrilldown/piechartdrilldown.pro create mode 100644 examples/charts/polarchart/chartview.cpp create mode 100644 examples/charts/polarchart/chartview.h create mode 100644 examples/charts/polarchart/main.cpp create mode 100644 examples/charts/polarchart/polarchart.pro create mode 100644 examples/charts/qmlaxes/main.cpp create mode 100644 examples/charts/qmlaxes/qml/qmlaxes/View1.qml create mode 100644 examples/charts/qmlaxes/qml/qmlaxes/View2.qml create mode 100644 examples/charts/qmlaxes/qml/qmlaxes/View3.qml create mode 100644 examples/charts/qmlaxes/qml/qmlaxes/main.qml create mode 100644 examples/charts/qmlaxes/qmlaxes.pro create mode 100644 examples/charts/qmlaxes/resources.qrc create mode 100644 examples/charts/qmlboxplot/main.cpp create mode 100644 examples/charts/qmlboxplot/qml/qmlboxplot/main.qml create mode 100644 examples/charts/qmlboxplot/qmlboxplot.pro create mode 100644 examples/charts/qmlboxplot/resources.qrc create mode 100644 examples/charts/qmlchart/main.cpp create mode 100644 examples/charts/qmlchart/qml/qmlchart/View1.qml create mode 100644 examples/charts/qmlchart/qml/qmlchart/View10.qml create mode 100644 examples/charts/qmlchart/qml/qmlchart/View11.qml create mode 100644 examples/charts/qmlchart/qml/qmlchart/View12.qml create mode 100644 examples/charts/qmlchart/qml/qmlchart/View2.qml create mode 100644 examples/charts/qmlchart/qml/qmlchart/View3.qml create mode 100644 examples/charts/qmlchart/qml/qmlchart/View4.qml create mode 100644 examples/charts/qmlchart/qml/qmlchart/View5.qml create mode 100644 examples/charts/qmlchart/qml/qmlchart/View6.qml create mode 100644 examples/charts/qmlchart/qml/qmlchart/View7.qml create mode 100644 examples/charts/qmlchart/qml/qmlchart/View8.qml create mode 100644 examples/charts/qmlchart/qml/qmlchart/View9.qml create mode 100644 examples/charts/qmlchart/qml/qmlchart/main.qml create mode 100644 examples/charts/qmlchart/qmlchart.pro create mode 100644 examples/charts/qmlchart/resources.qrc create mode 100644 examples/charts/qmlcustomizations/main.cpp create mode 100644 examples/charts/qmlcustomizations/qml/qmlcustomizations/main.qml create mode 100644 examples/charts/qmlcustomizations/qmlcustomizations.pro create mode 100644 examples/charts/qmlcustomizations/resources.qrc create mode 100644 examples/charts/qmlcustomlegend/main.cpp create mode 100644 examples/charts/qmlcustomlegend/qml/qmlcustomlegend/AnimatedAreaSeries.qml create mode 100644 examples/charts/qmlcustomlegend/qml/qmlcustomlegend/ChartViewHighlighted.qml create mode 100644 examples/charts/qmlcustomlegend/qml/qmlcustomlegend/ChartViewSelector.qml create mode 100644 examples/charts/qmlcustomlegend/qml/qmlcustomlegend/ChartViewStacked.qml create mode 100644 examples/charts/qmlcustomlegend/qml/qmlcustomlegend/CustomLegend.qml create mode 100644 examples/charts/qmlcustomlegend/qml/qmlcustomlegend/main.qml create mode 100644 examples/charts/qmlcustomlegend/qmlcustomlegend.pro create mode 100644 examples/charts/qmlcustomlegend/resources.qrc create mode 100644 examples/charts/qmlf1legends/main.cpp create mode 100644 examples/charts/qmlf1legends/qml/qmlf1legends/SpeedsXml.qml create mode 100644 examples/charts/qmlf1legends/qml/qmlf1legends/main.qml create mode 100644 examples/charts/qmlf1legends/qmlf1legends.pro create mode 100644 examples/charts/qmlf1legends/resources.qrc create mode 100644 examples/charts/qmloscilloscope/datasource.cpp create mode 100644 examples/charts/qmloscilloscope/datasource.h create mode 100644 examples/charts/qmloscilloscope/main.cpp create mode 100644 examples/charts/qmloscilloscope/qml/qmloscilloscope/ControlPanel.qml create mode 100644 examples/charts/qmloscilloscope/qml/qmloscilloscope/MultiButton.qml create mode 100644 examples/charts/qmloscilloscope/qml/qmloscilloscope/ScopeView.qml create mode 100644 examples/charts/qmloscilloscope/qml/qmloscilloscope/main.qml create mode 100644 examples/charts/qmloscilloscope/qmloscilloscope.pro create mode 100644 examples/charts/qmloscilloscope/resources.qrc create mode 100644 examples/charts/qmlpiechart/main.cpp create mode 100644 examples/charts/qmlpiechart/qml/qmlpiechart/main.qml create mode 100644 examples/charts/qmlpiechart/qmlpiechart.pro create mode 100644 examples/charts/qmlpiechart/qmlpiechart.svg create mode 100644 examples/charts/qmlpiechart/resources.qrc create mode 100644 examples/charts/qmlpolarchart/main.cpp create mode 100644 examples/charts/qmlpolarchart/qml/qmlpolarchart/View1.qml create mode 100644 examples/charts/qmlpolarchart/qml/qmlpolarchart/View2.qml create mode 100644 examples/charts/qmlpolarchart/qml/qmlpolarchart/View3.qml create mode 100644 examples/charts/qmlpolarchart/qml/qmlpolarchart/main.qml create mode 100644 examples/charts/qmlpolarchart/qmlpolarchart.pro create mode 100644 examples/charts/qmlpolarchart/resources.qrc create mode 100644 examples/charts/qmlweather/main.cpp create mode 100644 examples/charts/qmlweather/qml/qmlweather/main.qml create mode 100644 examples/charts/qmlweather/qmlweather.pro create mode 100644 examples/charts/qmlweather/resources.qrc create mode 100644 examples/charts/scatterchart/chartview.cpp create mode 100644 examples/charts/scatterchart/chartview.h create mode 100644 examples/charts/scatterchart/main.cpp create mode 100644 examples/charts/scatterchart/scatterchart.pro create mode 100644 examples/charts/scatterinteractions/chartview.cpp create mode 100644 examples/charts/scatterinteractions/chartview.h create mode 100644 examples/charts/scatterinteractions/main.cpp create mode 100644 examples/charts/scatterinteractions/scatterinteractions.pro create mode 100644 examples/charts/splinechart/main.cpp create mode 100644 examples/charts/splinechart/splinechart.pro create mode 100644 examples/charts/stackedbarchart/main.cpp create mode 100644 examples/charts/stackedbarchart/stackedbarchart.pro create mode 100644 examples/charts/stackedbarchartdrilldown/drilldownchart.cpp create mode 100644 examples/charts/stackedbarchartdrilldown/drilldownchart.h create mode 100644 examples/charts/stackedbarchartdrilldown/drilldownseries.cpp create mode 100644 examples/charts/stackedbarchartdrilldown/drilldownseries.h create mode 100644 examples/charts/stackedbarchartdrilldown/main.cpp create mode 100644 examples/charts/stackedbarchartdrilldown/stackedbarchartdrilldown.pro create mode 100644 examples/charts/temperaturerecords/main.cpp create mode 100644 examples/charts/temperaturerecords/temperaturerecords.pro create mode 100644 examples/charts/zoomlinechart/chart.cpp create mode 100644 examples/charts/zoomlinechart/chart.h create mode 100644 examples/charts/zoomlinechart/chartview.cpp create mode 100644 examples/charts/zoomlinechart/chartview.h create mode 100644 examples/charts/zoomlinechart/main.cpp create mode 100644 examples/charts/zoomlinechart/zoomlinechart.pro delete mode 100644 examples/customchart/customchart.pro delete mode 100644 examples/customchart/main.cpp delete mode 100644 examples/datetimeaxis/datetimeaxis.pro delete mode 100644 examples/datetimeaxis/main.cpp delete mode 100644 examples/datetimeaxis/sun_spots.txt delete mode 100644 examples/datetimeaxis/sundata.qrc delete mode 100644 examples/donutbreakdown/donutbreakdown.pro delete mode 100644 examples/donutbreakdown/donutbreakdownchart.cpp delete mode 100644 examples/donutbreakdown/donutbreakdownchart.h delete mode 100644 examples/donutbreakdown/main.cpp delete mode 100644 examples/donutbreakdown/mainslice.cpp delete mode 100644 examples/donutbreakdown/mainslice.h delete mode 100644 examples/donutchart/donutchart.pro delete mode 100644 examples/donutchart/main.cpp delete mode 100644 examples/examples.pri delete mode 100644 examples/horizontalbarchart/horizontalbarchart.pro delete mode 100644 examples/horizontalbarchart/main.cpp delete mode 100644 examples/horizontalpercentbarchart/horizontalpercentbarchart.pro delete mode 100644 examples/horizontalpercentbarchart/main.cpp delete mode 100644 examples/horizontalstackedbarchart/horizontalstackedbarchart.pro delete mode 100644 examples/horizontalstackedbarchart/main.cpp delete mode 100644 examples/legend/legend.pro delete mode 100644 examples/legend/main.cpp delete mode 100644 examples/legend/mainwidget.cpp delete mode 100644 examples/legend/mainwidget.h delete mode 100644 examples/legendmarkers/legendmarkers.pro delete mode 100644 examples/legendmarkers/main.cpp delete mode 100644 examples/legendmarkers/mainwidget.cpp delete mode 100644 examples/legendmarkers/mainwidget.h delete mode 100644 examples/lineandbar/lineandbar.pro delete mode 100644 examples/lineandbar/main.cpp delete mode 100644 examples/linechart/linechart.pro delete mode 100644 examples/linechart/main.cpp delete mode 100644 examples/logvalueaxis/logvalueaxis.pro delete mode 100644 examples/logvalueaxis/main.cpp delete mode 100644 examples/modeldata/customtablemodel.cpp delete mode 100644 examples/modeldata/customtablemodel.h delete mode 100644 examples/modeldata/main.cpp delete mode 100644 examples/modeldata/modeldata.pro delete mode 100644 examples/modeldata/tablewidget.cpp delete mode 100644 examples/modeldata/tablewidget.h delete mode 100644 examples/multiaxis/main.cpp delete mode 100644 examples/multiaxis/multiaxis.pro delete mode 100644 examples/percentbarchart/main.cpp delete mode 100644 examples/percentbarchart/percentbarchart.pro delete mode 100644 examples/piechart/main.cpp delete mode 100644 examples/piechart/piechart.pro delete mode 100644 examples/piechartdrilldown/drilldownchart.cpp delete mode 100644 examples/piechartdrilldown/drilldownchart.h delete mode 100644 examples/piechartdrilldown/drilldownslice.cpp delete mode 100644 examples/piechartdrilldown/drilldownslice.h delete mode 100644 examples/piechartdrilldown/main.cpp delete mode 100644 examples/piechartdrilldown/piechartdrilldown.pro delete mode 100644 examples/polarchart/chartview.cpp delete mode 100644 examples/polarchart/chartview.h delete mode 100644 examples/polarchart/main.cpp delete mode 100644 examples/polarchart/polarchart.pro delete mode 100644 examples/qmlboxplot/main.cpp delete mode 100644 examples/qmlboxplot/qml/qmlboxplot/main.qml delete mode 100644 examples/qmlboxplot/qmlapplicationviewer/qmlapplicationviewer.cpp delete mode 100644 examples/qmlboxplot/qmlapplicationviewer/qmlapplicationviewer.h delete mode 100644 examples/qmlboxplot/qmlapplicationviewer/qmlapplicationviewer.pri delete mode 100644 examples/qmlboxplot/qmlboxplot.pro delete mode 100644 examples/qmlboxplot/resources.qrc delete mode 100644 examples/qmlpiechart/main.cpp delete mode 100644 examples/qmlpiechart/qml/qmlpiechart/main.qml delete mode 100644 examples/qmlpiechart/qmlapplicationviewer/qmlapplicationviewer.cpp delete mode 100644 examples/qmlpiechart/qmlapplicationviewer/qmlapplicationviewer.h delete mode 100644 examples/qmlpiechart/qmlapplicationviewer/qmlapplicationviewer.pri delete mode 100644 examples/qmlpiechart/qmlpiechart.pro delete mode 100644 examples/qmlpiechart/qmlpiechart.svg delete mode 100644 examples/qmlpiechart/resources.qrc delete mode 100644 examples/scatterchart/chartview.cpp delete mode 100644 examples/scatterchart/chartview.h delete mode 100644 examples/scatterchart/main.cpp delete mode 100644 examples/scatterchart/scatterchart.pro delete mode 100644 examples/scatterinteractions/chartview.cpp delete mode 100644 examples/scatterinteractions/chartview.h delete mode 100644 examples/scatterinteractions/main.cpp delete mode 100644 examples/scatterinteractions/scatterinteractions.pro delete mode 100644 examples/splinechart/main.cpp delete mode 100644 examples/splinechart/splinechart.pro delete mode 100644 examples/stackedbarchart/main.cpp delete mode 100644 examples/stackedbarchart/stackedbarchart.pro delete mode 100644 examples/stackedbarchartdrilldown/drilldownchart.cpp delete mode 100644 examples/stackedbarchartdrilldown/drilldownchart.h delete mode 100644 examples/stackedbarchartdrilldown/drilldownseries.cpp delete mode 100644 examples/stackedbarchartdrilldown/drilldownseries.h delete mode 100644 examples/stackedbarchartdrilldown/main.cpp delete mode 100644 examples/stackedbarchartdrilldown/stackedbarchartdrilldown.pro delete mode 100644 examples/temperaturerecords/main.cpp delete mode 100644 examples/temperaturerecords/temperaturerecords.pro delete mode 100644 examples/zoomlinechart/chart.cpp delete mode 100644 examples/zoomlinechart/chart.h delete mode 100644 examples/zoomlinechart/chartview.cpp delete mode 100644 examples/zoomlinechart/chartview.h delete mode 100644 examples/zoomlinechart/main.cpp delete mode 100644 examples/zoomlinechart/zoomlinechart.pro (limited to 'examples') diff --git a/examples/areachart/areachart.pro b/examples/areachart/areachart.pro deleted file mode 100644 index e8e1a074..00000000 --- a/examples/areachart/areachart.pro +++ /dev/null @@ -1,5 +0,0 @@ -!include( ../examples.pri ) { - error( "Couldn't find the examples.pri file!" ) -} -TARGET = areachart -SOURCES += main.cpp diff --git a/examples/areachart/main.cpp b/examples/areachart/main.cpp deleted file mode 100644 index e860ea18..00000000 --- a/examples/areachart/main.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include - -QTCOMMERCIALCHART_USE_NAMESPACE - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - -//![1] - QLineSeries *series0 = new QLineSeries(); - QLineSeries *series1 = new QLineSeries(); -//![1] - -//![2] - *series0 << QPointF(1, 5) << QPointF(3, 7) << QPointF(7, 6) << QPointF(9, 7) << QPointF(12, 6) - << QPointF(16, 7) << QPointF(18, 5); - *series1 << QPointF(1, 3) << QPointF(3, 4) << QPointF(7, 3) << QPointF(8, 2) << QPointF(12, 3) - << QPointF(16, 4) << QPointF(18, 3); -//![2] - -//![3] - QAreaSeries *series = new QAreaSeries(series0, series1); - series->setName("Batman"); - QPen pen(0x059605); - pen.setWidth(3); - series->setPen(pen); - - QLinearGradient gradient(QPointF(0, 0), QPointF(0, 1)); - gradient.setColorAt(0.0, 0x3cc63c); - gradient.setColorAt(1.0, 0x26f626); - gradient.setCoordinateMode(QGradient::ObjectBoundingMode); - series->setBrush(gradient); -//![3] - -//![4] - QChart *chart = new QChart(); - chart->addSeries(series); - chart->setTitle("Simple areachart example"); - chart->createDefaultAxes(); - chart->axisX()->setRange(0, 20); - chart->axisY()->setRange(0, 10); -//![4] - -//![5] - QChartView *chartView = new QChartView(chart); - chartView->setRenderHint(QPainter::Antialiasing); -//![5] - -//![6] - QMainWindow window; - window.setCentralWidget(chartView); - window.resize(400, 300); - window.show(); -//![6] - - return a.exec(); -} diff --git a/examples/barchart/barchart.pro b/examples/barchart/barchart.pro deleted file mode 100644 index 14db3c88..00000000 --- a/examples/barchart/barchart.pro +++ /dev/null @@ -1,6 +0,0 @@ -!include( ../examples.pri ) { - error( "Couldn't find the examples.pri file!" ) -} - -TARGET = barchart -SOURCES += main.cpp diff --git a/examples/barchart/main.cpp b/examples/barchart/main.cpp deleted file mode 100644 index 001ae2b3..00000000 --- a/examples/barchart/main.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include - -QTCOMMERCIALCHART_USE_NAMESPACE - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - -//![1] - QBarSet *set0 = new QBarSet("Jane"); - QBarSet *set1 = new QBarSet("John"); - QBarSet *set2 = new QBarSet("Axel"); - QBarSet *set3 = new QBarSet("Mary"); - QBarSet *set4 = new QBarSet("Samantha"); - - *set0 << 1 << 2 << 3 << 4 << 5 << 6; - *set1 << 5 << 0 << 0 << 4 << 0 << 7; - *set2 << 3 << 5 << 8 << 13 << 8 << 5; - *set3 << 5 << 6 << 7 << 3 << 4 << 5; - *set4 << 9 << 7 << 5 << 3 << 1 << 2; -//![1] - -//![2] - QBarSeries *series = new QBarSeries(); - series->append(set0); - series->append(set1); - series->append(set2); - series->append(set3); - series->append(set4); - -//![2] - -//![3] - QChart *chart = new QChart(); - chart->addSeries(series); - chart->setTitle("Simple barchart example"); - chart->setAnimationOptions(QChart::SeriesAnimations); -//![3] - -//![4] - QStringList categories; - categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; - QBarCategoryAxis *axis = new QBarCategoryAxis(); - axis->append(categories); - chart->createDefaultAxes(); - chart->setAxisX(axis, series); -//![4] - -//![5] - chart->legend()->setVisible(true); - chart->legend()->setAlignment(Qt::AlignBottom); -//![5] - -//![6] - QChartView *chartView = new QChartView(chart); - chartView->setRenderHint(QPainter::Antialiasing); -//![6] - -//![7] - QMainWindow window; - window.setCentralWidget(chartView); - window.resize(420, 300); - window.show(); -//![7] - - return a.exec(); -} diff --git a/examples/barmodelmapper/barmodelmapper.pro b/examples/barmodelmapper/barmodelmapper.pro deleted file mode 100644 index 91b8f367..00000000 --- a/examples/barmodelmapper/barmodelmapper.pro +++ /dev/null @@ -1,16 +0,0 @@ -!include( ../examples.pri ) { - error( "Couldn't find the examples.pri file!" ) -} - -QT += core gui - -TARGET = barmodelmapper -TEMPLATE = app - - -SOURCES += main.cpp\ - tablewidget.cpp \ - customtablemodel.cpp - -HEADERS += tablewidget.h \ - customtablemodel.h diff --git a/examples/barmodelmapper/customtablemodel.cpp b/examples/barmodelmapper/customtablemodel.cpp deleted file mode 100644 index 3ec58384..00000000 --- a/examples/barmodelmapper/customtablemodel.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "customtablemodel.h" -#include -#include -#include -#include - -CustomTableModel::CustomTableModel(QObject *parent) : - QAbstractTableModel(parent) -{ - qsrand(QTime(0, 0, 0).secsTo(QTime::currentTime())); - - m_columnCount = 6; - m_rowCount = 12; - - // m_data - for (int i = 0; i < m_rowCount; i++) { - QVector* dataVec = new QVector(m_columnCount); - for (int k = 0; k < dataVec->size(); k++) { - if (k % 2 == 0) - dataVec->replace(k, i * 50 + qrand() % 20); - else - dataVec->replace(k, qrand() % 100); - } - m_data.append(dataVec); - } -} - -int CustomTableModel::rowCount(const QModelIndex &parent) const -{ - Q_UNUSED(parent) - return m_data.count(); -} - -int CustomTableModel::columnCount(const QModelIndex &parent) const -{ - Q_UNUSED(parent) - return m_columnCount; -} - -QVariant CustomTableModel::headerData(int section, Qt::Orientation orientation, int role) const -{ - if (role != Qt::DisplayRole) - return QVariant(); - - if (orientation == Qt::Horizontal) - return QString("201%1").arg(section); - else - return QString("%1").arg(section + 1); -} - -QVariant CustomTableModel::data(const QModelIndex &index, int role) const -{ - if (role == Qt::DisplayRole) { - return m_data[index.row()]->at(index.column()); - } else if (role == Qt::EditRole) { - return m_data[index.row()]->at(index.column()); - } else if (role == Qt::BackgroundRole) { - QRect rect; - foreach (rect, m_mapping) - if (rect.contains(index.column(), index.row())) - return QColor(m_mapping.key(rect)); - - // cell not mapped return white color - return QColor(Qt::white); - } - return QVariant(); -} - -bool CustomTableModel::setData(const QModelIndex &index, const QVariant &value, int role) -{ - if (index.isValid() && role == Qt::EditRole) { - m_data[index.row()]->replace(index.column(), value.toDouble()); - emit dataChanged(index, index); - return true; - } - return false; -} - -Qt::ItemFlags CustomTableModel::flags(const QModelIndex &index) const -{ - return QAbstractItemModel::flags(index) | Qt::ItemIsEditable; -} - -void CustomTableModel::addMapping(QString color, QRect area) -{ - m_mapping.insertMulti(color, area); -} diff --git a/examples/barmodelmapper/customtablemodel.h b/examples/barmodelmapper/customtablemodel.h deleted file mode 100644 index 755f4c7d..00000000 --- a/examples/barmodelmapper/customtablemodel.h +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef CUSTOMTABLEMODEL_H -#define CUSTOMTABLEMODEL_H - -#include -#include -#include - -class CustomTableModel : public QAbstractTableModel -{ - Q_OBJECT -public: - explicit CustomTableModel(QObject *parent = 0); - - int rowCount(const QModelIndex &parent = QModelIndex()) const; - int columnCount(const QModelIndex &parent = QModelIndex()) const; - QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; - bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); - Qt::ItemFlags flags(const QModelIndex &index) const; - - void addMapping(QString color, QRect area); - void clearMapping() { m_mapping.clear(); } - -private: - QList * > m_data; - QHash m_mapping; - int m_columnCount; - int m_rowCount; -}; - -#endif // CUSTOMTABLEMODEL_H diff --git a/examples/barmodelmapper/main.cpp b/examples/barmodelmapper/main.cpp deleted file mode 100644 index bf0b384b..00000000 --- a/examples/barmodelmapper/main.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include "tablewidget.h" - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - TableWidget w; - w.show(); - return a.exec(); -} diff --git a/examples/barmodelmapper/tablewidget.cpp b/examples/barmodelmapper/tablewidget.cpp deleted file mode 100644 index f31bfff9..00000000 --- a/examples/barmodelmapper/tablewidget.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "tablewidget.h" -#include "customtablemodel.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -QTCOMMERCIALCHART_USE_NAMESPACE - -TableWidget::TableWidget(QWidget *parent) - : QWidget(parent) -{ - // create simple model for storing data - // user's table data model - //! [1] - CustomTableModel *model = new CustomTableModel; - //! [1] - - //! [2] - // create table view and add model to it - QTableView *tableView = new QTableView; - tableView->setModel(model); - tableView->setMinimumWidth(300); -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) - tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); - tableView->verticalHeader()->setSectionResizeMode(QHeaderView::Stretch); -#else - tableView->horizontalHeader()->setResizeMode(QHeaderView::Stretch); - tableView->verticalHeader()->setResizeMode(QHeaderView::Stretch); -#endif - //! [2] - - //! [3] - QChart *chart = new QChart; - chart->setAnimationOptions(QChart::AllAnimations); - //! [3] - - // series 1 - //! [4] - QBarSeries *series = new QBarSeries; - - int first = 3; - int count = 5; - QVBarModelMapper *mapper = new QVBarModelMapper(this); - mapper->setFirstBarSetColumn(1); - mapper->setLastBarSetColumn(4); - mapper->setFirstRow(first); - mapper->setRowCount(count); - mapper->setSeries(series); - mapper->setModel(model); - chart->addSeries(series); - //! [4] - - //! [5] - // for storing color hex from the series - QString seriesColorHex = "#000000"; - - // get the color of the series and use it for showing the mapped area - QList barsets = series->barSets(); - for (int i = 0; i < barsets.count(); i++) { - seriesColorHex = "#" + QString::number(barsets.at(i)->brush().color().rgb(), 16).right(6).toUpper(); - model->addMapping(seriesColorHex, QRect(1 + i, first, 1, barsets.at(i)->count())); - } - //! [5] - - //! [6] - QStringList categories; - categories << "April" << "May" << "June" << "July" << "August"; - QBarCategoryAxis *axis = new QBarCategoryAxis(); - axis->append(categories); - chart->createDefaultAxes(); - chart->setAxisX(axis, series); - //! [6] - - //! [7] - QChartView *chartView = new QChartView(chart); - chartView->setRenderHint(QPainter::Antialiasing); - chartView->setMinimumSize(640, 480); - //! [7] - - //! [8] - // create main layout - QGridLayout *mainLayout = new QGridLayout; - mainLayout->addWidget(tableView, 1, 0); - mainLayout->addWidget(chartView, 1, 1); - mainLayout->setColumnStretch(1, 1); - mainLayout->setColumnStretch(0, 0); - setLayout(mainLayout); - //! [8] -} diff --git a/examples/barmodelmapper/tablewidget.h b/examples/barmodelmapper/tablewidget.h deleted file mode 100644 index 3846cc11..00000000 --- a/examples/barmodelmapper/tablewidget.h +++ /dev/null @@ -1,34 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef TABLEWIDGET_H -#define TABLEWIDGET_H - -#include - -class TableWidget : public QWidget -{ - Q_OBJECT - -public: - TableWidget(QWidget *parent = 0); -}; - -#endif // TABLEWIDGET_H diff --git a/examples/boxplotchart/acme_data.txt b/examples/boxplotchart/acme_data.txt deleted file mode 100644 index 9511418d..00000000 --- a/examples/boxplotchart/acme_data.txt +++ /dev/null @@ -1,13 +0,0 @@ -# Acme Ltd share deviation in 2012 -Jan 27.74 27.28 27.86 28.05 28.64 27.47 28.30 28.22 28.72 26.50 26.62 26.50 26.15 26.47 26.41 25.78 24.82 24.89 24.88 24.60 23.85 -Feb 31.79 30.62 30.67 31.37 31.16 31.22 32.02 32.70 31.60 31.24 30.98 30.79 31.10 30.79 31.53 30.92 30.00 30.58 30.37 29.40 28.60 -Mar 28.64 28.34 29.13 29.43 30.75 29.77 29.72 30.52 31.12 33.05 32.51 32.69 31.83 32.47 31.41 31.39 31.78 30.08 29.46 31.58 31.39 31.41 -Apr 25.96 26.62 26.19 30.37 28.78 27.50 28.90 28.40 28.86 28.90 27.91 27.32 27.99 26.86 26.68 27.57 27.50 28.96 28.50 -May 20.85 21.08 21.98 21.61 21.45 21.73 21.71 22.27 21.14 20.65 21.95 22.23 23.17 24.26 24.17 22.97 23.53 24.49 24.51 25.46 25.65 -Jun 18.08 17.19 17.36 17.21 17.31 18.19 18.30 17.53 17.35 17.80 17.17 16.95 18.25 20.52 20.61 21.40 20.45 19.43 19.11 19.74 -Jul 17.75 18.24 17.57 16.53 15.98 16.06 16.64 17.69 17.91 18.00 18.03 18.14 18.10 17.86 18.12 18.53 18.43 18.30 19.03 18.76 18.79 18.33 -Aug 18.69 18.54 18.39 18.49 18.96 18.72 19.25 19.70 20.13 19.74 19.27 18.25 17.72 18.02 18.20 18.24 18.60 18.22 18.60 17.98 17.27 16.70 17.19 -Sep 18.35 18.82 18.96 19.96 19.75 20.55 20.68 21.19 21.14 21.48 21.45 20.74 20.97 20.18 19.66 19.54 18.89 18.39 18.26 18.86 -Oct 16.95 16.80 16.45 16.89 17.38 17.12 16.85 17.59 17.65 17.46 17.43 17.30 17.87 18.61 18.55 18.59 19.27 19.54 20.02 19.23 18.05 18.52 18.71 -Now 19.36 19.29 18.22 18.74 19.05 19.13 18.67 18.19 17.94 18.04 17.49 17.53 17.64 18.00 18.21 18.19 18.30 18.11 18.17 17.76 17.80 17.52 -Dec 19.95 20.19 20.15 20.42 20.39 20.65 20.39 19.86 19.48 19.70 19.94 19.82 20.25 20.21 19.63 19.55 diff --git a/examples/boxplotchart/boxdatareader.cpp b/examples/boxplotchart/boxdatareader.cpp deleted file mode 100644 index ba2d8b3a..00000000 --- a/examples/boxplotchart/boxdatareader.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "boxdatareader.h" - -BoxDataReader::BoxDataReader(QIODevice *device) : - QTextStream(device) -{ -} - -void BoxDataReader::readFile(QIODevice *device) -{ - QTextStream::setDevice(device); -} - -QBoxSet *BoxDataReader::readBox() -{ - //! [1] - QString line = readLine(); - if (line.startsWith("#")) - return 0; - //! [1] - - //! [2] - QStringList strList = line.split(" ", QString::SkipEmptyParts); - //! [2] - - //! [3] - sortedList.clear(); - for (int i = 1; i < strList.count(); i++) - sortedList.append(strList.at(i).toDouble()); - - qSort(sortedList.begin(), sortedList.end()); - //! [3] - - int count = sortedList.count(); - - //! [4] - QBoxSet *box = new QBoxSet(strList.first()); - box->setValue(QBoxSet::LowerExtreme, sortedList.first()); - box->setValue(QBoxSet::UpperExtreme, sortedList.last()); - box->setValue(QBoxSet::Median, findMedian(0, count)); - box->setValue(QBoxSet::LowerQuartile, findMedian(0, count / 2)); - box->setValue(QBoxSet::UpperQuartile, findMedian(count / 2 + (count % 2), count)); - //! [4] - - return box; -} - -qreal BoxDataReader::findMedian(int begin, int end) -{ - //! [5] - int count = end - begin; - if (count % 2) { - return sortedList.at(count / 2 + begin); - } else { - qreal right = sortedList.at(count / 2 + begin); - qreal left = sortedList.at(count / 2 - 1 + begin); - return (right + left) / 2.0; - } - //! [5] -} diff --git a/examples/boxplotchart/boxdatareader.h b/examples/boxplotchart/boxdatareader.h deleted file mode 100644 index 8f1e9c51..00000000 --- a/examples/boxplotchart/boxdatareader.h +++ /dev/null @@ -1,43 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef BOXDATAREADER_H -#define BOXDATAREADER_H - -#include -#include - -QTCOMMERCIALCHART_USE_NAMESPACE - -class BoxDataReader : public QTextStream -{ -public: - explicit BoxDataReader(QIODevice *device); - QBoxSet *readBox(); - void readFile(QIODevice *device); - -protected: - qreal findMedian(int begin, int end); - -private: - QList sortedList; -}; - -#endif // BOXDATAREADER_H diff --git a/examples/boxplotchart/boxplotchart.pro b/examples/boxplotchart/boxplotchart.pro deleted file mode 100644 index c2483511..00000000 --- a/examples/boxplotchart/boxplotchart.pro +++ /dev/null @@ -1,13 +0,0 @@ -!include( ../examples.pri ) { - error( "Couldn't find the examples.pri file!" ) -} - -TARGET = boxplotchart -SOURCES += main.cpp \ - boxdatareader.cpp - -RESOURCES += \ - boxplotdata.qrc - -HEADERS += \ - boxdatareader.h diff --git a/examples/boxplotchart/boxplotdata.qrc b/examples/boxplotchart/boxplotdata.qrc deleted file mode 100644 index fe6d52b5..00000000 --- a/examples/boxplotchart/boxplotdata.qrc +++ /dev/null @@ -1,6 +0,0 @@ - - - acme_data.txt - boxwhisk_data.txt - - diff --git a/examples/boxplotchart/boxwhisk_data.txt b/examples/boxplotchart/boxwhisk_data.txt deleted file mode 100644 index f1d49cf0..00000000 --- a/examples/boxplotchart/boxwhisk_data.txt +++ /dev/null @@ -1,13 +0,0 @@ -# BoxWhisk Inc share deviation in 2012 -Jan 25.74 25.28 25.86 26.05 26.64 28.47 28.30 29.22 29.72 27.50 25.62 25.50 25.15 26.47 27.41 25.78 24.82 24.89 24.88 24.60 23.85 -Feb 30.79 29.62 29.67 30.37 30.16 30.22 31.02 33.70 32.60 32.24 31.98 31.79 31.10 30.79 31.53 30.92 29.00 29.58 30.37 29.40 28.60 -Mar 29.64 29.34 30.13 30.43 31.75 30.77 30.72 31.52 32.12 33.75 33.51 33.69 32.83 32.47 32.41 32.39 32.78 31.08 29.46 31.58 31.39 31.41 -Apr 24.96 25.62 25.19 28.37 28.78 26.50 25.90 26.40 26.86 26.90 27.91 27.32 27.99 26.86 26.68 27.57 27.50 26.96 26.50 -May 21.85 21.08 22.98 22.61 22.45 21.73 21.71 23.27 22.14 19.65 22.95 21.23 23.17 24.26 24.17 21.97 22.53 25.49 25.51 26.46 26.65 -Jun 15.08 15.19 15.36 15.21 15.31 18.19 18.30 15.53 15.35 15.80 15.17 16.95 18.25 20.52 20.61 20.40 20.45 19.43 19.11 19.74 -Jul 17.75 18.24 17.57 16.53 15.98 16.06 16.64 17.69 17.91 19.00 19.03 19.14 19.10 17.86 19.12 19.53 19.43 19.30 19.03 19.76 18.79 18.33 -Aug 19.69 19.54 19.39 19.49 19.96 19.72 20.25 20.70 21.13 20.74 20.27 19.25 18.72 19.02 19.20 19.24 19.60 19.22 19.60 18.98 18.27 17.70 18.19 -Sep 19.35 19.82 19.96 20.96 20.75 21.55 21.68 22.19 22.14 22.48 22.45 21.74 21.97 21.18 20.66 20.54 19.89 19.39 19.26 19.86 -Oct 17.95 17.80 17.45 17.89 18.38 18.12 17.85 18.59 18.65 18.46 18.43 18.30 18.87 19.61 19.55 19.59 20.27 20.54 21.02 20.23 19.05 19.52 19.71 -Now 20.36 20.29 19.22 19.74 20.05 20.13 19.67 19.19 18.94 19.04 18.49 18.53 18.64 19.00 19.21 19.19 19.30 19.11 19.17 18.76 18.80 18.52 -Dec 22.95 22.19 22.15 21.42 21.39 21.65 22.39 20.86 20.48 20.70 20.94 20.82 19.25 21.21 19.63 20.55 diff --git a/examples/boxplotchart/main.cpp b/examples/boxplotchart/main.cpp deleted file mode 100644 index 78ce7a54..00000000 --- a/examples/boxplotchart/main.cpp +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "boxdatareader.h" - -QTCOMMERCIALCHART_USE_NAMESPACE - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - - //! [1] - QBoxPlotSeries *acmeSeries = new QBoxPlotSeries(); - acmeSeries->setName("Acme Ltd"); - - QBoxPlotSeries *boxWhiskSeries = new QBoxPlotSeries(); - boxWhiskSeries->setName("BoxWhisk Inc"); - //! [1] - - //! [2] - QFile acmeData(":acme"); - if (!acmeData.open(QIODevice::ReadOnly | QIODevice::Text)) - return 1; - - BoxDataReader dataReader(&acmeData); - while (!dataReader.atEnd()) { - QBoxSet *set = dataReader.readBox(); - if (set) - acmeSeries->append(set); - } - //! [2] - - //! [3] - QFile boxwhiskData(":boxwhisk"); - if (!boxwhiskData.open(QIODevice::ReadOnly | QIODevice::Text)) - return 1; - - dataReader.readFile(&boxwhiskData); - while (!dataReader.atEnd()) { - QBoxSet *set = dataReader.readBox(); - if (set) - boxWhiskSeries->append(set); - } - //! [3] - - //! [4] - QChart *chart = new QChart(); - chart->addSeries(acmeSeries); - chart->addSeries(boxWhiskSeries); - chart->setTitle("Acme Ltd and BoxWhisk Inc share deviation in 2012"); - chart->setAnimationOptions(QChart::SeriesAnimations); - //! [4] - - //! [5] - chart->createDefaultAxes(); - chart->axisY()->setMin(15.0); - chart->axisY()->setMax(34.0); - //! [5] - - //! [6] - chart->legend()->setVisible(true); - chart->legend()->setAlignment(Qt::AlignBottom); - //! [6] - - //! [7] - QChartView *chartView = new QChartView(chart); - chartView->setRenderHint(QPainter::Antialiasing); - //! [7] - - //! [8] - QMainWindow window; - window.setCentralWidget(chartView); - window.resize(800, 600); - window.show(); - //! [8] - - return a.exec(); -} - diff --git a/examples/charts/areachart/areachart.pro b/examples/charts/areachart/areachart.pro new file mode 100644 index 00000000..e8e1a074 --- /dev/null +++ b/examples/charts/areachart/areachart.pro @@ -0,0 +1,5 @@ +!include( ../examples.pri ) { + error( "Couldn't find the examples.pri file!" ) +} +TARGET = areachart +SOURCES += main.cpp diff --git a/examples/charts/areachart/main.cpp b/examples/charts/areachart/main.cpp new file mode 100644 index 00000000..6f2a1cac --- /dev/null +++ b/examples/charts/areachart/main.cpp @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include + +QT_CHARTS_USE_NAMESPACE + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + +//![1] + QLineSeries *series0 = new QLineSeries(); + QLineSeries *series1 = new QLineSeries(); +//![1] + +//![2] + *series0 << QPointF(1, 5) << QPointF(3, 7) << QPointF(7, 6) << QPointF(9, 7) << QPointF(12, 6) + << QPointF(16, 7) << QPointF(18, 5); + *series1 << QPointF(1, 3) << QPointF(3, 4) << QPointF(7, 3) << QPointF(8, 2) << QPointF(12, 3) + << QPointF(16, 4) << QPointF(18, 3); +//![2] + +//![3] + QAreaSeries *series = new QAreaSeries(series0, series1); + series->setName("Batman"); + QPen pen(0x059605); + pen.setWidth(3); + series->setPen(pen); + + QLinearGradient gradient(QPointF(0, 0), QPointF(0, 1)); + gradient.setColorAt(0.0, 0x3cc63c); + gradient.setColorAt(1.0, 0x26f626); + gradient.setCoordinateMode(QGradient::ObjectBoundingMode); + series->setBrush(gradient); +//![3] + +//![4] + QChart *chart = new QChart(); + chart->addSeries(series); + chart->setTitle("Simple areachart example"); + chart->createDefaultAxes(); + chart->axisX()->setRange(0, 20); + chart->axisY()->setRange(0, 10); +//![4] + +//![5] + QChartView *chartView = new QChartView(chart); + chartView->setRenderHint(QPainter::Antialiasing); +//![5] + +//![6] + QMainWindow window; + window.setCentralWidget(chartView); + window.resize(400, 300); + window.show(); +//![6] + + return a.exec(); +} diff --git a/examples/charts/audio/audio.pro b/examples/charts/audio/audio.pro new file mode 100644 index 00000000..6a3b6917 --- /dev/null +++ b/examples/charts/audio/audio.pro @@ -0,0 +1,15 @@ +!include( ../examples.pri ) { + error( "Couldn't find the examples.pri file!" ) +} + +QT += multimedia + +TARGET = audio +TEMPLATE = app + +SOURCES += main.cpp\ + widget.cpp \ + xyseriesiodevice.cpp + +HEADERS += widget.h \ + xyseriesiodevice.h diff --git a/examples/charts/audio/main.cpp b/examples/charts/audio/main.cpp new file mode 100644 index 00000000..dd9069df --- /dev/null +++ b/examples/charts/audio/main.cpp @@ -0,0 +1,31 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include "widget.h" + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + Widget w; + w.show(); + + return a.exec(); +} diff --git a/examples/charts/audio/widget.cpp b/examples/charts/audio/widget.cpp new file mode 100644 index 00000000..6cd5d442 --- /dev/null +++ b/examples/charts/audio/widget.cpp @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "widget.h" +#include +#include +#include +#include +#include +#include +#include +#include "xyseriesiodevice.h" + +QT_CHARTS_USE_NAMESPACE + +Widget::Widget(QWidget *parent) + : QWidget(parent), + m_device(0), + m_chart(0), + m_series(0), + m_audioInput(0) +{ + m_chart = new QChart; + QChartView *chartView = new QChartView(m_chart); + chartView->setMinimumSize(800, 600); + m_series = new QLineSeries; + m_chart->addSeries(m_series); + QValueAxis *axisX = new QValueAxis; + axisX->setRange(0, 2000); + axisX->setLabelFormat("%g"); + axisX->setTitleText("Samples"); + QValueAxis *axisY = new QValueAxis; + axisY->setRange(-1, 1); + axisY->setTitleText("Audio level"); + m_chart->setAxisX(axisX, m_series); + m_chart->setAxisY(axisY, m_series); + m_chart->legend()->hide(); + m_chart->setTitle("Data from the microphone"); + + QVBoxLayout *mainLayout = new QVBoxLayout; + mainLayout->addWidget(chartView); + setLayout(mainLayout); + + QAudioFormat formatAudio; + formatAudio.setSampleRate(8000); + formatAudio.setChannelCount(1); + formatAudio.setSampleSize(8); + formatAudio.setCodec("audio/pcm"); + formatAudio.setByteOrder(QAudioFormat::LittleEndian); + formatAudio.setSampleType(QAudioFormat::UnSignedInt); + + QAudioDeviceInfo inputDevices = QAudioDeviceInfo::defaultInputDevice(); + m_audioInput = new QAudioInput(inputDevices,formatAudio, this); + + m_device = new XYSeriesIODevice(m_series, this); + m_device->open(QIODevice::WriteOnly); + + m_audioInput->start(m_device); +} + +Widget::~Widget() +{ + m_audioInput->stop(); + m_device->close(); +} diff --git a/examples/charts/audio/widget.h b/examples/charts/audio/widget.h new file mode 100644 index 00000000..6f745069 --- /dev/null +++ b/examples/charts/audio/widget.h @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef WIDGET_H +#define WIDGET_H + +#include +#include + +QT_CHARTS_BEGIN_NAMESPACE +class QLineSeries; +class QChart; +QT_CHARTS_END_NAMESPACE + +QT_CHARTS_USE_NAMESPACE + +class XYSeriesIODevice; +class QAudioInput; + +class Widget : public QWidget +{ + Q_OBJECT + +public: + Widget(QWidget *parent = 0); + ~Widget(); + +private: + XYSeriesIODevice *m_device; + QChart *m_chart; + QLineSeries *m_series; + QAudioInput *m_audioInput; +}; + +#endif // WIDGET_H diff --git a/examples/charts/audio/xyseriesiodevice.cpp b/examples/charts/audio/xyseriesiodevice.cpp new file mode 100644 index 00000000..5440771f --- /dev/null +++ b/examples/charts/audio/xyseriesiodevice.cpp @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "xyseriesiodevice.h" +#include + +XYSeriesIODevice::XYSeriesIODevice(QXYSeries * series, QObject *parent) : + QIODevice(parent), + m_series(series) +{ +} + +qint64 XYSeriesIODevice::readData(char * data, qint64 maxSize) +{ + Q_UNUSED(data) + Q_UNUSED(maxSize) + return -1; +} + +qint64 XYSeriesIODevice::writeData(const char * data, qint64 maxSize) +{ + qint64 range = 2000; + QList oldPoints = m_series->points(); + QList points; + int resolution = 4; + + if (oldPoints.count() < range) { + points = m_series->points(); + } else { + for (int i = maxSize/resolution; i < oldPoints.count(); i++) + points.append(QPointF(i - maxSize/resolution, oldPoints.at(i).y())); + } + + qint64 size = points.count(); + for (int k = 0; k < maxSize/resolution; k++) + points.append(QPointF(k + size, ((quint8)data[resolution * k] - 128)/128.0)); + + m_series->replace(points); + return maxSize; +} diff --git a/examples/charts/audio/xyseriesiodevice.h b/examples/charts/audio/xyseriesiodevice.h new file mode 100644 index 00000000..6e504b08 --- /dev/null +++ b/examples/charts/audio/xyseriesiodevice.h @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef XYSERIESIODEVICE_H +#define XYSERIESIODEVICE_H + +#include +#include + +QT_CHARTS_BEGIN_NAMESPACE +class QXYSeries; +QT_CHARTS_END_NAMESPACE + +QT_CHARTS_USE_NAMESPACE + +class XYSeriesIODevice : public QIODevice +{ + Q_OBJECT +public: + explicit XYSeriesIODevice(QXYSeries * series, QObject *parent = 0); + +protected: + qint64 readData(char * data, qint64 maxSize); + qint64 writeData(const char * data, qint64 maxSize); + +private: + QXYSeries *m_series; +}; + +#endif // XYSERIESIODEVICE_H diff --git a/examples/charts/barchart/barchart.pro b/examples/charts/barchart/barchart.pro new file mode 100644 index 00000000..14db3c88 --- /dev/null +++ b/examples/charts/barchart/barchart.pro @@ -0,0 +1,6 @@ +!include( ../examples.pri ) { + error( "Couldn't find the examples.pri file!" ) +} + +TARGET = barchart +SOURCES += main.cpp diff --git a/examples/charts/barchart/main.cpp b/examples/charts/barchart/main.cpp new file mode 100644 index 00000000..a0e3cd89 --- /dev/null +++ b/examples/charts/barchart/main.cpp @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include + +QT_CHARTS_USE_NAMESPACE + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + +//![1] + QBarSet *set0 = new QBarSet("Jane"); + QBarSet *set1 = new QBarSet("John"); + QBarSet *set2 = new QBarSet("Axel"); + QBarSet *set3 = new QBarSet("Mary"); + QBarSet *set4 = new QBarSet("Samantha"); + + *set0 << 1 << 2 << 3 << 4 << 5 << 6; + *set1 << 5 << 0 << 0 << 4 << 0 << 7; + *set2 << 3 << 5 << 8 << 13 << 8 << 5; + *set3 << 5 << 6 << 7 << 3 << 4 << 5; + *set4 << 9 << 7 << 5 << 3 << 1 << 2; +//![1] + +//![2] + QBarSeries *series = new QBarSeries(); + series->append(set0); + series->append(set1); + series->append(set2); + series->append(set3); + series->append(set4); + +//![2] + +//![3] + QChart *chart = new QChart(); + chart->addSeries(series); + chart->setTitle("Simple barchart example"); + chart->setAnimationOptions(QChart::SeriesAnimations); +//![3] + +//![4] + QStringList categories; + categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; + QBarCategoryAxis *axis = new QBarCategoryAxis(); + axis->append(categories); + chart->createDefaultAxes(); + chart->setAxisX(axis, series); +//![4] + +//![5] + chart->legend()->setVisible(true); + chart->legend()->setAlignment(Qt::AlignBottom); +//![5] + +//![6] + QChartView *chartView = new QChartView(chart); + chartView->setRenderHint(QPainter::Antialiasing); +//![6] + +//![7] + QMainWindow window; + window.setCentralWidget(chartView); + window.resize(420, 300); + window.show(); +//![7] + + return a.exec(); +} diff --git a/examples/charts/barmodelmapper/barmodelmapper.pro b/examples/charts/barmodelmapper/barmodelmapper.pro new file mode 100644 index 00000000..91b8f367 --- /dev/null +++ b/examples/charts/barmodelmapper/barmodelmapper.pro @@ -0,0 +1,16 @@ +!include( ../examples.pri ) { + error( "Couldn't find the examples.pri file!" ) +} + +QT += core gui + +TARGET = barmodelmapper +TEMPLATE = app + + +SOURCES += main.cpp\ + tablewidget.cpp \ + customtablemodel.cpp + +HEADERS += tablewidget.h \ + customtablemodel.h diff --git a/examples/charts/barmodelmapper/customtablemodel.cpp b/examples/charts/barmodelmapper/customtablemodel.cpp new file mode 100644 index 00000000..3ec58384 --- /dev/null +++ b/examples/charts/barmodelmapper/customtablemodel.cpp @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "customtablemodel.h" +#include +#include +#include +#include + +CustomTableModel::CustomTableModel(QObject *parent) : + QAbstractTableModel(parent) +{ + qsrand(QTime(0, 0, 0).secsTo(QTime::currentTime())); + + m_columnCount = 6; + m_rowCount = 12; + + // m_data + for (int i = 0; i < m_rowCount; i++) { + QVector* dataVec = new QVector(m_columnCount); + for (int k = 0; k < dataVec->size(); k++) { + if (k % 2 == 0) + dataVec->replace(k, i * 50 + qrand() % 20); + else + dataVec->replace(k, qrand() % 100); + } + m_data.append(dataVec); + } +} + +int CustomTableModel::rowCount(const QModelIndex &parent) const +{ + Q_UNUSED(parent) + return m_data.count(); +} + +int CustomTableModel::columnCount(const QModelIndex &parent) const +{ + Q_UNUSED(parent) + return m_columnCount; +} + +QVariant CustomTableModel::headerData(int section, Qt::Orientation orientation, int role) const +{ + if (role != Qt::DisplayRole) + return QVariant(); + + if (orientation == Qt::Horizontal) + return QString("201%1").arg(section); + else + return QString("%1").arg(section + 1); +} + +QVariant CustomTableModel::data(const QModelIndex &index, int role) const +{ + if (role == Qt::DisplayRole) { + return m_data[index.row()]->at(index.column()); + } else if (role == Qt::EditRole) { + return m_data[index.row()]->at(index.column()); + } else if (role == Qt::BackgroundRole) { + QRect rect; + foreach (rect, m_mapping) + if (rect.contains(index.column(), index.row())) + return QColor(m_mapping.key(rect)); + + // cell not mapped return white color + return QColor(Qt::white); + } + return QVariant(); +} + +bool CustomTableModel::setData(const QModelIndex &index, const QVariant &value, int role) +{ + if (index.isValid() && role == Qt::EditRole) { + m_data[index.row()]->replace(index.column(), value.toDouble()); + emit dataChanged(index, index); + return true; + } + return false; +} + +Qt::ItemFlags CustomTableModel::flags(const QModelIndex &index) const +{ + return QAbstractItemModel::flags(index) | Qt::ItemIsEditable; +} + +void CustomTableModel::addMapping(QString color, QRect area) +{ + m_mapping.insertMulti(color, area); +} diff --git a/examples/charts/barmodelmapper/customtablemodel.h b/examples/charts/barmodelmapper/customtablemodel.h new file mode 100644 index 00000000..755f4c7d --- /dev/null +++ b/examples/charts/barmodelmapper/customtablemodel.h @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef CUSTOMTABLEMODEL_H +#define CUSTOMTABLEMODEL_H + +#include +#include +#include + +class CustomTableModel : public QAbstractTableModel +{ + Q_OBJECT +public: + explicit CustomTableModel(QObject *parent = 0); + + int rowCount(const QModelIndex &parent = QModelIndex()) const; + int columnCount(const QModelIndex &parent = QModelIndex()) const; + QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; + bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); + Qt::ItemFlags flags(const QModelIndex &index) const; + + void addMapping(QString color, QRect area); + void clearMapping() { m_mapping.clear(); } + +private: + QList * > m_data; + QHash m_mapping; + int m_columnCount; + int m_rowCount; +}; + +#endif // CUSTOMTABLEMODEL_H diff --git a/examples/charts/barmodelmapper/main.cpp b/examples/charts/barmodelmapper/main.cpp new file mode 100644 index 00000000..bf0b384b --- /dev/null +++ b/examples/charts/barmodelmapper/main.cpp @@ -0,0 +1,30 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include "tablewidget.h" + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + TableWidget w; + w.show(); + return a.exec(); +} diff --git a/examples/charts/barmodelmapper/tablewidget.cpp b/examples/charts/barmodelmapper/tablewidget.cpp new file mode 100644 index 00000000..81e881e9 --- /dev/null +++ b/examples/charts/barmodelmapper/tablewidget.cpp @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "tablewidget.h" +#include "customtablemodel.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +QT_CHARTS_USE_NAMESPACE + +TableWidget::TableWidget(QWidget *parent) + : QWidget(parent) +{ + // create simple model for storing data + // user's table data model + //! [1] + CustomTableModel *model = new CustomTableModel; + //! [1] + + //! [2] + // create table view and add model to it + QTableView *tableView = new QTableView; + tableView->setModel(model); + tableView->setMinimumWidth(300); + tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); + tableView->verticalHeader()->setSectionResizeMode(QHeaderView::Stretch); + //! [2] + + //! [3] + QChart *chart = new QChart; + chart->setAnimationOptions(QChart::AllAnimations); + //! [3] + + // series 1 + //! [4] + QBarSeries *series = new QBarSeries; + + int first = 3; + int count = 5; + QVBarModelMapper *mapper = new QVBarModelMapper(this); + mapper->setFirstBarSetColumn(1); + mapper->setLastBarSetColumn(4); + mapper->setFirstRow(first); + mapper->setRowCount(count); + mapper->setSeries(series); + mapper->setModel(model); + chart->addSeries(series); + //! [4] + + //! [5] + // for storing color hex from the series + QString seriesColorHex = "#000000"; + + // get the color of the series and use it for showing the mapped area + QList barsets = series->barSets(); + for (int i = 0; i < barsets.count(); i++) { + seriesColorHex = "#" + QString::number(barsets.at(i)->brush().color().rgb(), 16).right(6).toUpper(); + model->addMapping(seriesColorHex, QRect(1 + i, first, 1, barsets.at(i)->count())); + } + //! [5] + + //! [6] + QStringList categories; + categories << "April" << "May" << "June" << "July" << "August"; + QBarCategoryAxis *axis = new QBarCategoryAxis(); + axis->append(categories); + chart->createDefaultAxes(); + chart->setAxisX(axis, series); + //! [6] + + //! [7] + QChartView *chartView = new QChartView(chart); + chartView->setRenderHint(QPainter::Antialiasing); + chartView->setMinimumSize(640, 480); + //! [7] + + //! [8] + // create main layout + QGridLayout *mainLayout = new QGridLayout; + mainLayout->addWidget(tableView, 1, 0); + mainLayout->addWidget(chartView, 1, 1); + mainLayout->setColumnStretch(1, 1); + mainLayout->setColumnStretch(0, 0); + setLayout(mainLayout); + //! [8] +} diff --git a/examples/charts/barmodelmapper/tablewidget.h b/examples/charts/barmodelmapper/tablewidget.h new file mode 100644 index 00000000..3846cc11 --- /dev/null +++ b/examples/charts/barmodelmapper/tablewidget.h @@ -0,0 +1,34 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef TABLEWIDGET_H +#define TABLEWIDGET_H + +#include + +class TableWidget : public QWidget +{ + Q_OBJECT + +public: + TableWidget(QWidget *parent = 0); +}; + +#endif // TABLEWIDGET_H diff --git a/examples/charts/boxplotchart/acme_data.txt b/examples/charts/boxplotchart/acme_data.txt new file mode 100644 index 00000000..9511418d --- /dev/null +++ b/examples/charts/boxplotchart/acme_data.txt @@ -0,0 +1,13 @@ +# Acme Ltd share deviation in 2012 +Jan 27.74 27.28 27.86 28.05 28.64 27.47 28.30 28.22 28.72 26.50 26.62 26.50 26.15 26.47 26.41 25.78 24.82 24.89 24.88 24.60 23.85 +Feb 31.79 30.62 30.67 31.37 31.16 31.22 32.02 32.70 31.60 31.24 30.98 30.79 31.10 30.79 31.53 30.92 30.00 30.58 30.37 29.40 28.60 +Mar 28.64 28.34 29.13 29.43 30.75 29.77 29.72 30.52 31.12 33.05 32.51 32.69 31.83 32.47 31.41 31.39 31.78 30.08 29.46 31.58 31.39 31.41 +Apr 25.96 26.62 26.19 30.37 28.78 27.50 28.90 28.40 28.86 28.90 27.91 27.32 27.99 26.86 26.68 27.57 27.50 28.96 28.50 +May 20.85 21.08 21.98 21.61 21.45 21.73 21.71 22.27 21.14 20.65 21.95 22.23 23.17 24.26 24.17 22.97 23.53 24.49 24.51 25.46 25.65 +Jun 18.08 17.19 17.36 17.21 17.31 18.19 18.30 17.53 17.35 17.80 17.17 16.95 18.25 20.52 20.61 21.40 20.45 19.43 19.11 19.74 +Jul 17.75 18.24 17.57 16.53 15.98 16.06 16.64 17.69 17.91 18.00 18.03 18.14 18.10 17.86 18.12 18.53 18.43 18.30 19.03 18.76 18.79 18.33 +Aug 18.69 18.54 18.39 18.49 18.96 18.72 19.25 19.70 20.13 19.74 19.27 18.25 17.72 18.02 18.20 18.24 18.60 18.22 18.60 17.98 17.27 16.70 17.19 +Sep 18.35 18.82 18.96 19.96 19.75 20.55 20.68 21.19 21.14 21.48 21.45 20.74 20.97 20.18 19.66 19.54 18.89 18.39 18.26 18.86 +Oct 16.95 16.80 16.45 16.89 17.38 17.12 16.85 17.59 17.65 17.46 17.43 17.30 17.87 18.61 18.55 18.59 19.27 19.54 20.02 19.23 18.05 18.52 18.71 +Now 19.36 19.29 18.22 18.74 19.05 19.13 18.67 18.19 17.94 18.04 17.49 17.53 17.64 18.00 18.21 18.19 18.30 18.11 18.17 17.76 17.80 17.52 +Dec 19.95 20.19 20.15 20.42 20.39 20.65 20.39 19.86 19.48 19.70 19.94 19.82 20.25 20.21 19.63 19.55 diff --git a/examples/charts/boxplotchart/boxdatareader.cpp b/examples/charts/boxplotchart/boxdatareader.cpp new file mode 100644 index 00000000..ba2d8b3a --- /dev/null +++ b/examples/charts/boxplotchart/boxdatareader.cpp @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "boxdatareader.h" + +BoxDataReader::BoxDataReader(QIODevice *device) : + QTextStream(device) +{ +} + +void BoxDataReader::readFile(QIODevice *device) +{ + QTextStream::setDevice(device); +} + +QBoxSet *BoxDataReader::readBox() +{ + //! [1] + QString line = readLine(); + if (line.startsWith("#")) + return 0; + //! [1] + + //! [2] + QStringList strList = line.split(" ", QString::SkipEmptyParts); + //! [2] + + //! [3] + sortedList.clear(); + for (int i = 1; i < strList.count(); i++) + sortedList.append(strList.at(i).toDouble()); + + qSort(sortedList.begin(), sortedList.end()); + //! [3] + + int count = sortedList.count(); + + //! [4] + QBoxSet *box = new QBoxSet(strList.first()); + box->setValue(QBoxSet::LowerExtreme, sortedList.first()); + box->setValue(QBoxSet::UpperExtreme, sortedList.last()); + box->setValue(QBoxSet::Median, findMedian(0, count)); + box->setValue(QBoxSet::LowerQuartile, findMedian(0, count / 2)); + box->setValue(QBoxSet::UpperQuartile, findMedian(count / 2 + (count % 2), count)); + //! [4] + + return box; +} + +qreal BoxDataReader::findMedian(int begin, int end) +{ + //! [5] + int count = end - begin; + if (count % 2) { + return sortedList.at(count / 2 + begin); + } else { + qreal right = sortedList.at(count / 2 + begin); + qreal left = sortedList.at(count / 2 - 1 + begin); + return (right + left) / 2.0; + } + //! [5] +} diff --git a/examples/charts/boxplotchart/boxdatareader.h b/examples/charts/boxplotchart/boxdatareader.h new file mode 100644 index 00000000..5dbddc14 --- /dev/null +++ b/examples/charts/boxplotchart/boxdatareader.h @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef BOXDATAREADER_H +#define BOXDATAREADER_H + +#include +#include + +QT_CHARTS_USE_NAMESPACE + +class BoxDataReader : public QTextStream +{ +public: + explicit BoxDataReader(QIODevice *device); + QBoxSet *readBox(); + void readFile(QIODevice *device); + +protected: + qreal findMedian(int begin, int end); + +private: + QList sortedList; +}; + +#endif // BOXDATAREADER_H diff --git a/examples/charts/boxplotchart/boxplotchart.pro b/examples/charts/boxplotchart/boxplotchart.pro new file mode 100644 index 00000000..c2483511 --- /dev/null +++ b/examples/charts/boxplotchart/boxplotchart.pro @@ -0,0 +1,13 @@ +!include( ../examples.pri ) { + error( "Couldn't find the examples.pri file!" ) +} + +TARGET = boxplotchart +SOURCES += main.cpp \ + boxdatareader.cpp + +RESOURCES += \ + boxplotdata.qrc + +HEADERS += \ + boxdatareader.h diff --git a/examples/charts/boxplotchart/boxplotdata.qrc b/examples/charts/boxplotchart/boxplotdata.qrc new file mode 100644 index 00000000..fe6d52b5 --- /dev/null +++ b/examples/charts/boxplotchart/boxplotdata.qrc @@ -0,0 +1,6 @@ + + + acme_data.txt + boxwhisk_data.txt + + diff --git a/examples/charts/boxplotchart/boxwhisk_data.txt b/examples/charts/boxplotchart/boxwhisk_data.txt new file mode 100644 index 00000000..f1d49cf0 --- /dev/null +++ b/examples/charts/boxplotchart/boxwhisk_data.txt @@ -0,0 +1,13 @@ +# BoxWhisk Inc share deviation in 2012 +Jan 25.74 25.28 25.86 26.05 26.64 28.47 28.30 29.22 29.72 27.50 25.62 25.50 25.15 26.47 27.41 25.78 24.82 24.89 24.88 24.60 23.85 +Feb 30.79 29.62 29.67 30.37 30.16 30.22 31.02 33.70 32.60 32.24 31.98 31.79 31.10 30.79 31.53 30.92 29.00 29.58 30.37 29.40 28.60 +Mar 29.64 29.34 30.13 30.43 31.75 30.77 30.72 31.52 32.12 33.75 33.51 33.69 32.83 32.47 32.41 32.39 32.78 31.08 29.46 31.58 31.39 31.41 +Apr 24.96 25.62 25.19 28.37 28.78 26.50 25.90 26.40 26.86 26.90 27.91 27.32 27.99 26.86 26.68 27.57 27.50 26.96 26.50 +May 21.85 21.08 22.98 22.61 22.45 21.73 21.71 23.27 22.14 19.65 22.95 21.23 23.17 24.26 24.17 21.97 22.53 25.49 25.51 26.46 26.65 +Jun 15.08 15.19 15.36 15.21 15.31 18.19 18.30 15.53 15.35 15.80 15.17 16.95 18.25 20.52 20.61 20.40 20.45 19.43 19.11 19.74 +Jul 17.75 18.24 17.57 16.53 15.98 16.06 16.64 17.69 17.91 19.00 19.03 19.14 19.10 17.86 19.12 19.53 19.43 19.30 19.03 19.76 18.79 18.33 +Aug 19.69 19.54 19.39 19.49 19.96 19.72 20.25 20.70 21.13 20.74 20.27 19.25 18.72 19.02 19.20 19.24 19.60 19.22 19.60 18.98 18.27 17.70 18.19 +Sep 19.35 19.82 19.96 20.96 20.75 21.55 21.68 22.19 22.14 22.48 22.45 21.74 21.97 21.18 20.66 20.54 19.89 19.39 19.26 19.86 +Oct 17.95 17.80 17.45 17.89 18.38 18.12 17.85 18.59 18.65 18.46 18.43 18.30 18.87 19.61 19.55 19.59 20.27 20.54 21.02 20.23 19.05 19.52 19.71 +Now 20.36 20.29 19.22 19.74 20.05 20.13 19.67 19.19 18.94 19.04 18.49 18.53 18.64 19.00 19.21 19.19 19.30 19.11 19.17 18.76 18.80 18.52 +Dec 22.95 22.19 22.15 21.42 21.39 21.65 22.39 20.86 20.48 20.70 20.94 20.82 19.25 21.21 19.63 20.55 diff --git a/examples/charts/boxplotchart/main.cpp b/examples/charts/boxplotchart/main.cpp new file mode 100644 index 00000000..802217e1 --- /dev/null +++ b/examples/charts/boxplotchart/main.cpp @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "boxdatareader.h" + +QT_CHARTS_USE_NAMESPACE + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + + //! [1] + QBoxPlotSeries *acmeSeries = new QBoxPlotSeries(); + acmeSeries->setName("Acme Ltd"); + + QBoxPlotSeries *boxWhiskSeries = new QBoxPlotSeries(); + boxWhiskSeries->setName("BoxWhisk Inc"); + //! [1] + + //! [2] + QFile acmeData(":acme"); + if (!acmeData.open(QIODevice::ReadOnly | QIODevice::Text)) + return 1; + + BoxDataReader dataReader(&acmeData); + while (!dataReader.atEnd()) { + QBoxSet *set = dataReader.readBox(); + if (set) + acmeSeries->append(set); + } + //! [2] + + //! [3] + QFile boxwhiskData(":boxwhisk"); + if (!boxwhiskData.open(QIODevice::ReadOnly | QIODevice::Text)) + return 1; + + dataReader.readFile(&boxwhiskData); + while (!dataReader.atEnd()) { + QBoxSet *set = dataReader.readBox(); + if (set) + boxWhiskSeries->append(set); + } + //! [3] + + //! [4] + QChart *chart = new QChart(); + chart->addSeries(acmeSeries); + chart->addSeries(boxWhiskSeries); + chart->setTitle("Acme Ltd and BoxWhisk Inc share deviation in 2012"); + chart->setAnimationOptions(QChart::SeriesAnimations); + //! [4] + + //! [5] + chart->createDefaultAxes(); + chart->axisY()->setMin(15.0); + chart->axisY()->setMax(34.0); + //! [5] + + //! [6] + chart->legend()->setVisible(true); + chart->legend()->setAlignment(Qt::AlignBottom); + //! [6] + + //! [7] + QChartView *chartView = new QChartView(chart); + chartView->setRenderHint(QPainter::Antialiasing); + //! [7] + + //! [8] + QMainWindow window; + window.setCentralWidget(chartView); + window.resize(800, 600); + window.show(); + //! [8] + + return a.exec(); +} + diff --git a/examples/charts/callout/callout.cpp b/examples/charts/callout/callout.cpp new file mode 100644 index 00000000..2491368f --- /dev/null +++ b/examples/charts/callout/callout.cpp @@ -0,0 +1,119 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "callout.h" +#include +#include +#include +#include + +Callout::Callout(QGraphicsItem * parent): + QGraphicsItem(parent) +{ +} + +QRectF Callout::boundingRect() const +{ + QPointF anchor = mapFromParent(m_anchor); + QRectF rect; + rect.setLeft(qMin(m_rect.left(), anchor.x())); + rect.setRight(qMax(m_rect.right(), anchor.x())); + rect.setTop(qMin(m_rect.top(), anchor.y())); + rect.setBottom(qMax(m_rect.bottom(), anchor.y())); + return rect; +} + +void Callout::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) +{ + Q_UNUSED(option) + Q_UNUSED(widget) + QPainterPath path; + path.addRoundedRect(m_rect, 5, 5); + + QPointF anchor = mapFromParent(m_anchor); + if (!m_rect.contains(anchor)) { + QPointF point1, point2; + + // establish the position of the anchor point in relation to m_rect + bool above = anchor.y() <= m_rect.top(); + bool aboveCenter = anchor.y() > m_rect.top() && anchor.y() <= m_rect.center().y(); + bool belowCenter = anchor.y() > m_rect.center().y() && anchor.y() <= m_rect.bottom(); + bool below = anchor.y() > m_rect.bottom(); + + bool onLeft = anchor.x() <= m_rect.left(); + bool leftOfCenter = anchor.x() > m_rect.left() && anchor.x() <= m_rect.center().x(); + bool rightOfCenter = anchor.x() > m_rect.center().x() && anchor.x() <= m_rect.right(); + bool onRight = anchor.x() > m_rect.right(); + + // get the nearest m_rect corner. + qreal x = (onRight + rightOfCenter) * m_rect.width(); + qreal y = (below + belowCenter) * m_rect.height(); + bool cornerCase = (above && onLeft) || (above && onRight) || (below && onLeft) || (below && onRight); + bool vertical = qAbs(anchor.x() - x) > qAbs(anchor.y() - y); + + qreal x1 = x + leftOfCenter * 10 - rightOfCenter * 20 + cornerCase * !vertical * (onLeft * 10 - onRight * 20); + qreal y1 = y + aboveCenter * 10 - belowCenter * 20 + cornerCase * vertical * (above * 10 - below * 20);; + point1.setX(x1); + point1.setY(y1); + + qreal x2 = x + leftOfCenter * 20 - rightOfCenter * 10 + cornerCase * !vertical * (onLeft * 20 - onRight * 10);; + qreal y2 = y + aboveCenter * 20 - belowCenter * 10 + cornerCase * vertical * (above * 20 - below * 10);; + point2.setX(x2); + point2.setY(y2); + + path.moveTo(point1); + path.lineTo(mapFromParent(m_anchor)); + path.lineTo(point2); + path = path.simplified(); + } + painter->setBrush(QColor(255, 255, 255)); + painter->drawPath(path); + painter->drawText(m_textRect, m_text); +} + +void Callout::mousePressEvent(QGraphicsSceneMouseEvent *event) +{ + event->setAccepted(true); +} + +void Callout::mouseMoveEvent(QGraphicsSceneMouseEvent *event) +{ + if (event->buttons() & Qt::LeftButton){ + setPos(mapToParent(event->pos() - event->buttonDownPos(Qt::LeftButton))); + event->setAccepted(true); + } else { + event->setAccepted(false); + } +} + +void Callout::setText(const QString &text) +{ + m_text = text; + QFontMetrics metrics(m_font); + m_textRect = metrics.boundingRect(QRect(0, 0, 150, 150), Qt::AlignLeft, m_text); + m_textRect.translate(5, 5); + prepareGeometryChange(); + m_rect = m_textRect.adjusted(-5, -5, 5, 5); +} + +void Callout::setAnchor(QPointF point) +{ + m_anchor = point; +} diff --git a/examples/charts/callout/callout.h b/examples/charts/callout/callout.h new file mode 100644 index 00000000..23fc8484 --- /dev/null +++ b/examples/charts/callout/callout.h @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef CALLOUT_H +#define CALLOUT_H + +#include +#include + +class QGraphicsSceneMouseEvent; + +class Callout : public QGraphicsItem +{ +public: + Callout(QGraphicsItem * parent = 0); + + void setText(const QString &text); + void setAnchor(QPointF point); + + QRectF boundingRect() const; + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,QWidget *widget); + +protected: + void mousePressEvent(QGraphicsSceneMouseEvent *event); + void mouseMoveEvent(QGraphicsSceneMouseEvent *event); + +private: + QString m_text; + QRectF m_textRect; + QRectF m_rect; + QPointF m_anchor; + QFont m_font; +}; + +#endif // CALLOUT_H diff --git a/examples/charts/callout/callout.pro b/examples/charts/callout/callout.pro new file mode 100644 index 00000000..b0da66d6 --- /dev/null +++ b/examples/charts/callout/callout.pro @@ -0,0 +1,15 @@ +!include( ../examples.pri ) { + error( "Couldn't find the examples.pri file!" ) +} + +TARGET = callout +TEMPLATE = app + +SOURCES += \ + main.cpp\ + callout.cpp \ + view.cpp + +HEADERS += \ + callout.h \ + view.h diff --git a/examples/charts/callout/main.cpp b/examples/charts/callout/main.cpp new file mode 100644 index 00000000..a6dfc2e9 --- /dev/null +++ b/examples/charts/callout/main.cpp @@ -0,0 +1,31 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include "view.h" + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + View w; + w.show(); + + return a.exec(); +} diff --git a/examples/charts/callout/view.cpp b/examples/charts/callout/view.cpp new file mode 100644 index 00000000..a7c43863 --- /dev/null +++ b/examples/charts/callout/view.cpp @@ -0,0 +1,123 @@ +/**************************************************************************** + ** + ** Copyright (C) 2014 Digia Plc + ** All rights reserved. + ** For any questions to Digia, please use contact form at http://qt.digia.com + ** + ** This file is part of the Qt Enterprise Charts Add-on. + ** + ** $QT_BEGIN_LICENSE$ + ** Licensees holding valid Qt Enterprise licenses may use this file in + ** accordance with the Qt Enterprise License Agreement provided with the + ** Software or, alternatively, in accordance with the terms contained in + ** a written agreement between you and Digia. + ** + ** If you have questions regarding the use of this file, please use + ** contact form at http://qt.digia.com + ** $QT_END_LICENSE$ + ** + ****************************************************************************/ + +#include "view.h" +#include +#include +#include +#include +#include +#include +#include "callout.h" +#include + +View::View(QWidget *parent) + : QGraphicsView(new QGraphicsScene, parent), + m_coordX(0), + m_coordY(0), + m_chart(0), + m_tooltip(0) +{ + setDragMode(QGraphicsView::NoDrag); + setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + + // chart + m_chart = new QChart; + m_chart->setMinimumSize(640, 480); + m_chart->setTitle("Hover the line to show callout. Click the line to make it stay"); + m_chart->legend()->hide(); + QLineSeries *series = new QLineSeries; + series->append(1, 3); + series->append(4, 5); + series->append(5, 4.5); + series->append(7, 1); + series->append(11, 2); + m_chart->addSeries(series); + + QSplineSeries *series2 = new QSplineSeries; + series2->append(1.6, 1.4); + series2->append(2.4, 3.5); + series2->append(3.7, 2.5); + series2->append(7, 4); + series2->append(10, 2); + m_chart->addSeries(series2); + + m_chart->createDefaultAxes(); + m_chart->setAcceptHoverEvents(true); + + setRenderHint(QPainter::Antialiasing); + scene()->addItem(m_chart); + + m_coordX = new QGraphicsSimpleTextItem(m_chart); + m_coordX->setPos(m_chart->size().width()/2 - 50, m_chart->size().height()); + m_coordX->setText("X: "); + m_coordY = new QGraphicsSimpleTextItem(m_chart); + m_coordY->setPos(m_chart->size().width()/2 + 50, m_chart->size().height()); + m_coordY->setText("Y: "); + + connect(series, SIGNAL(clicked(QPointF)), this, SLOT(keepCallout())); + connect(series, SIGNAL(hovered(QPointF, bool)), this, SLOT(tooltip(QPointF,bool))); + + connect(series2, SIGNAL(clicked(QPointF)), this, SLOT(keepCallout())); + connect(series2, SIGNAL(hovered(QPointF, bool)), this, SLOT(tooltip(QPointF,bool))); + + this->setMouseTracking(true); +} + +void View::resizeEvent(QResizeEvent *event) +{ + if (scene()) { + scene()->setSceneRect(QRect(QPoint(0, 0), event->size())); + m_chart->resize(event->size()); + m_coordX->setPos(m_chart->size().width()/2 - 50, m_chart->size().height() - 20); + m_coordY->setPos(m_chart->size().width()/2 + 50, m_chart->size().height() - 20); + } + QGraphicsView::resizeEvent(event); +} + +void View::mouseMoveEvent(QMouseEvent *event) +{ + m_coordX->setText(QString("X: %1").arg(m_chart->mapToValue(event->pos()).x())); + m_coordY->setText(QString("Y: %1").arg(m_chart->mapToValue(event->pos()).y())); + QGraphicsView::mouseMoveEvent(event); +} + +void View::keepCallout() +{ + m_tooltip = new Callout(m_chart); +} + +void View::tooltip(QPointF point, bool state) +{ + if (m_tooltip == 0) + m_tooltip = new Callout(m_chart); + + if (state) { + m_tooltip->setText(QString("X: %1 \nY: %2 ").arg(point.x()).arg(point.y())); + QXYSeries *series = qobject_cast(sender()); + m_tooltip->setAnchor(m_chart->mapToPosition(point, series)); + m_tooltip->setPos(m_chart->mapToPosition(point, series) + QPoint(10, -50)); + m_tooltip->setZValue(11); + m_tooltip->show(); + } else { + m_tooltip->hide(); + } +} diff --git a/examples/charts/callout/view.h b/examples/charts/callout/view.h new file mode 100644 index 00000000..3a322382 --- /dev/null +++ b/examples/charts/callout/view.h @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef VIEW_H +#define VIEW_H +#include +#include + +QT_CHARTS_BEGIN_NAMESPACE +class QChart; +QT_CHARTS_END_NAMESPACE + +class QGraphicsScene; +class QResizeEvent; +class Callout; +class QMouseEvent; + +QT_CHARTS_USE_NAMESPACE + +class View: public QGraphicsView +{ + Q_OBJECT + +public: + View(QWidget *parent = 0); + +protected: + void resizeEvent(QResizeEvent *event); + void mouseMoveEvent(QMouseEvent *event); + +public slots: + void keepCallout(); + void tooltip(QPointF point, bool state); + +private: + QGraphicsSimpleTextItem *m_coordX; + QGraphicsSimpleTextItem *m_coordY; + QChart *m_chart; + Callout *m_tooltip; +}; + +#endif diff --git a/examples/charts/chartinteractions/chart.cpp b/examples/charts/chartinteractions/chart.cpp new file mode 100644 index 00000000..8aa2a443 --- /dev/null +++ b/examples/charts/chartinteractions/chart.cpp @@ -0,0 +1,101 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "chart.h" +#include +#include +#include + +Chart::Chart(QGraphicsItem *parent, Qt::WindowFlags wFlags, QLineSeries *series) + : QChart(QChart::ChartTypeCartesian, parent, wFlags), m_series(series) +{ + m_clicked = false; +} + +Chart::~Chart() +{ +} + +void Chart::clickPoint(const QPointF &point) +{ + // Find the closes data point + m_movingPoint = QPoint(); + m_clicked = false; + foreach (QPointF p, m_series->points()) { + if (distance(p, point) < distance(m_movingPoint, point)) { + m_movingPoint = p; + m_clicked = true; + } + } +} + +qreal Chart::distance(const QPointF &p1, const QPointF &p2) +{ + return qSqrt((p1.x() - p2.x()) * (p1.x() - p2.x()) + + (p1.y() - p2.y()) * (p1.y() - p2.y())); +} + +void Chart::setPointClicked(bool clicked) +{ + m_clicked = clicked; +} + +void Chart::handlePointMove(const QPoint &point) +{ + if (m_clicked) { + //Map the point clicked from the ChartView + //to the area occupied by the chart. + QPoint mappedPoint = point; + mappedPoint.setX(point.x() - this->plotArea().x()); + mappedPoint.setY(point.y() - this->plotArea().y()); + + //Get the x- and y axis to be able to convert the mapped + //coordinate point to the charts scale. + QAbstractAxis *axisx = this->axisX(); + QValueAxis *haxis = 0; + if (axisx->type() == QAbstractAxis::AxisTypeValue) + haxis = qobject_cast(axisx); + + QAbstractAxis *axisy = this->axisY(); + QValueAxis *vaxis = 0; + if (axisy->type() == QAbstractAxis::AxisTypeValue) + vaxis = qobject_cast(axisy); + + if (haxis && vaxis) { + //Calculate the "unit" between points on the x + //y axis. + double xUnit = this->plotArea().width() / haxis->max(); + double yUnit = this->plotArea().height() / vaxis->max(); + + //Convert the mappedPoint to the actual chart scale. + double x = mappedPoint.x() / xUnit; + double y = vaxis->max() - mappedPoint.y() / yUnit; + + //Replace the old point with the new one. + m_series->replace(m_movingPoint, QPointF(x, y)); + + //Update the m_movingPoint so we are able to + //do the replace also during mousemoveEvent. + m_movingPoint.setX(x); + m_movingPoint.setY(y); + } + } +} + diff --git a/examples/charts/chartinteractions/chart.h b/examples/charts/chartinteractions/chart.h new file mode 100644 index 00000000..9a10387b --- /dev/null +++ b/examples/charts/chartinteractions/chart.h @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef CHART_H +#define CHART_H + +#include +#include + +QT_CHARTS_USE_NAMESPACE + +class Chart : public QChart +{ + Q_OBJECT +public: + explicit Chart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0, QLineSeries *series = 0); + ~Chart(); + +public slots: + void clickPoint(const QPointF &point); + +public: + void handlePointMove(const QPoint &point); + void setPointClicked(bool clicked); + +private: + qreal distance(const QPointF &p1, const QPointF &p2); + QLineSeries *m_series; + QPointF m_movingPoint; + + //Boolean value to determine if an actual point in the + //series is clicked. + bool m_clicked; +}; + +#endif // CHART_H diff --git a/examples/charts/chartinteractions/chartinteractions.pro b/examples/charts/chartinteractions/chartinteractions.pro new file mode 100644 index 00000000..8cf4c36c --- /dev/null +++ b/examples/charts/chartinteractions/chartinteractions.pro @@ -0,0 +1,11 @@ +!include( ../examples.pri ) { + error( "Couldn't find the examples.pri file!" ) +} + +QT += core gui + +TARGET = chartinteractions +TEMPLATE = app + +HEADERS += chart.h chartview.h +SOURCES += main.cpp chart.cpp chartview.cpp diff --git a/examples/charts/chartinteractions/chartview.cpp b/examples/charts/chartinteractions/chartview.cpp new file mode 100644 index 00000000..95fae6cd --- /dev/null +++ b/examples/charts/chartinteractions/chartview.cpp @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "chartview.h" +#include +#include "chart.h" + +ChartView::ChartView(Chart *chart, QWidget *parent) : + QChartView(chart, parent) +{ + m_chart = chart; +} + +void ChartView::mousePressEvent(QMouseEvent *event) +{ + m_mousePos = event->pos(); + QChartView::mousePressEvent(event); +} + +void ChartView::mouseMoveEvent(QMouseEvent *event) +{ + m_chart->handlePointMove(event->pos()); + QChartView::mouseMoveEvent(event); +} + +void ChartView::mouseReleaseEvent(QMouseEvent *event) +{ + if (event->pos() != m_mousePos) { + m_chart->handlePointMove(event->pos()); + m_chart->setPointClicked(false); + } + QChartView::mouseReleaseEvent(event); +} diff --git a/examples/charts/chartinteractions/chartview.h b/examples/charts/chartinteractions/chartview.h new file mode 100644 index 00000000..931feee0 --- /dev/null +++ b/examples/charts/chartinteractions/chartview.h @@ -0,0 +1,45 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef CHARTVIEW_H +#define CHARTVIEW_H + +#include + +class Chart; + +QT_CHARTS_USE_NAMESPACE + +class ChartView : public QChartView +{ +public: + ChartView(Chart *chart, QWidget *parent = 0); + +protected: + void mousePressEvent(QMouseEvent *event); + void mouseMoveEvent(QMouseEvent *event); + void mouseReleaseEvent(QMouseEvent *event); + +private: + Chart *m_chart; + QPoint m_mousePos; +}; + +#endif diff --git a/examples/charts/chartinteractions/main.cpp b/examples/charts/chartinteractions/main.cpp new file mode 100644 index 00000000..67cfb800 --- /dev/null +++ b/examples/charts/chartinteractions/main.cpp @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include + +#include + +#include "chart.h" +#include "chartview.h" + +QT_CHARTS_USE_NAMESPACE + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + + QLineSeries *series = new QLineSeries(); + + series->append(0, 6); + series->append(1, 3); + series->append(2, 4); + series->append(3, 8); + series->append(7, 13); + series->append(10, 5); + *series << QPointF(11, 1) << QPointF(13, 3) << QPointF(17, 6) << QPointF(18, 3) << QPointF(20, 2); + + Chart *chart = new Chart(0, 0, series); + chart->legend()->hide(); + chart->addSeries(series); + QPen p = series->pen(); + p.setWidth(5); + series->setPen(p); + chart->createDefaultAxes(); + chart->setTitle("Drag'n drop to move data points"); + + QValueAxis *axisX = new QValueAxis(); + chart->setAxisX(axisX, series); + axisX->setRange(0, 20); + + QValueAxis *axisY = new QValueAxis(); + chart->setAxisY(axisY, series); + axisY->setRange(0, 13); + + QObject::connect(series, SIGNAL(clicked(QPointF)), chart, SLOT(clickPoint(QPointF))); + + ChartView *chartView = new ChartView(chart); + chartView->setRenderHint(QPainter::Antialiasing); + + QMainWindow window; + window.setCentralWidget(chartView); + window.resize(400, 300); + window.show(); + + return a.exec(); +} diff --git a/examples/charts/charts.pro b/examples/charts/charts.pro new file mode 100644 index 00000000..e9d3e0e8 --- /dev/null +++ b/examples/charts/charts.pro @@ -0,0 +1,60 @@ +TEMPLATE = subdirs +SUBDIRS += areachart \ + customchart \ + linechart \ + percentbarchart \ + piechart \ + piechartdrilldown \ + scatterchart \ + scatterinteractions \ + splinechart \ + stackedbarchart \ + stackedbarchartdrilldown \ + zoomlinechart \ + modeldata \ + barchart \ + boxplotchart \ + legend \ + barmodelmapper \ + lineandbar \ + horizontalbarchart \ + horizontalstackedbarchart \ + horizontalpercentbarchart \ + donutbreakdown \ + temperaturerecords \ + donutchart \ + multiaxis \ + legendmarkers \ + logvalueaxis \ + polarchart \ + piechartcustomization \ + dynamicspline \ + nesteddonuts \ + chartinteractions \ + callout \ + chartthemes + +qtHaveModule(quick) { + SUBDIRS += qmlboxplot \ + qmlpiechart \ + qmlweather \ + qmlf1legends \ + qmlcustomizations \ + qmlaxes \ + qmlcustomlegend \ + qmlpolarchart \ + qmlchart \ + qmloscilloscope +} + +contains(QT_CONFIG, multimedia) { + SUBDIRS += audio +} else { + message("QtMultimedia library not available. Some examples are disabled") +} + +!linux-arm*: { +SUBDIRS += \ + datetimeaxis +} + diff --git a/examples/charts/chartthemes/chartthemes.pro b/examples/charts/chartthemes/chartthemes.pro new file mode 100644 index 00000000..2a414557 --- /dev/null +++ b/examples/charts/chartthemes/chartthemes.pro @@ -0,0 +1,7 @@ +!include( ../examples.pri ) { + error( "Couldn't find the examples.pri file!" ) +} + +TARGET = chartthemes +SOURCES = main.cpp themewidget.cpp +HEADERS = themewidget.h diff --git a/examples/charts/chartthemes/main.cpp b/examples/charts/chartthemes/main.cpp new file mode 100644 index 00000000..5bc1af84 --- /dev/null +++ b/examples/charts/chartthemes/main.cpp @@ -0,0 +1,35 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "themewidget.h" +#include +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + QMainWindow window; + ThemeWidget *widget = new ThemeWidget(); + window.setCentralWidget(widget); + window.resize(900, 600); + window.show(); + return a.exec(); +} + diff --git a/examples/charts/chartthemes/themewidget.cpp b/examples/charts/chartthemes/themewidget.cpp new file mode 100644 index 00000000..d1b0051b --- /dev/null +++ b/examples/charts/chartthemes/themewidget.cpp @@ -0,0 +1,372 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "themewidget.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +ThemeWidget::ThemeWidget(QWidget *parent) : + QWidget(parent), + m_listCount(3), + m_valueMax(10), + m_valueCount(7), + m_dataTable(generateRandomData(m_listCount, m_valueMax, m_valueCount)), + m_themeComboBox(createThemeBox()), + m_antialiasCheckBox(new QCheckBox("Anti-aliasing")), + m_animatedComboBox(createAnimationBox()), + m_legendComboBox(createLegendBox()) +{ + connectSignals(); + // create layout + QGridLayout *baseLayout = new QGridLayout(); + QHBoxLayout *settingsLayout = new QHBoxLayout(); + settingsLayout->addWidget(new QLabel("Theme:")); + settingsLayout->addWidget(m_themeComboBox); + settingsLayout->addWidget(new QLabel("Animation:")); + settingsLayout->addWidget(m_animatedComboBox); + settingsLayout->addWidget(new QLabel("Legend:")); + settingsLayout->addWidget(m_legendComboBox); + settingsLayout->addWidget(m_antialiasCheckBox); + settingsLayout->addStretch(); + baseLayout->addLayout(settingsLayout, 0, 0, 1, 3); + + //create charts + + QChartView *chartView; + + chartView = new QChartView(createAreaChart()); + baseLayout->addWidget(chartView, 1, 0); + m_charts << chartView; + + chartView = new QChartView(createBarChart(m_valueCount)); + baseLayout->addWidget(chartView, 1, 1); + m_charts << chartView; + + chartView = new QChartView(createLineChart()); + baseLayout->addWidget(chartView, 1, 2); + m_charts << chartView; + + chartView = new QChartView(createPieChart()); + chartView->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); // funny things happen if the pie slice labels no not fit the screen... + baseLayout->addWidget(chartView, 2, 0); + m_charts << chartView; + + chartView = new QChartView(createSplineChart()); + baseLayout->addWidget(chartView, 2, 1); + m_charts << chartView; + + chartView = new QChartView(createScatterChart()); + baseLayout->addWidget(chartView, 2, 2); + m_charts << chartView; + + setLayout(baseLayout); + + // Set defaults + m_antialiasCheckBox->setChecked(true); + updateUI(); +} + +ThemeWidget::~ThemeWidget() +{ +} + +void ThemeWidget::connectSignals() +{ + connect(m_themeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI())); + connect(m_antialiasCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateUI())); + connect(m_animatedComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI())); + connect(m_legendComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI())); +} + +DataTable ThemeWidget::generateRandomData(int listCount, int valueMax, int valueCount) const +{ + DataTable dataTable; + + // set seed for random stuff + qsrand(QTime(0, 0, 0).secsTo(QTime::currentTime())); + + // generate random data + for (int i(0); i < listCount; i++) { + DataList dataList; + qreal yValue(0); + for (int j(0); j < valueCount; j++) { + yValue = yValue + (qreal)(qrand() % valueMax) / (qreal) valueCount; + QPointF value((j + (qreal) rand() / (qreal) RAND_MAX) * ((qreal) m_valueMax / (qreal) valueCount), + yValue); + QString label = "Slice " + QString::number(i) + ":" + QString::number(j); + dataList << Data(value, label); + } + dataTable << dataList; + } + + return dataTable; +} + +QComboBox *ThemeWidget::createThemeBox() const +{ + // settings layout + QComboBox *themeComboBox = new QComboBox(); + themeComboBox->addItem("Light", QChart::ChartThemeLight); + themeComboBox->addItem("Blue Cerulean", QChart::ChartThemeBlueCerulean); + themeComboBox->addItem("Dark", QChart::ChartThemeDark); + themeComboBox->addItem("Brown Sand", QChart::ChartThemeBrownSand); + themeComboBox->addItem("Blue NCS", QChart::ChartThemeBlueNcs); + themeComboBox->addItem("High Contrast", QChart::ChartThemeHighContrast); + themeComboBox->addItem("Blue Icy", QChart::ChartThemeBlueIcy); + themeComboBox->addItem("Qt", QChart::ChartThemeQt); + return themeComboBox; +} + +QComboBox *ThemeWidget::createAnimationBox() const +{ + // settings layout + QComboBox *animationComboBox = new QComboBox(); + animationComboBox->addItem("No Animations", QChart::NoAnimation); + animationComboBox->addItem("GridAxis Animations", QChart::GridAxisAnimations); + animationComboBox->addItem("Series Animations", QChart::SeriesAnimations); + animationComboBox->addItem("All Animations", QChart::AllAnimations); + return animationComboBox; +} + +QComboBox *ThemeWidget::createLegendBox() const +{ + QComboBox *legendComboBox = new QComboBox(); + legendComboBox->addItem("No Legend ", 0); + legendComboBox->addItem("Legend Top", Qt::AlignTop); + legendComboBox->addItem("Legend Bottom", Qt::AlignBottom); + legendComboBox->addItem("Legend Left", Qt::AlignLeft); + legendComboBox->addItem("Legend Right", Qt::AlignRight); + return legendComboBox; +} + +QChart *ThemeWidget::createAreaChart() const +{ + QChart *chart = new QChart(); + chart->setTitle("Area chart"); + + // The lower series initialized to zero values + QLineSeries *lowerSeries = 0; + QString name("Series "); + int nameIndex = 0; + for (int i(0); i < m_dataTable.count(); i++) { + QLineSeries *upperSeries = new QLineSeries(chart); + for (int j(0); j < m_dataTable[i].count(); j++) { + Data data = m_dataTable[i].at(j); + if (lowerSeries) { + const QList& points = lowerSeries->points(); + upperSeries->append(QPointF(j, points[i].y() + data.first.y())); + } else { + upperSeries->append(QPointF(j, data.first.y())); + } + } + QAreaSeries *area = new QAreaSeries(upperSeries, lowerSeries); + area->setName(name + QString::number(nameIndex)); + nameIndex++; + chart->addSeries(area); + chart->createDefaultAxes(); + lowerSeries = upperSeries; + } + + return chart; +} + +QChart *ThemeWidget::createBarChart(int valueCount) const +{ + Q_UNUSED(valueCount); + QChart *chart = new QChart(); + chart->setTitle("Bar chart"); + + QStackedBarSeries *series = new QStackedBarSeries(chart); + for (int i(0); i < m_dataTable.count(); i++) { + QBarSet *set = new QBarSet("Bar set " + QString::number(i)); + foreach (Data data, m_dataTable[i]) + *set << data.first.y(); + series->append(set); + } + chart->addSeries(series); + chart->createDefaultAxes(); + + return chart; +} + +QChart *ThemeWidget::createLineChart() const +{ + QChart *chart = new QChart(); + chart->setTitle("Line chart"); + + QString name("Series "); + int nameIndex = 0; + foreach (DataList list, m_dataTable) { + QLineSeries *series = new QLineSeries(chart); + foreach (Data data, list) + series->append(data.first); + series->setName(name + QString::number(nameIndex)); + nameIndex++; + chart->addSeries(series); + } + chart->createDefaultAxes(); + + return chart; +} + +QChart *ThemeWidget::createPieChart() const +{ + QChart *chart = new QChart(); + chart->setTitle("Pie chart"); + + qreal pieSize = 1.0 / m_dataTable.count(); + for (int i = 0; i < m_dataTable.count(); i++) { + QPieSeries *series = new QPieSeries(chart); + foreach (Data data, m_dataTable[i]) { + QPieSlice *slice = series->append(data.second, data.first.y()); + if (data == m_dataTable[i].first()) { + slice->setLabelVisible(); + slice->setExploded(); + } + } + qreal hPos = (pieSize / 2) + (i / (qreal) m_dataTable.count()); + series->setPieSize(pieSize); + series->setHorizontalPosition(hPos); + series->setVerticalPosition(0.5); + chart->addSeries(series); + } + + return chart; +} + +QChart *ThemeWidget::createSplineChart() const +{ + // spine chart + QChart *chart = new QChart(); + chart->setTitle("Spline chart"); + QString name("Series "); + int nameIndex = 0; + foreach (DataList list, m_dataTable) { + QSplineSeries *series = new QSplineSeries(chart); + foreach (Data data, list) + series->append(data.first); + series->setName(name + QString::number(nameIndex)); + nameIndex++; + chart->addSeries(series); + } + chart->createDefaultAxes(); + return chart; +} + +QChart *ThemeWidget::createScatterChart() const +{ + // scatter chart + QChart *chart = new QChart(); + chart->setTitle("Scatter chart"); + QString name("Series "); + int nameIndex = 0; + foreach (DataList list, m_dataTable) { + QScatterSeries *series = new QScatterSeries(chart); + foreach (Data data, list) + series->append(data.first); + series->setName(name + QString::number(nameIndex)); + nameIndex++; + chart->addSeries(series); + } + chart->createDefaultAxes(); + return chart; +} + +void ThemeWidget::updateUI() +{ + QChart::ChartTheme theme = (QChart::ChartTheme) m_themeComboBox->itemData(m_themeComboBox->currentIndex()).toInt(); + + if (m_charts.at(0)->chart()->theme() != theme) { + foreach (QChartView *chartView, m_charts) + chartView->chart()->setTheme(theme); + + QPalette pal = window()->palette(); + if (theme == QChart::ChartThemeLight) { + pal.setColor(QPalette::Window, QRgb(0xf0f0f0)); + pal.setColor(QPalette::WindowText, QRgb(0x404044)); + } else if (theme == QChart::ChartThemeDark) { + pal.setColor(QPalette::Window, QRgb(0x121218)); + pal.setColor(QPalette::WindowText, QRgb(0xd6d6d6)); + } else if (theme == QChart::ChartThemeBlueCerulean) { + pal.setColor(QPalette::Window, QRgb(0x40434a)); + pal.setColor(QPalette::WindowText, QRgb(0xd6d6d6)); + } else if (theme == QChart::ChartThemeBrownSand) { + pal.setColor(QPalette::Window, QRgb(0x9e8965)); + pal.setColor(QPalette::WindowText, QRgb(0x404044)); + } else if (theme == QChart::ChartThemeBlueNcs) { + pal.setColor(QPalette::Window, QRgb(0x018bba)); + pal.setColor(QPalette::WindowText, QRgb(0x404044)); + } else if (theme == QChart::ChartThemeHighContrast) { + pal.setColor(QPalette::Window, QRgb(0xffab03)); + pal.setColor(QPalette::WindowText, QRgb(0x181818)); + } else if (theme == QChart::ChartThemeBlueIcy) { + pal.setColor(QPalette::Window, QRgb(0xcee7f0)); + pal.setColor(QPalette::WindowText, QRgb(0x404044)); + } else { + pal.setColor(QPalette::Window, QRgb(0xf0f0f0)); + pal.setColor(QPalette::WindowText, QRgb(0x404044)); + } + window()->setPalette(pal); + } + + bool checked = m_antialiasCheckBox->isChecked(); + foreach (QChartView *chart, m_charts) + chart->setRenderHint(QPainter::Antialiasing, checked); + + QChart::AnimationOptions options(m_animatedComboBox->itemData(m_animatedComboBox->currentIndex()).toInt()); + if (m_charts.at(0)->chart()->animationOptions() != options) { + foreach (QChartView *chartView, m_charts) + chartView->chart()->setAnimationOptions(options); + } + + Qt::Alignment alignment(m_legendComboBox->itemData(m_legendComboBox->currentIndex()).toInt()); + + if (!alignment) { + foreach (QChartView *chartView, m_charts) + chartView->chart()->legend()->hide(); + } else { + foreach (QChartView *chartView, m_charts) { + chartView->chart()->legend()->setAlignment(alignment); + chartView->chart()->legend()->show(); + } + } +} + diff --git a/examples/charts/chartthemes/themewidget.h b/examples/charts/chartthemes/themewidget.h new file mode 100644 index 00000000..d1a4d997 --- /dev/null +++ b/examples/charts/chartthemes/themewidget.h @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef THEMEWIDGET_H +#define THEMEWIDGET_H + +#include +#include + +class QComboBox; +class QCheckBox; + +QT_CHARTS_BEGIN_NAMESPACE +class QChartView; +class QChart; +QT_CHARTS_END_NAMESPACE + +typedef QPair Data; +typedef QList DataList; +typedef QList DataTable; + +QT_CHARTS_USE_NAMESPACE + +class ThemeWidget: public QWidget +{ + Q_OBJECT +public: + explicit ThemeWidget(QWidget *parent = 0); + ~ThemeWidget(); + +private Q_SLOTS: + void updateUI(); + +private: + DataTable generateRandomData(int listCount, int valueMax, int valueCount) const; + QComboBox *createThemeBox() const; + QComboBox *createAnimationBox() const; + QComboBox *createLegendBox() const; + void connectSignals(); + QChart *createAreaChart() const; + QChart *createBarChart(int valueCount) const; + QChart *createPieChart() const; + QChart *createLineChart() const; + QChart *createSplineChart() const; + QChart *createScatterChart() const; + +private: + int m_listCount; + int m_valueMax; + int m_valueCount; + QList m_charts; + DataTable m_dataTable; + + QComboBox *m_themeComboBox; + QCheckBox *m_antialiasCheckBox; + QComboBox *m_animatedComboBox; + QComboBox *m_legendComboBox; +}; + +#endif /* THEMEWIDGET_H */ diff --git a/examples/charts/customchart/customchart.pro b/examples/charts/customchart/customchart.pro new file mode 100644 index 00000000..5f3f7382 --- /dev/null +++ b/examples/charts/customchart/customchart.pro @@ -0,0 +1,6 @@ +!include( ../examples.pri ) { + error( "Couldn't find the examples.pri file!" ) +} + +TARGET = customchart +SOURCES += main.cpp diff --git a/examples/charts/customchart/main.cpp b/examples/charts/customchart/main.cpp new file mode 100644 index 00000000..8a35dfb1 --- /dev/null +++ b/examples/charts/customchart/main.cpp @@ -0,0 +1,131 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include + +QT_CHARTS_USE_NAMESPACE + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + +//![1] + QLineSeries *series = new QLineSeries(); + *series << QPointF(0, 6) << QPointF(9, 4) << QPointF(15, 20) << QPointF(25, 12) << QPointF(29, 26); + QChart *chart = new QChart(); + chart->legend()->hide(); + chart->addSeries(series); +//![1] + +//![2] + // Customize series + QPen pen(QRgb(0xfdb157)); + pen.setWidth(5); + series->setPen(pen); + + // Customize chart title + QFont font; + font.setPixelSize(18); + chart->setTitleFont(font); + chart->setTitleBrush(QBrush(Qt::white)); + chart->setTitle("Customchart example"); + + // Customize chart background + QLinearGradient backgroundGradient; + backgroundGradient.setStart(QPointF(0, 0)); + backgroundGradient.setFinalStop(QPointF(0, 1)); + backgroundGradient.setColorAt(0.0, QRgb(0xd2d0d1)); + backgroundGradient.setColorAt(1.0, QRgb(0x4c4547)); + backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode); + chart->setBackgroundBrush(backgroundGradient); + + // Customize plot area background + QLinearGradient plotAreaGradient; + plotAreaGradient.setStart(QPointF(0, 1)); + plotAreaGradient.setFinalStop(QPointF(1, 0)); + plotAreaGradient.setColorAt(0.0, QRgb(0x555555)); + plotAreaGradient.setColorAt(1.0, QRgb(0x55aa55)); + plotAreaGradient.setCoordinateMode(QGradient::ObjectBoundingMode); + chart->setPlotAreaBackgroundBrush(plotAreaGradient); + chart->setPlotAreaBackgroundVisible(true); +//![2] + +//![3] + QCategoryAxis *axisX = new QCategoryAxis(); + QCategoryAxis *axisY = new QCategoryAxis(); + + // Customize axis label font + QFont labelsFont; + labelsFont.setPixelSize(12); + axisX->setLabelsFont(labelsFont); + axisY->setLabelsFont(labelsFont); + + // Customize axis colors + QPen axisPen(QRgb(0xd18952)); + axisPen.setWidth(2); + axisX->setLinePen(axisPen); + axisY->setLinePen(axisPen); + + // Customize axis label colors + QBrush axisBrush(Qt::white); + axisX->setLabelsBrush(axisBrush); + axisY->setLabelsBrush(axisBrush); + + // Customize grid lines and shades + axisX->setGridLineVisible(false); + axisY->setGridLineVisible(false); + axisY->setShadesPen(Qt::NoPen); + axisY->setShadesBrush(QBrush(QColor(0x99, 0xcc, 0xcc, 0x55))); + axisY->setShadesVisible(true); +//![3] + +//![4] + axisX->append("low", 10); + axisX->append("optimal", 20); + axisX->append("high", 30); + axisX->setRange(0, 30); + + axisY->append("slow", 10); + axisY->append("med", 20); + axisY->append("fast", 30); + axisY->setRange(0, 30); + + chart->setAxisX(axisX, series); + chart->setAxisY(axisY, series); +//![4] + +//![5] + QChartView *chartView = new QChartView(chart); + chartView->setRenderHint(QPainter::Antialiasing); +//![5] + +//![6] + QMainWindow window; + window.setCentralWidget(chartView); + window.resize(400, 300); + window.show(); +//![6] + + return a.exec(); +} diff --git a/examples/charts/datetimeaxis/datetimeaxis.pro b/examples/charts/datetimeaxis/datetimeaxis.pro new file mode 100644 index 00000000..0ec9d715 --- /dev/null +++ b/examples/charts/datetimeaxis/datetimeaxis.pro @@ -0,0 +1,8 @@ +!include( ../examples.pri ) { + error( "Couldn't find the examples.pri file!" ) +} +TARGET = datetimeaxis +SOURCES += main.cpp + +RESOURCES += \ + sundata.qrc diff --git a/examples/charts/datetimeaxis/main.cpp b/examples/charts/datetimeaxis/main.cpp new file mode 100644 index 00000000..988b74f2 --- /dev/null +++ b/examples/charts/datetimeaxis/main.cpp @@ -0,0 +1,100 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +QT_CHARTS_USE_NAMESPACE + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + qsrand(QTime(0, 0, 0).secsTo(QTime::currentTime())); + + //![1] + QLineSeries *series = new QLineSeries(); + //![1] + + //![2] + // data from http://www.swpc.noaa.gov/ftpdir/weekly/RecentIndices.txt + // http://www.swpc.noaa.gov/ftpdir/weekly/README + // http://www.weather.gov/disclaimer + QFile sunSpots(":sun"); + if (!sunSpots.open(QIODevice::ReadOnly | QIODevice::Text)) { + return 1; + } + + QTextStream stream(&sunSpots); + while (!stream.atEnd()) { + QString line = stream.readLine(); + if (line.startsWith("#") || line.startsWith(":")) + continue; + QStringList values = line.split(" ", QString::SkipEmptyParts); + QDateTime momentInTime; + momentInTime.setDate(QDate(values[0].toInt(), values[1].toInt() , 15)); + series->append(momentInTime.toMSecsSinceEpoch(), values[2].toDouble()); + } + sunSpots.close(); + //![2] + + //![3] + QChart *chart = new QChart(); + chart->addSeries(series); + chart->legend()->hide(); + chart->setTitle("Sunspots count (by Space Weather Prediction Center)"); + //![3] + + //![4] + QDateTimeAxis *axisX = new QDateTimeAxis; + axisX->setTickCount(10); + axisX->setFormat("MMM yyyy"); + axisX->setTitleText("Date"); + chart->addAxis(axisX, Qt::AlignBottom); + series->attachAxis(axisX); + + QValueAxis *axisY = new QValueAxis; + axisY->setLabelFormat("%i"); + axisY->setTitleText("Sunspots count"); + chart->addAxis(axisY, Qt::AlignLeft); + series->attachAxis(axisY); + //![4] + + //![5] + QChartView *chartView = new QChartView(chart); + chartView->setRenderHint(QPainter::Antialiasing); + //![5] + + //![6] + QMainWindow window; + window.setCentralWidget(chartView); + window.resize(820, 600); + window.show(); + //![6] + + return a.exec(); +} diff --git a/examples/charts/datetimeaxis/sun_spots.txt b/examples/charts/datetimeaxis/sun_spots.txt new file mode 100644 index 00000000..91ef5982 --- /dev/null +++ b/examples/charts/datetimeaxis/sun_spots.txt @@ -0,0 +1,284 @@ +:Recent_Solar_Indices: RecentIndices.txt +:Created: 2012 Aug 06 0759 UTC +# Prepared by the U.S. Dept. of Commerce, NOAA, Space Weather Prediction Center (SWPC). +# Please send comments and suggestions to swpc.webmaster@noaa.gov +# +# Source SWO: SWPC Space Weather Operations (SWO). +# Source RI: S.I.D.C. Brussels International Sunspot Number. +# Source 10.7cm radio flux values (sfu): Penticton, B.C., Canada. +# +# Source Ap: GeoForschungsZentrum, Postdam, Germany +# Prior to January 1997, Institut fur Geophysik, Gottingen, Germany +# Source Ap for final month is NOAA/SWPC estimated Ap. +# +# Data not yet available or not calculable: -1.0 +# +# Values for most recent 6 months are considered preliminary. +# Final values from National Geophysical Data Center www.ngdc.noaa.gov +# +# Recent Solar Indices +# of Observed Monthly Mean Values +# +# -----------Sunspot Numbers--------- ----Radio Flux--- ---Geomagnetic--- +# ---Observed---- Ratio --Smoothed- Observed Smoothed Observed Smoothed +# YR MO SWO RI RI/SW SWO RI 10.7cm 10.7cm Ap Ap +#------------------------------------------------------------------------------- +1991 01 213.5 136.9 0.64 220.5 147.6 229.4 205.5 8 17.4 +1991 02 270.2 167.5 0.62 221.5 147.6 243.0 206.3 10 18.4 +1991 03 227.9 141.9 0.62 220.7 146.6 230.0 205.9 27 19.1 +1991 04 215.9 140.0 0.65 220.7 146.5 198.8 206.8 17 20.0 +1991 05 182.5 121.3 0.66 219.6 145.5 190.3 207.1 18 21.7 +1991 06 231.8 169.7 0.73 218.9 145.2 206.8 207.4 44 23.0 +1991 07 245.7 173.7 0.71 219.5 146.3 212.0 207.7 27 23.6 +1991 08 251.5 176.3 0.70 218.3 146.6 210.3 206.8 30 24.7 +1991 09 185.8 125.3 0.67 214.2 144.9 180.6 203.9 20 25.0 +1991 10 220.1 144.1 0.65 208.4 141.7 201.3 199.7 31 24.3 +1991 11 169.0 108.2 0.64 202.2 138.1 172.0 195.4 33 24.1 +1991 12 217.7 144.4 0.66 193.7 131.7 223.9 188.9 15 23.0 +1992 01 217.9 150.0 0.69 183.3 123.7 217.6 181.8 14 21.1 +1992 02 238.2 161.1 0.68 171.8 115.4 232.1 174.8 31 19.8 +1992 03 160.5 106.7 0.66 161.6 108.2 171.3 168.5 14 19.4 +1992 04 144.0 99.8 0.69 154.3 103.3 158.5 162.9 11 18.9 +1992 05 106.3 73.8 0.69 148.9 100.3 125.4 158.9 21 17.5 +1992 06 104.7 65.2 0.62 143.3 97.1 116.7 154.3 15 16.6 +1992 07 121.4 85.7 0.71 134.3 90.7 132.2 146.7 10 16.6 +1992 08 99.5 64.5 0.65 124.4 84.0 122.1 138.9 15 16.1 +1992 09 93.8 63.9 0.68 117.5 79.5 116.8 133.8 25 15.9 +1992 10 136.2 88.7 0.65 113.4 76.4 131.7 130.5 15 16.7 +1992 11 124.3 91.8 0.74 110.4 74.4 145.2 128.2 14 16.6 +1992 12 127.4 82.6 0.65 107.7 73.2 139.1 127.4 13 16.1 +1993 01 92.1 59.3 0.64 104.5 71.4 121.0 125.7 17 16.0 +1993 02 126.1 91.0 0.72 101.2 69.3 142.6 123.1 16 15.9 +1993 03 107.4 69.8 0.65 97.0 66.6 136.4 120.7 24 15.3 +1993 04 98.6 62.2 0.63 91.9 63.6 115.9 118.1 19 14.9 +1993 05 79.1 61.3 0.77 86.2 59.9 112.4 114.8 12 14.9 +1993 06 68.5 49.8 0.73 81.0 56.1 109.3 111.3 12 15.0 +1993 07 81.6 57.9 0.71 78.7 54.7 99.0 109.6 10 14.9 +1993 08 59.4 42.2 0.71 75.7 52.3 93.7 107.6 12 15.4 +1993 09 33.5 22.4 0.67 70.7 48.4 87.0 103.9 15 16.0 +1993 10 73.5 56.4 0.77 65.5 44.9 100.3 100.4 14 16.4 +1993 11 51.0 35.6 0.70 60.8 41.2 95.9 97.5 15 17.4 +1993 12 75.9 48.9 0.64 57.9 38.4 104.8 94.8 14 18.1 +1994 01 86.4 57.8 0.67 55.6 36.6 115.0 92.7 15 18.2 +1994 02 60.5 35.5 0.59 53.5 34.8 99.6 91.2 30 18.1 +1994 03 52.4 31.7 0.60 52.9 34.1 90.4 90.2 24 17.8 +1994 04 29.3 16.1 0.55 53.0 33.7 79.1 89.3 29 18.0 +1994 05 35.4 17.8 0.50 51.9 32.5 79.9 88.1 26 18.3 +1994 06 42.6 28.0 0.66 49.6 30.8 77.3 86.4 14 18.2 +1994 07 52.7 35.1 0.67 46.1 28.5 80.5 83.9 11 18.1 +1994 08 38.4 22.5 0.59 43.8 26.8 76.1 82.0 8 17.5 +1994 09 40.5 25.7 0.63 43.4 26.6 79.0 81.2 12 16.5 +1994 10 67.1 44.0 0.66 43.2 26.5 87.7 80.9 22 15.5 +1994 11 33.0 18.0 0.55 42.5 26.2 80.9 80.6 14 14.7 +1994 12 38.7 26.2 0.68 41.4 25.6 77.4 80.4 13 14.2 +1995 01 39.8 24.2 0.61 39.6 24.2 82.7 80.1 14 14.0 +1995 02 51.3 29.9 0.58 37.8 23.0 85.6 79.7 15 13.9 +1995 03 51.9 31.1 0.60 36.3 22.1 85.1 79.3 15 14.0 +1995 04 23.6 14.0 0.59 33.8 20.6 77.7 78.6 16 13.8 +1995 05 24.6 14.5 0.59 31.6 19.2 75.5 77.9 18 13.3 +1995 06 27.8 15.6 0.56 29.9 18.2 75.7 77.4 11 12.9 +1995 07 23.8 14.5 0.61 28.1 17.0 73.9 76.9 8 12.5 +1995 08 25.1 14.3 0.57 25.4 15.4 73.8 76.0 9 12.1 +1995 09 16.5 11.8 0.72 22.0 13.4 72.0 74.8 13 11.8 +1995 10 31.6 21.1 0.67 19.7 12.1 77.9 73.8 16 11.4 +1995 11 15.7 9.0 0.57 18.5 11.3 74.2 73.2 9 10.7 +1995 12 16.2 10.0 0.62 17.6 10.8 72.6 72.8 9 10.0 +1996 01 17.6 11.5 0.65 16.8 10.4 74.5 72.4 9 9.7 +1996 02 9.1 4.4 0.48 16.2 10.1 71.5 72.2 10 9.7 +1996 03 12.1 9.2 0.76 15.4 9.7 70.7 72.1 11 9.8 +1996 04 8.5 4.8 0.56 13.6 8.4 69.3 71.6 11 9.7 +1996 05 11.8 5.5 0.47 12.9 8.0 70.1 71.4 7 9.5 +1996 06 18.8 11.8 0.63 13.5 8.5 69.6 71.8 5 9.4 +1996 07 13.2 8.2 0.62 13.4 8.4 71.2 72.0 7 9.3 +1996 08 20.5 14.4 0.70 13.1 8.3 72.4 72.1 9 9.4 +1996 09 2.9 1.6 0.55 13.3 8.4 69.4 72.3 15 9.3 +1996 10 2.3 0.9 0.39 14.0 8.8 69.2 72.6 13 9.1 +1996 11 26.7 17.9 0.67 15.4 9.8 78.7 73.0 8 9.1 +1996 12 21.1 13.3 0.63 16.2 10.4 77.8 73.3 7 9.3 +1997 01 9.0 5.7 0.63 16.5 10.5 74.0 73.4 9 9.3 +1997 02 11.3 7.6 0.67 17.4 11.0 73.8 73.7 11 9.2 +1997 03 14.4 8.7 0.60 20.4 13.5 73.5 75.1 8 8.9 +1997 04 24.5 15.5 0.63 24.0 16.5 74.5 76.8 10 8.5 +1997 05 28.6 18.5 0.65 26.4 18.4 74.6 78.4 8 8.5 +1997 06 22.1 12.7 0.57 29.0 20.4 71.7 80.1 7 8.5 +1997 07 17.0 10.4 0.61 32.4 22.7 71.1 81.8 6 8.4 +1997 08 36.7 24.4 0.66 35.9 25.1 79.0 83.4 7 8.2 +1997 09 58.2 51.3 0.88 40.5 28.4 96.2 85.7 10 8.3 +1997 10 33.6 23.8 0.71 45.4 31.9 84.9 88.6 10 8.5 +1997 11 53.5 39.0 0.73 49.3 35.0 99.5 91.3 11 8.9 +1997 12 57.9 41.2 0.71 54.2 39.0 98.8 94.2 4 9.5 +1998 01 51.8 31.9 0.62 60.6 43.8 93.4 97.5 8 9.8 +1998 02 54.4 40.3 0.74 67.4 49.0 93.4 101.7 8 10.5 +1998 03 81.8 54.8 0.67 73.3 53.5 109.1 105.8 13 11.0 +1998 04 73.6 53.4 0.73 77.7 56.6 108.3 108.9 10 11.3 +1998 05 74.3 56.3 0.76 81.4 59.4 106.7 112.0 18 11.6 +1998 06 93.6 70.7 0.76 85.9 62.5 108.4 115.8 10 12.0 +1998 07 98.3 66.6 0.68 90.3 65.5 114.0 120.0 11 12.3 +1998 08 118.6 92.2 0.78 93.7 67.8 136.0 124.1 18 12.5 +1998 09 119.0 92.9 0.78 96.1 69.5 138.3 126.8 13 12.7 +1998 10 77.0 55.5 0.72 97.7 70.5 117.3 127.9 13 12.8 +1998 11 99.5 74.0 0.74 101.3 73.0 140.2 130.0 16 12.5 +1998 12 120.8 81.9 0.68 108.8 77.9 150.1 134.3 8 12.0 +1999 01 94.3 62.0 0.66 116.5 82.6 142.6 139.0 10 11.8 +1999 02 93.4 66.3 0.71 120.2 84.6 142.0 142.6 12 11.6 +1999 03 100.5 68.8 0.68 120.5 83.8 126.3 144.0 14 11.8 +1999 04 92.9 63.7 0.69 123.8 85.5 117.2 145.8 12 12.3 +1999 05 140.5 106.4 0.76 131.7 90.5 148.6 149.9 8 12.4 +1999 06 208.3 137.7 0.66 136.0 93.1 169.8 152.9 7 12.4 +1999 07 169.2 113.5 0.67 138.0 94.3 165.6 154.4 10 12.6 +1999 08 136.1 93.7 0.69 142.8 97.5 170.8 156.3 15 12.9 +1999 09 107.4 71.5 0.67 150.0 102.3 135.7 161.0 19 12.9 +1999 10 167.7 116.7 0.70 158.5 107.8 164.8 167.2 19 12.8 +1999 11 199.3 133.2 0.67 164.7 111.0 191.5 171.5 14 13.2 +1999 12 123.5 84.6 0.69 165.9 111.1 169.8 173.4 10 13.8 +2000 01 140.8 90.1 0.64 168.0 112.9 158.1 175.5 13 14.6 +2000 02 161.9 112.9 0.70 172.1 116.8 173.2 176.8 16 15.1 +2000 03 203.6 138.5 0.68 175.4 119.9 208.2 178.4 9 15.1 +2000 04 193.4 125.5 0.65 176.3 120.8 184.2 180.5 15 15.0 +2000 05 188.8 121.6 0.64 173.1 119.0 184.5 180.0 15 15.1 +2000 06 190.3 124.9 0.66 172.0 118.7 179.8 179.7 15 15.1 +2000 07 236.7 170.1 0.72 173.0 119.8 204.7 180.2 21 14.8 +2000 08 166.6 130.5 0.78 171.8 118.6 163.1 179.4 16 14.2 +2000 09 157.9 109.7 0.69 169.0 116.3 182.1 177.1 18 14.3 +2000 10 138.9 99.4 0.72 166.2 114.5 167.7 175.5 18 15.0 +2000 11 149.9 106.8 0.71 162.7 112.7 178.8 173.8 17 15.1 +2000 12 146.4 104.4 0.71 160.8 112.0 173.6 172.0 7 14.7 +2001 01 142.7 95.6 0.67 156.3 108.7 166.6 168.7 8 14.0 +2001 02 131.0 80.6 0.62 151.4 104.0 146.7 165.6 7 13.3 +2001 03 166.7 113.5 0.68 154.0 104.8 177.7 167.8 20 12.9 +2001 04 163.6 107.7 0.66 159.4 107.5 178.1 171.6 22 12.8 +2001 05 135.1 96.6 0.72 163.1 108.6 147.9 174.7 10 12.8 +2001 06 196.7 134.0 0.68 167.2 109.8 173.7 178.7 10 12.8 +2001 07 124.6 81.8 0.66 172.1 111.7 131.3 183.8 9 12.9 +2001 08 159.4 106.4 0.67 176.7 113.6 163.1 188.8 11 13.0 +2001 09 229.1 150.7 0.66 178.8 114.1 233.8 191.3 13 12.8 +2001 10 197.4 125.5 0.64 179.5 114.0 208.1 191.9 20 12.1 +2001 11 178.6 106.5 0.60 183.7 115.5 212.7 193.7 16 12.0 +2001 12 217.5 132.2 0.61 184.5 114.6 235.6 193.9 9 12.0 +2002 01 189.0 114.1 0.60 184.8 113.5 227.3 194.6 8 11.9 +2002 02 194.5 107.4 0.55 188.6 114.6 205.0 197.2 10 12.1 +2002 03 153.1 98.4 0.64 188.9 113.3 180.3 195.7 10 12.3 +2002 04 194.9 120.7 0.62 186.2 110.5 189.8 191.5 17 12.5 +2002 05 204.1 120.8 0.59 183.6 108.8 178.4 188.0 12 12.7 +2002 06 146.0 88.3 0.60 179.9 106.2 148.7 182.9 7 12.9 +2002 07 183.5 99.6 0.54 175.4 102.7 173.5 176.2 11 13.3 +2002 08 191.0 116.4 0.61 169.2 98.7 183.9 169.3 14 13.8 +2002 09 206.4 109.6 0.53 163.4 94.6 175.8 164.0 13 14.5 +2002 10 153.9 97.5 0.63 158.8 90.5 167.0 159.3 25 15.1 +2002 11 159.8 95.5 0.60 150.9 85.2 168.7 154.1 17 15.8 +2002 12 147.9 80.8 0.55 145.0 82.0 157.2 150.7 13 17.1 +2003 01 149.3 79.7 0.53 141.7 80.8 144.0 148.0 13 18.2 +2003 02 87.0 46.0 0.53 136.4 78.3 124.5 143.5 17 18.9 +2003 03 119.7 61.1 0.51 128.1 74.0 132.2 138.3 21 19.5 +2003 04 119.7 60.0 0.50 121.5 70.1 126.3 135.0 20 20.1 +2003 05 89.6 54.6 0.61 118.3 67.6 116.2 133.1 26 21.0 +2003 06 118.4 77.4 0.65 113.6 65.0 129.3 130.2 24 21.5 +2003 07 132.8 83.3 0.63 106.9 61.8 127.7 127.2 19 22.0 +2003 08 114.3 72.7 0.64 102.8 60.0 122.1 125.2 23 22.3 +2003 09 82.6 48.7 0.59 100.7 59.5 112.2 123.7 18 21.8 +2003 10 118.9 65.5 0.55 96.6 58.2 151.3 121.8 35 21.1 +2003 11 118.9 67.3 0.57 93.6 56.7 140.8 120.1 28 20.0 +2003 12 75.4 46.5 0.62 91.4 54.8 115.0 118.0 16 18.6 +2004 01 62.3 37.3 0.60 87.9 52.0 114.1 116.3 22 18.1 +2004 02 75.6 45.8 0.61 84.2 49.3 107.0 115.5 13 17.7 +2004 03 81.0 49.1 0.61 80.9 47.1 112.0 114.6 14 16.7 +2004 04 59.3 39.3 0.66 77.9 45.5 101.2 112.4 11 15.2 +2004 05 77.3 41.5 0.54 74.1 43.8 99.8 109.3 8 14.0 +2004 06 78.9 43.2 0.55 70.4 41.6 97.4 107.4 8 13.6 +2004 07 87.8 51.1 0.58 68.3 40.2 118.5 106.1 23 13.5 +2004 08 69.5 40.9 0.59 66.6 39.2 111.0 105.2 9 13.5 +2004 09 50.0 27.7 0.55 63.7 37.5 103.0 103.8 9 13.3 +2004 10 77.9 48.0 0.62 61.3 35.9 105.9 102.3 8 13.3 +2004 11 70.5 43.5 0.62 60.0 35.3 113.7 101.6 25 13.7 +2004 12 34.7 17.9 0.52 58.8 35.2 95.0 101.5 11 14.3 +2005 01 52.0 31.3 0.60 57.3 34.6 102.2 100.4 24 14.1 +2005 02 45.4 29.2 0.64 56.4 33.9 97.2 98.6 11 14.0 +2005 03 41.0 24.5 0.60 55.8 33.5 89.9 97.3 12 14.6 +2005 04 41.5 24.2 0.58 52.6 31.6 86.0 95.5 11 15.1 +2005 05 65.4 42.7 0.65 48.3 28.9 99.5 93.2 19 14.4 +2005 06 59.8 39.3 0.66 47.9 28.8 93.7 91.9 12 13.6 +2005 07 71.0 40.1 0.56 48.1 29.1 96.5 90.9 14 12.8 +2005 08 65.6 36.4 0.55 45.4 27.4 90.5 89.2 14 11.8 +2005 09 39.2 21.9 0.56 42.9 25.8 91.1 87.8 20 11.4 +2005 10 13.0 8.7 0.67 42.6 25.5 76.6 87.3 8 11.3 +2005 11 32.2 18.0 0.56 42.1 24.9 86.2 86.7 8 10.8 +2005 12 62.6 41.1 0.66 40.1 23.0 90.7 85.2 9 10.0 +2006 01 28.0 15.3 0.55 37.2 20.8 83.4 83.6 6 9.5 +2006 02 5.3 4.9 0.92 33.4 18.6 76.5 82.3 6 9.0 +2006 03 21.3 10.6 0.50 31.0 17.4 75.5 81.2 8 8.3 +2006 04 55.2 30.2 0.55 30.6 17.1 89.0 80.6 11 7.8 +2006 05 39.6 22.3 0.56 30.7 17.3 80.9 80.5 7 7.9 +2006 06 37.7 13.9 0.37 28.9 16.3 76.5 80.2 7 8.2 +2006 07 22.6 12.2 0.54 27.2 15.2 75.8 80.0 6 8.6 +2006 08 22.8 12.9 0.57 27.6 15.6 79.4 80.1 9 8.8 +2006 09 25.2 14.4 0.57 27.7 15.5 77.8 80.0 8 8.8 +2006 10 15.7 10.5 0.67 25.2 14.2 74.3 79.1 9 8.8 +2006 11 31.5 21.4 0.68 22.3 12.6 86.3 78.2 9 8.7 +2006 12 22.2 13.6 0.61 20.7 12.1 84.5 77.8 15 8.7 +2007 01 26.6 16.8 0.63 19.7 11.9 83.5 77.5 10 8.7 +2007 02 17.2 10.7 0.62 18.9 11.5 77.7 76.9 7 8.6 +2007 03 9.7 4.5 0.46 17.5 10.7 72.2 76.0 8 8.5 +2007 04 6.9 3.4 0.49 16.0 9.8 72.4 75.3 9 8.5 +2007 05 19.4 11.7 0.60 14.2 8.6 74.4 74.3 8 8.3 +2007 06 20.0 12.1 0.61 12.8 7.6 73.7 73.3 6 7.9 +2007 07 15.6 9.7 0.62 11.6 6.9 71.6 72.7 7 7.4 +2007 08 9.9 6.0 0.61 10.2 6.0 69.1 72.1 6 7.5 +2007 09 4.8 2.4 0.50 9.9 5.9 67.0 71.8 9 7.8 +2007 10 1.3 0.9 0.69 10.0 6.0 67.5 71.8 7 7.9 +2007 11 2.5 1.7 0.68 9.4 5.7 69.6 71.4 7 7.8 +2007 12 16.2 10.1 0.62 8.1 4.9 78.5 70.8 6 7.8 +2008 01 5.1 3.3 0.65 6.9 4.2 74.3 70.3 8 7.8 +2008 02 3.8 2.1 0.55 5.9 3.6 71.1 69.9 11 7.6 +2008 03 15.9 9.3 0.58 5.3 3.3 72.9 69.8 11 7.5 +2008 04 4.9 2.9 0.59 5.3 3.4 70.2 69.8 9 7.3 +2008 05 5.7 3.2 0.56 5.7 3.5 68.4 69.8 6 7.2 +2008 06 4.2 3.4 0.81 5.2 3.3 65.9 69.4 7 7.0 +2008 07 1.0 0.8 0.80 4.5 2.8 65.7 68.8 5 6.8 +2008 08 0.0 0.5 -1.00 4.4 2.7 66.3 68.6 5 6.3 +2008 09 1.5 1.1 0.73 3.7 2.3 67.1 68.4 6 5.8 +2008 10 5.2 2.9 0.56 2.9 1.8 68.3 68.2 7 5.4 +2008 11 6.8 4.1 0.60 2.7 1.7 68.6 68.3 4 5.1 +2008 12 1.3 0.8 0.62 2.7 1.7 69.2 68.5 4 4.9 +2009 01 2.8 1.3 0.46 3.0 1.8 69.8 68.7 4 4.7 +2009 02 2.5 1.4 0.56 3.1 1.9 70.0 68.8 5 4.7 +2009 03 0.7 0.7 1.00 3.4 2.0 69.2 69.0 5 4.6 +2009 04 1.2 0.8 1.00 3.7 2.2 69.7 69.3 4 4.3 +2009 05 3.9 2.9 0.74 3.8 2.3 70.5 69.7 4 4.1 +2009 06 6.6 2.9 0.39 4.4 2.7 68.6 70.2 4 4.0 +2009 07 5.0 3.2 0.70 5.8 3.6 68.2 71.0 4 3.9 +2009 08 0.3 0.0 0.00 7.7 4.8 67.4 72.1 5 3.8 +2009 09 6.6 4.3 0.64 9.9 6.2 70.5 73.3 4 3.8 +2009 10 7.0 4.8 0.66 11.3 7.1 72.3 74.1 3 4.1 +2009 11 7.7 4.1 0.55 12.4 7.6 73.6 74.5 3 4.5 +2009 12 15.7 10.8 0.68 13.6 8.3 76.8 74.9 2 4.8 +2010 01 21.3 13.2 0.62 14.8 9.3 81.1 75.5 3 5.0 +2010 02 31.0 18.8 0.60 16.7 10.6 84.7 76.5 5 5.1 +2010 03 24.7 15.4 0.62 19.1 12.3 83.3 77.5 5 5.3 +2010 04 11.2 8.0 0.71 21.4 14.0 75.9 78.3 10 5.5 +2010 05 19.9 8.7 0.44 23.8 15.5 73.8 79.0 8 5.7 +2010 06 17.9 13.6 0.75 25.2 16.4 72.6 79.7 7 5.8 +2010 07 23.1 16.1 0.70 25.9 16.7 79.9 80.1 5 6.0 +2010 08 28.2 19.6 0.70 27.3 17.4 79.7 80.7 8 6.2 +2010 09 35.6 25.2 0.71 30.6 19.6 81.1 82.4 5 6.3 +2010 10 35.0 23.5 0.67 35.9 23.2 81.6 85.3 6 6.4 +2010 11 36.1 21.5 0.60 40.5 26.5 82.5 87.7 5 6.4 +2010 12 22.0 14.4 0.66 43.8 28.8 84.3 89.6 4 6.5 +2011 01 32.1 18.8 0.59 47.2 30.9 83.7 91.2 6 6.7 +2011 02 53.2 29.6 0.55 50.6 33.4 94.5 92.7 6 6.8 +2011 03 81.0 55.8 0.69 55.2 36.9 115.3 95.8 7 7.2 +2011 04 81.7 54.4 0.67 61.5 41.8 112.6 100.4 9 7.5 +2011 05 61.4 41.5 0.68 69.0 47.6 95.9 105.6 9 7.5 +2011 06 55.5 37.0 0.67 76.5 53.2 95.8 110.9 8 7.4 +2011 07 67.0 43.8 0.66 82.5 57.2 94.2 115.4 9 7.3 +2011 08 66.1 50.6 0.77 84.9 59.0 101.7 117.9 8 7.4 +2011 09 106.4 78.0 0.73 84.6 59.5 134.5 118.4 13 7.7 +2011 10 116.8 88.0 0.75 84.6 59.9 137.2 118.4 7 8.0 +2011 11 133.1 96.7 0.73 86.3 61.1 153.1 119.5 3 8.0 +2011 12 106.3 73.0 0.69 89.2 63.4 141.2 121.6 3 8.0 +2012 01 91.3 58.3 0.64 92.0 65.5 133.1 124.4 6 8.3 +2012 02 50.1 32.9 0.66 -1.0 -1.0 106.7 -1.0 7 -1.0 +2012 03 77.9 64.3 0.82 -1.0 -1.0 115.1 -1.0 14 -1.0 +2012 04 84.4 55.2 0.65 -1.0 -1.0 113.1 -1.0 9 -1.0 +2012 05 99.5 69.0 0.69 -1.0 -1.0 121.5 -1.0 8 -1.0 +2012 06 88.6 64.5 0.73 -1.0 -1.0 120.5 -1.0 10 -1.0 +2012 07 99.6 66.5 0.67 -1.0 -1.0 135.6 -1.0 13 -1.0 diff --git a/examples/charts/datetimeaxis/sundata.qrc b/examples/charts/datetimeaxis/sundata.qrc new file mode 100644 index 00000000..318be590 --- /dev/null +++ b/examples/charts/datetimeaxis/sundata.qrc @@ -0,0 +1,5 @@ + + + sun_spots.txt + + diff --git a/examples/charts/donutbreakdown/donutbreakdown.pro b/examples/charts/donutbreakdown/donutbreakdown.pro new file mode 100644 index 00000000..fecef7b8 --- /dev/null +++ b/examples/charts/donutbreakdown/donutbreakdown.pro @@ -0,0 +1,12 @@ +!include( ../examples.pri ) { + error( "Couldn't find the examples.pri file!" ) +} + +TARGET = donutbreakdown +SOURCES += main.cpp\ + donutbreakdownchart.cpp \ + mainslice.cpp + +HEADERS += \ + donutbreakdownchart.h \ + mainslice.h diff --git a/examples/charts/donutbreakdown/donutbreakdownchart.cpp b/examples/charts/donutbreakdown/donutbreakdownchart.cpp new file mode 100644 index 00000000..5272f105 --- /dev/null +++ b/examples/charts/donutbreakdown/donutbreakdownchart.cpp @@ -0,0 +1,110 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "donutbreakdownchart.h" +#include "mainslice.h" +#include +#include + +QT_CHARTS_USE_NAMESPACE + +//![1] +DonutBreakdownChart::DonutBreakdownChart(QGraphicsItem *parent, Qt::WindowFlags wFlags) + : QChart(QChart::ChartTypeCartesian, parent, wFlags) +{ + // create the series for main center pie + m_mainSeries = new QPieSeries(); + m_mainSeries->setPieSize(0.7); + QChart::addSeries(m_mainSeries); +} +//![1] + +//![2] +void DonutBreakdownChart::addBreakdownSeries(QPieSeries *breakdownSeries, QColor color) +{ + QFont font("Arial", 8); + + // add breakdown series as a slice to center pie + MainSlice *mainSlice = new MainSlice(breakdownSeries); + mainSlice->setName(breakdownSeries->name()); + mainSlice->setValue(breakdownSeries->sum()); + m_mainSeries->append(mainSlice); + + // customize the slice + mainSlice->setBrush(color); + mainSlice->setLabelVisible(); + mainSlice->setLabelColor(Qt::white); + mainSlice->setLabelPosition(QPieSlice::LabelInsideHorizontal); + mainSlice->setLabelFont(font); + + // position and customize the breakdown series + breakdownSeries->setPieSize(0.8); + breakdownSeries->setHoleSize(0.7); + breakdownSeries->setLabelsVisible(); + foreach (QPieSlice *slice, breakdownSeries->slices()) { + color = color.lighter(115); + slice->setBrush(color); + slice->setLabelFont(font); + } + + // add the series to the chart + QChart::addSeries(breakdownSeries); + + // recalculate breakdown donut segments + recalculateAngles(); + + // update customize legend markers + updateLegendMarkers(); +} +//![2] + +//![3] +void DonutBreakdownChart::recalculateAngles() +{ + qreal angle = 0; + foreach (QPieSlice *slice, m_mainSeries->slices()) { + QPieSeries *breakdownSeries = qobject_cast(slice)->breakdownSeries(); + breakdownSeries->setPieStartAngle(angle); + angle += slice->percentage() * 360.0; // full pie is 360.0 + breakdownSeries->setPieEndAngle(angle); + } +} +//![3] + +//![4] +void DonutBreakdownChart::updateLegendMarkers() +{ + // go through all markers + foreach (QAbstractSeries *series, QChart::series()) { + foreach (QLegendMarker *marker, legend()->markers(series)) { + QPieLegendMarker *pieMarker = qobject_cast(marker); + if (series == m_mainSeries) { + // hide markers from main series + pieMarker->setVisible(false); + } else { + // modify markers from breakdown series + pieMarker->setLabel(QString("%1 %2%") + .arg(pieMarker->slice()->label()) + .arg(pieMarker->slice()->percentage() * 100, 0, 'f', 2)); + pieMarker->setFont(QFont("Arial", 8)); + } + } + } +} +//![4] diff --git a/examples/charts/donutbreakdown/donutbreakdownchart.h b/examples/charts/donutbreakdown/donutbreakdownchart.h new file mode 100644 index 00000000..71b3ecf4 --- /dev/null +++ b/examples/charts/donutbreakdown/donutbreakdownchart.h @@ -0,0 +1,42 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef DONUTBREAKDOWNCHART_H +#define DONUTBREAKDOWNCHART_H + +#include +#include + +QT_CHARTS_USE_NAMESPACE + +class DonutBreakdownChart : public QChart +{ +public: + DonutBreakdownChart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0); + void addBreakdownSeries(QPieSeries *series, QColor color); + +private: + void recalculateAngles(); + void updateLegendMarkers(); + +private: + QPieSeries *m_mainSeries; +}; + +#endif // DONUTBREAKDOWNCHART_H diff --git a/examples/charts/donutbreakdown/main.cpp b/examples/charts/donutbreakdown/main.cpp new file mode 100644 index 00000000..fb3925b6 --- /dev/null +++ b/examples/charts/donutbreakdown/main.cpp @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include "donutbreakdownchart.h" + +QT_CHARTS_USE_NAMESPACE + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + + //![1] + // Graph is based on data of 'Total consumption of energy increased by 10 per cent in 2010' + // Statistics Finland, 13 December 2011 + // http://www.stat.fi/til/ekul/2010/ekul_2010_2011-12-13_tie_001_en.html + + QPieSeries *series1 = new QPieSeries(); + series1->setName("Fossil fuels"); + series1->append("Oil", 353295); + series1->append("Coal", 188500); + series1->append("Natural gas", 148680); + series1->append("Peat", 94545); + + QPieSeries *series2 = new QPieSeries(); + series2->setName("Renewables"); + series2->append("Wood fuels", 319663); + series2->append("Hydro power", 45875); + series2->append("Wind power", 1060); + + QPieSeries *series3 = new QPieSeries(); + series3->setName("Others"); + series3->append("Nuclear energy", 238789); + series3->append("Import energy", 37802); + series3->append("Other", 32441); + //![1] + + //![2] + DonutBreakdownChart *donutBreakdown = new DonutBreakdownChart(); + donutBreakdown->setAnimationOptions(QChart::AllAnimations); + donutBreakdown->setTitle("Total consumption of energy in Finland 2010"); + donutBreakdown->legend()->setAlignment(Qt::AlignRight); + donutBreakdown->addBreakdownSeries(series1, Qt::red); + donutBreakdown->addBreakdownSeries(series2, Qt::darkGreen); + donutBreakdown->addBreakdownSeries(series3, Qt::darkBlue); + //![2] + + //![3] + QMainWindow window; + QChartView *chartView = new QChartView(donutBreakdown); + chartView->setRenderHint(QPainter::Antialiasing); + window.setCentralWidget(chartView); + window.resize(800, 500); + window.show(); + //![3] + + return a.exec(); +} diff --git a/examples/charts/donutbreakdown/mainslice.cpp b/examples/charts/donutbreakdown/mainslice.cpp new file mode 100644 index 00000000..0ac83b3c --- /dev/null +++ b/examples/charts/donutbreakdown/mainslice.cpp @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "mainslice.h" + +QT_CHARTS_USE_NAMESPACE + +//![1] +MainSlice::MainSlice(QPieSeries *breakdownSeries, QObject *parent) + : QPieSlice(parent), + m_breakdownSeries(breakdownSeries) +{ + connect(this, SIGNAL(percentageChanged()), this, SLOT(updateLabel())); +} +//![1] + +QPieSeries *MainSlice::breakdownSeries() const +{ + return m_breakdownSeries; +} + +void MainSlice::setName(QString name) +{ + m_name = name; +} + +QString MainSlice::name() const +{ + return m_name; +} + +//![2] +void MainSlice::updateLabel() +{ + this->setLabel(QString("%1 %2%").arg(m_name).arg(percentage() * 100, 0, 'f', 2)); +} +//![2] + +#include "moc_mainslice.cpp" + diff --git a/examples/charts/donutbreakdown/mainslice.h b/examples/charts/donutbreakdown/mainslice.h new file mode 100644 index 00000000..6c6d63c2 --- /dev/null +++ b/examples/charts/donutbreakdown/mainslice.h @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef MAINSLICE_H +#define MAINSLICE_H + +#include +#include + +QT_CHARTS_USE_NAMESPACE + +class MainSlice : public QPieSlice +{ + Q_OBJECT +public: + MainSlice(QPieSeries *breakdownSeries, QObject *parent = 0); + + QPieSeries *breakdownSeries() const; + + void setName(QString name); + QString name() const; + +public Q_SLOTS: + void updateLabel(); + +private: + QPieSeries *m_breakdownSeries; + QString m_name; +}; + +#endif // MAINSLICE_H diff --git a/examples/charts/donutchart/donutchart.pro b/examples/charts/donutchart/donutchart.pro new file mode 100644 index 00000000..72d4ea4d --- /dev/null +++ b/examples/charts/donutchart/donutchart.pro @@ -0,0 +1,5 @@ +!include( ../examples.pri ) { + error( "Couldn't find the examples.pri file!" ) +} +TARGET = donutchart +SOURCES += main.cpp diff --git a/examples/charts/donutchart/main.cpp b/examples/charts/donutchart/main.cpp new file mode 100644 index 00000000..78b2a7c3 --- /dev/null +++ b/examples/charts/donutchart/main.cpp @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +QT_CHARTS_USE_NAMESPACE + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + +//![1] + QPieSeries *series = new QPieSeries(); + series->setHoleSize(0.35); + series->append("Protein 4.2%", 4.2); + QPieSlice *slice = series->append("Fat 15.6%", 15.6); + slice->setExploded(); + slice->setLabelVisible(); + series->append("Other 23.8%", 23.8); + series->append("Carbs 56.4%", 56.4); +//![1] + +//![2] + QChartView *chartView = new QChartView(); + chartView->setRenderHint(QPainter::Antialiasing); + chartView->chart()->setTitle("Donut with a lemon glaze (100g)"); + chartView->chart()->addSeries(series); + chartView->chart()->legend()->setAlignment(Qt::AlignBottom); + chartView->chart()->setTheme(QChart::ChartThemeBlueCerulean); + chartView->chart()->legend()->setFont(QFont("Arial", 7)); +//![2] + +//![3] + QMainWindow window; + window.setCentralWidget(chartView); + window.resize(400, 300); + window.show(); +//![3] + + return a.exec(); +} diff --git a/examples/charts/dynamicspline/chart.cpp b/examples/charts/dynamicspline/chart.cpp new file mode 100644 index 00000000..4c7bc355 --- /dev/null +++ b/examples/charts/dynamicspline/chart.cpp @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "chart.h" +#include +#include +#include +#include +#include + +Chart::Chart(QGraphicsItem *parent, Qt::WindowFlags wFlags): + QChart(QChart::ChartTypeCartesian, parent, wFlags), + m_series(0), + m_axis(new QValueAxis), + m_step(0), + m_x(5), + m_y(1) +{ + qsrand((uint) QTime::currentTime().msec()); + + QObject::connect(&m_timer, SIGNAL(timeout()), this, SLOT(handleTimeout())); + m_timer.setInterval(1000); + + m_series = new QSplineSeries(this); + QPen green(Qt::red); + green.setWidth(3); + m_series->setPen(green); + m_series->append(m_x, m_y); + + addSeries(m_series); + createDefaultAxes(); + setAxisX(m_axis, m_series); + m_axis->setTickCount(5); + axisX()->setRange(0, 10); + axisY()->setRange(-5, 10); + + m_timer.start(); +} + +Chart::~Chart() +{ + +} + +void Chart::handleTimeout() +{ + qreal x = plotArea().width() / m_axis->tickCount(); + qreal y = (m_axis->max() - m_axis->min()) / m_axis->tickCount(); + m_x += y; + m_y = qrand() % 5 - 2.5; + m_series->append(m_x, m_y); + scroll(x, 0); + if (m_x == 100) + m_timer.stop(); +} diff --git a/examples/charts/dynamicspline/chart.h b/examples/charts/dynamicspline/chart.h new file mode 100644 index 00000000..b6d5eb1c --- /dev/null +++ b/examples/charts/dynamicspline/chart.h @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef CHART_H +#define CHART_H + +#include +#include + +QT_CHARTS_BEGIN_NAMESPACE +class QSplineSeries; +class QValueAxis; +QT_CHARTS_END_NAMESPACE + +QT_CHARTS_USE_NAMESPACE + +//![1] +class Chart: public QChart +{ + Q_OBJECT +public: + Chart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0); + virtual ~Chart(); + +public slots: + void handleTimeout(); + +private: + QTimer m_timer; + QSplineSeries *m_series; + QStringList m_titles; + QValueAxis *m_axis; + qreal m_step; + qreal m_x; + qreal m_y; +}; +//![1] + +#endif /* CHART_H */ diff --git a/examples/charts/dynamicspline/dynamicspline.pro b/examples/charts/dynamicspline/dynamicspline.pro new file mode 100644 index 00000000..feb26895 --- /dev/null +++ b/examples/charts/dynamicspline/dynamicspline.pro @@ -0,0 +1,7 @@ +!include( ../examples.pri ) { + error( "Couldn't find the examples.pri file!" ) +} + +TARGET = dynamicspline +HEADERS += chart.h +SOURCES += main.cpp chart.cpp diff --git a/examples/charts/dynamicspline/main.cpp b/examples/charts/dynamicspline/main.cpp new file mode 100644 index 00000000..00f18c2f --- /dev/null +++ b/examples/charts/dynamicspline/main.cpp @@ -0,0 +1,42 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "chart.h" +#include +#include +#include + +QT_CHARTS_USE_NAMESPACE + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + QMainWindow window; + Chart *chart = new Chart; + chart->setTitle("Dynamic spline chart"); + chart->legend()->hide(); + chart->setAnimationOptions(QChart::AllAnimations); + QChartView chartView(chart); + chartView.setRenderHint(QPainter::Antialiasing); + window.setCentralWidget(&chartView); + window.resize(400, 300); + window.show(); + return a.exec(); +} diff --git a/examples/charts/examples.pri b/examples/charts/examples.pri new file mode 100644 index 00000000..7b2eaaa7 --- /dev/null +++ b/examples/charts/examples.pri @@ -0,0 +1,17 @@ + +INCLUDEPATH += ../../../include + +LIBS += -L$$OUT_PWD/../../../lib + +TEMPLATE = app + +QT += charts +QT += core gui widgets + +contains(TARGET, qml.*) { + QT += qml quick +} + +target.path = $$[QT_INSTALL_EXAMPLES]/charts/$$TARGET +INSTALLS += target + diff --git a/examples/charts/horizontalbarchart/horizontalbarchart.pro b/examples/charts/horizontalbarchart/horizontalbarchart.pro new file mode 100644 index 00000000..61ec088e --- /dev/null +++ b/examples/charts/horizontalbarchart/horizontalbarchart.pro @@ -0,0 +1,6 @@ +!include( ../examples.pri ) { + error( "Couldn't find the examples.pri file!" ) +} + +TARGET = horizontalbarchart +SOURCES += main.cpp diff --git a/examples/charts/horizontalbarchart/main.cpp b/examples/charts/horizontalbarchart/main.cpp new file mode 100644 index 00000000..725aa127 --- /dev/null +++ b/examples/charts/horizontalbarchart/main.cpp @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +QT_CHARTS_USE_NAMESPACE + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + +//![1] + QBarSet *set0 = new QBarSet("Jane"); + QBarSet *set1 = new QBarSet("John"); + QBarSet *set2 = new QBarSet("Axel"); + QBarSet *set3 = new QBarSet("Mary"); + QBarSet *set4 = new QBarSet("Samantha"); + + *set0 << 1 << 2 << 3 << 4 << 5 << 6; + *set1 << 5 << 0 << 0 << 4 << 0 << 7; + *set2 << 3 << 5 << 8 << 13 << 8 << 5; + *set3 << 5 << 6 << 7 << 3 << 4 << 5; + *set4 << 9 << 7 << 5 << 3 << 1 << 2; +//![1] + +//![2] + QHorizontalBarSeries *series = new QHorizontalBarSeries(); + series->append(set0); + series->append(set1); + 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->setAnimationOptions(QChart::SeriesAnimations); +//![3] + +//![4] + QStringList categories; + categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; + QBarCategoryAxis *axisY = new QBarCategoryAxis(); + axisY->append(categories); + chart->setAxisY(axisY, series); + QValueAxis *axisX = new QValueAxis(); + chart->setAxisX(axisX, series); + axisX->applyNiceNumbers(); +//![4] + +//![5] + chart->legend()->setVisible(true); + chart->legend()->setAlignment(Qt::AlignBottom); +//![5] + +//![6] + QChartView *chartView = new QChartView(chart); + chartView->setRenderHint(QPainter::Antialiasing); +//![6] + +//![7] + QMainWindow window; + window.setCentralWidget(chartView); + window.resize(420, 300); + window.show(); +//![7] + + return a.exec(); +} diff --git a/examples/charts/horizontalpercentbarchart/horizontalpercentbarchart.pro b/examples/charts/horizontalpercentbarchart/horizontalpercentbarchart.pro new file mode 100644 index 00000000..d6168695 --- /dev/null +++ b/examples/charts/horizontalpercentbarchart/horizontalpercentbarchart.pro @@ -0,0 +1,6 @@ +!include( ../examples.pri ) { + error( "Couldn't find the examples.pri file!" ) +} + +TARGET = horizontalpercentbarchart +SOURCES += main.cpp diff --git a/examples/charts/horizontalpercentbarchart/main.cpp b/examples/charts/horizontalpercentbarchart/main.cpp new file mode 100644 index 00000000..d8adab49 --- /dev/null +++ b/examples/charts/horizontalpercentbarchart/main.cpp @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include + +QT_CHARTS_USE_NAMESPACE + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + +//![1] + QBarSet *set0 = new QBarSet("Jane"); + QBarSet *set1 = new QBarSet("John"); + QBarSet *set2 = new QBarSet("Axel"); + QBarSet *set3 = new QBarSet("Mary"); + QBarSet *set4 = new QBarSet("Samantha"); + + *set0 << 1 << 2 << 3 << 4 << 5 << 6; + *set1 << 5 << 0 << 0 << 4 << 0 << 7; + *set2 << 3 << 5 << 8 << 13 << 8 << 5; + *set3 << 5 << 6 << 7 << 3 << 4 << 5; + *set4 << 9 << 7 << 5 << 3 << 1 << 2; +//![1] + +//![2] + QHorizontalPercentBarSeries *series = new QHorizontalPercentBarSeries(); + series->append(set0); + series->append(set1); + series->append(set2); + series->append(set3); + series->append(set4); + +//![2] + +//![3] + QChart *chart = new QChart(); + chart->addSeries(series); + chart->setTitle("Simple horizontal percent barchart example"); + chart->setAnimationOptions(QChart::SeriesAnimations); +//![3] + +//![4] + QStringList categories; + categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; + QBarCategoryAxis *axis = new QBarCategoryAxis(); + axis->append(categories); + chart->createDefaultAxes(); + chart->setAxisY(axis, series); +//![4] + +//![5] + chart->legend()->setVisible(true); + chart->legend()->setAlignment(Qt::AlignBottom); +//![5] + +//![6] + QChartView *chartView = new QChartView(chart); + chartView->setRenderHint(QPainter::Antialiasing); +//![6] + +//![7] + QMainWindow window; + window.setCentralWidget(chartView); + window.resize(420, 300); + window.show(); +//![7] + + return a.exec(); +} diff --git a/examples/charts/horizontalstackedbarchart/horizontalstackedbarchart.pro b/examples/charts/horizontalstackedbarchart/horizontalstackedbarchart.pro new file mode 100644 index 00000000..5c08d212 --- /dev/null +++ b/examples/charts/horizontalstackedbarchart/horizontalstackedbarchart.pro @@ -0,0 +1,6 @@ +!include( ../examples.pri ) { + error( "Couldn't find the examples.pri file!" ) +} + +TARGET = horizontalstackedbarchart +SOURCES += main.cpp diff --git a/examples/charts/horizontalstackedbarchart/main.cpp b/examples/charts/horizontalstackedbarchart/main.cpp new file mode 100644 index 00000000..13df0cdf --- /dev/null +++ b/examples/charts/horizontalstackedbarchart/main.cpp @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include + +QT_CHARTS_USE_NAMESPACE + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + +//![1] + QBarSet *set0 = new QBarSet("Jane"); + QBarSet *set1 = new QBarSet("John"); + QBarSet *set2 = new QBarSet("Axel"); + QBarSet *set3 = new QBarSet("Mary"); + QBarSet *set4 = new QBarSet("Samantha"); + + *set0 << 1 << 2 << 3 << 4 << 5 << 6; + *set1 << 5 << 0 << 0 << 4 << 0 << 7; + *set2 << 3 << 5 << 8 << 13 << 8 << 5; + *set3 << 5 << 6 << 7 << 3 << 4 << 5; + *set4 << 9 << 7 << 5 << 3 << 1 << 2; +//![1] + +//![2] + QHorizontalStackedBarSeries *series = new QHorizontalStackedBarSeries(); + series->append(set0); + series->append(set1); + series->append(set2); + series->append(set3); + series->append(set4); + +//![2] + +//![3] + QChart *chart = new QChart(); + chart->addSeries(series); + chart->setTitle("Simple horizontal stacked barchart example"); + chart->setAnimationOptions(QChart::SeriesAnimations); +//![3] + +//![4] + QStringList categories; + categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; + QBarCategoryAxis *axis = new QBarCategoryAxis(); + axis->append(categories); + chart->createDefaultAxes(); + chart->setAxisY(axis, series); +//![4] + +//![5] + chart->legend()->setVisible(true); + chart->legend()->setAlignment(Qt::AlignBottom); +//![5] + +//![6] + QChartView *chartView = new QChartView(chart); + chartView->setRenderHint(QPainter::Antialiasing); +//![6] + +//![7] + QMainWindow window; + window.setCentralWidget(chartView); + window.resize(420, 300); + window.show(); +//![7] + + return a.exec(); +} diff --git a/examples/charts/legend/legend.pro b/examples/charts/legend/legend.pro new file mode 100644 index 00000000..5e22fb2a --- /dev/null +++ b/examples/charts/legend/legend.pro @@ -0,0 +1,10 @@ +!include( ../examples.pri ) { + error( "Couldn't find the examples.pri file!" ) +} + +TARGET = legend +SOURCES += main.cpp \ + mainwidget.cpp + +HEADERS += \ + mainwidget.h diff --git a/examples/charts/legend/main.cpp b/examples/charts/legend/main.cpp new file mode 100644 index 00000000..64d3903b --- /dev/null +++ b/examples/charts/legend/main.cpp @@ -0,0 +1,37 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "mainwidget.h" + +#include +#include + +QT_CHARTS_USE_NAMESPACE + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + + MainWidget w; + w.resize(720, 480); + w.show(); + + return a.exec(); +} diff --git a/examples/charts/legend/mainwidget.cpp b/examples/charts/legend/mainwidget.cpp new file mode 100644 index 00000000..32bc2ae9 --- /dev/null +++ b/examples/charts/legend/mainwidget.cpp @@ -0,0 +1,247 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "mainwidget.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +QT_CHARTS_USE_NAMESPACE + +MainWidget::MainWidget(QWidget *parent) : + QWidget(parent) +{ + // Create buttons for ui + m_buttonLayout = new QGridLayout(); + QPushButton *detachLegendButton = new QPushButton("Toggle attached"); + connect(detachLegendButton, SIGNAL(clicked()), this, SLOT(toggleAttached())); + m_buttonLayout->addWidget(detachLegendButton, 0, 0); + + QPushButton *addSetButton = new QPushButton("add barset"); + connect(addSetButton, SIGNAL(clicked()), this, SLOT(addBarset())); + m_buttonLayout->addWidget(addSetButton, 2, 0); + QPushButton *removeBarsetButton = new QPushButton("remove barset"); + connect(removeBarsetButton, SIGNAL(clicked()), this, SLOT(removeBarset())); + m_buttonLayout->addWidget(removeBarsetButton, 3, 0); + + QPushButton *alignButton = new QPushButton("Align (Bottom)"); + connect(alignButton, SIGNAL(clicked()), this, SLOT(setLegendAlignment())); + m_buttonLayout->addWidget(alignButton, 4, 0); + + QPushButton *boldButton = new QPushButton("Toggle bold"); + connect(boldButton, SIGNAL(clicked()), this, SLOT(toggleBold())); + m_buttonLayout->addWidget(boldButton, 8, 0); + + QPushButton *italicButton = new QPushButton("Toggle italic"); + connect(italicButton, SIGNAL(clicked()), this, SLOT(toggleItalic())); + m_buttonLayout->addWidget(italicButton, 9, 0); + + m_legendPosX = new QDoubleSpinBox(); + m_legendPosY = new QDoubleSpinBox(); + m_legendWidth = new QDoubleSpinBox(); + m_legendHeight = new QDoubleSpinBox(); + + connect(m_legendPosX, SIGNAL(valueChanged(double)), this, SLOT(updateLegendLayout())); + connect(m_legendPosY, SIGNAL(valueChanged(double)), this, SLOT(updateLegendLayout())); + connect(m_legendWidth, SIGNAL(valueChanged(double)), this, SLOT(updateLegendLayout())); + connect(m_legendHeight, SIGNAL(valueChanged(double)), this, SLOT(updateLegendLayout())); + + QFormLayout *legendLayout = new QFormLayout(); + legendLayout->addRow("HPos", m_legendPosX); + legendLayout->addRow("VPos", m_legendPosY); + legendLayout->addRow("Width", m_legendWidth); + legendLayout->addRow("Height", m_legendHeight); + m_legendSettings = new QGroupBox("Detached legend"); + m_legendSettings->setLayout(legendLayout); + m_buttonLayout->addWidget(m_legendSettings); + m_legendSettings->setVisible(false); + + // Create chart view with the chart + m_chart = new QChart(); + m_chartView = new QChartView(m_chart, this); + + // Create spinbox to modify font size + m_fontSize = new QDoubleSpinBox(); + m_fontSize->setValue(m_chart->legend()->font().pointSizeF()); + connect(m_fontSize, SIGNAL(valueChanged(double)), this, SLOT(fontSizeChanged())); + + QFormLayout *fontLayout = new QFormLayout(); + fontLayout->addRow("Legend font size", m_fontSize); + + // Create layout for grid and detached legend + m_mainLayout = new QGridLayout(); + m_mainLayout->addLayout(m_buttonLayout, 0, 0); + m_mainLayout->addLayout(fontLayout, 1, 0); + m_mainLayout->addWidget(m_chartView, 0, 1, 3, 1); + setLayout(m_mainLayout); + + createSeries(); +} + +void MainWidget::createSeries() +{ + m_series = new QBarSeries(); + addBarset(); + addBarset(); + addBarset(); + addBarset(); + + m_chart->addSeries(m_series); + m_chart->setTitle("Legend detach example"); + m_chart->createDefaultAxes(); +//![1] + m_chart->legend()->setVisible(true); + m_chart->legend()->setAlignment(Qt::AlignBottom); +//![1] + + m_chartView->setRenderHint(QPainter::Antialiasing); +} + +void MainWidget::showLegendSpinbox() +{ + m_legendSettings->setVisible(true); + QRectF chartViewRect = m_chartView->rect(); + + m_legendPosX->setMinimum(0); + m_legendPosX->setMaximum(chartViewRect.width()); + m_legendPosX->setValue(150); + + m_legendPosY->setMinimum(0); + m_legendPosY->setMaximum(chartViewRect.height()); + m_legendPosY->setValue(150); + + m_legendWidth->setMinimum(0); + m_legendWidth->setMaximum(chartViewRect.width()); + m_legendWidth->setValue(150); + + m_legendHeight->setMinimum(0); + m_legendHeight->setMaximum(chartViewRect.height()); + m_legendHeight->setValue(75); +} + +void MainWidget::hideLegendSpinbox() +{ + m_legendSettings->setVisible(false); +} + + +void MainWidget::toggleAttached() +{ + QLegend *legend = m_chart->legend(); + if (legend->isAttachedToChart()) { + //![2] + legend->detachFromChart(); + m_chart->legend()->setBackgroundVisible(true); + m_chart->legend()->setBrush(QBrush(QColor(128, 128, 128, 128))); + m_chart->legend()->setPen(QPen(QColor(192, 192, 192, 192))); + //![2] + showLegendSpinbox(); + updateLegendLayout(); + } else { + //![3] + legend->attachToChart(); + legend->setBackgroundVisible(false); + //![3] + hideLegendSpinbox(); + } + update(); +} + +void MainWidget::addBarset() +{ + QBarSet *barSet = new QBarSet(QString("set ") + QString::number(m_series->count())); + qreal delta = m_series->count() * 0.1; + *barSet << 1 + delta << 2 + delta << 3 + delta << 4 + delta; + m_series->append(barSet); +} + +void MainWidget::removeBarset() +{ + QList sets = m_series->barSets(); + if (sets.count() > 0) { + m_series->remove(sets.at(sets.count() - 1)); + } +} + +void MainWidget::setLegendAlignment() +{ + QPushButton *button = qobject_cast(sender()); + + switch (m_chart->legend()->alignment()) { + case Qt::AlignTop: + m_chart->legend()->setAlignment(Qt::AlignLeft); + if (button) + button->setText("Align (Left)"); + break; + case Qt::AlignLeft: + m_chart->legend()->setAlignment(Qt::AlignBottom); + if (button) + button->setText("Align (Bottom)"); + break; + case Qt::AlignBottom: + m_chart->legend()->setAlignment(Qt::AlignRight); + if (button) + button->setText("Align (Right)"); + break; + default: + if (button) + button->setText("Align (Top)"); + m_chart->legend()->setAlignment(Qt::AlignTop); + break; + } +} + +void MainWidget::toggleBold() +{ + QFont font = m_chart->legend()->font(); + font.setBold(!font.bold()); + m_chart->legend()->setFont(font); +} + +void MainWidget::toggleItalic() +{ + QFont font = m_chart->legend()->font(); + font.setItalic(!font.italic()); + m_chart->legend()->setFont(font); +} + +void MainWidget::fontSizeChanged() +{ + QFont font = m_chart->legend()->font(); + font.setPointSizeF(m_fontSize->value()); + m_chart->legend()->setFont(font); +} + +void MainWidget::updateLegendLayout() +{ +//![4] + m_chart->legend()->setGeometry(QRectF(m_legendPosX->value(), + m_legendPosY->value(), + m_legendWidth->value(), + m_legendHeight->value())); + m_chart->legend()->update(); +//![4] +} diff --git a/examples/charts/legend/mainwidget.h b/examples/charts/legend/mainwidget.h new file mode 100644 index 00000000..3a24d674 --- /dev/null +++ b/examples/charts/legend/mainwidget.h @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef MAINWIDGET_H +#define MAINWIDGET_H + +#include "qchartglobal.h" +#include "qchart.h" +#include "qchartview.h" +#include +#include +#include +#include +#include +#include +#include + +QT_CHARTS_USE_NAMESPACE + +class MainWidget : public QWidget +{ + Q_OBJECT +public: + explicit MainWidget(QWidget *parent = 0); + void createSeries(); + void showLegendSpinbox(); + void hideLegendSpinbox(); + +public Q_SLOTS: + void toggleAttached(); + void addBarset(); + void removeBarset(); + + void setLegendAlignment(); + + void toggleBold(); + void toggleItalic(); + void fontSizeChanged(); + + void updateLegendLayout(); + +private: + QChart *m_chart; + QBarSeries *m_series; + + QChartView *m_chartView; + QGridLayout *m_mainLayout; + QGridLayout *m_buttonLayout; + QGridLayout *m_fontLayout; + + QDoubleSpinBox *m_fontSize; + + // For detached layout + QGroupBox *m_legendSettings; + QDoubleSpinBox *m_legendPosX; + QDoubleSpinBox *m_legendPosY; + QDoubleSpinBox *m_legendWidth; + QDoubleSpinBox *m_legendHeight; +}; + +#endif // MAINWIDGET_H diff --git a/examples/charts/legendmarkers/legendmarkers.pro b/examples/charts/legendmarkers/legendmarkers.pro new file mode 100644 index 00000000..f79bdba4 --- /dev/null +++ b/examples/charts/legendmarkers/legendmarkers.pro @@ -0,0 +1,10 @@ +!include( ../examples.pri ) { + error( "Couldn't find the examples.pri file!" ) +} + +TARGET = legendmarkers +SOURCES += main.cpp \ + mainwidget.cpp + +HEADERS += \ + mainwidget.h diff --git a/examples/charts/legendmarkers/main.cpp b/examples/charts/legendmarkers/main.cpp new file mode 100644 index 00000000..f627e496 --- /dev/null +++ b/examples/charts/legendmarkers/main.cpp @@ -0,0 +1,35 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "mainwidget.h" + +#include +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + + MainWidget w; + w.resize(720, 480); + w.show(); + + return a.exec(); +} diff --git a/examples/charts/legendmarkers/mainwidget.cpp b/examples/charts/legendmarkers/mainwidget.cpp new file mode 100644 index 00000000..f71e7a61 --- /dev/null +++ b/examples/charts/legendmarkers/mainwidget.cpp @@ -0,0 +1,177 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "mainwidget.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +QT_CHARTS_USE_NAMESPACE + +MainWidget::MainWidget(QWidget *parent) : + QWidget(parent) +{ + // Create chart view with the chart + m_chart = new QChart(); + m_chartView = new QChartView(m_chart, this); + + // Create layout for grid and detached legend + m_mainLayout = new QGridLayout(); + m_mainLayout->addWidget(m_chartView, 0, 1, 3, 1); + setLayout(m_mainLayout); + + // Add few series + addSeries(); + addSeries(); + addSeries(); + addSeries(); + + connectMarkers(); + + // Set the title and show legend + m_chart->setTitle("Legendmarker example (click on legend)"); + m_chart->legend()->setVisible(true); + m_chart->legend()->setAlignment(Qt::AlignBottom); + + m_chartView->setRenderHint(QPainter::Antialiasing); +} + +void MainWidget::addSeries() +{ + QLineSeries *series = new QLineSeries(); + m_series.append(series); + + series->setName(QString("line " + QString::number(m_series.count()))); + + // Make some sine wave for data + QList data; + int offset = m_chart->series().count(); + for (int i = 0; i < 360; i++) { + qreal x = offset * 20 + i; + data.append(QPointF(i, qSin(2.0 * 3.141592 * x / 360.0))); + } + + series->append(data); + m_chart->addSeries(series); + + if (m_series.count() == 1) { + m_chart->createDefaultAxes(); + } +} + +void MainWidget::removeSeries() +{ + // Remove last series from chart + if (m_series.count() > 0) { + QLineSeries *series = m_series.last(); + m_chart->removeSeries(series); + m_series.removeLast(); + delete series; + } +} + +void MainWidget::connectMarkers() +{ +//![1] + // Connect all markers to handler + foreach (QLegendMarker* marker, m_chart->legend()->markers()) { + // Disconnect possible existing connection to avoid multiple connections + QObject::disconnect(marker, SIGNAL(clicked()), this, SLOT(handleMarkerClicked())); + QObject::connect(marker, SIGNAL(clicked()), this, SLOT(handleMarkerClicked())); + } +//![1] +} + +void MainWidget::disconnectMarkers() +{ +//![2] + foreach (QLegendMarker* marker, m_chart->legend()->markers()) { + QObject::disconnect(marker, SIGNAL(clicked()), this, SLOT(handleMarkerClicked())); + } +//![2] +} + +void MainWidget::handleMarkerClicked() +{ +//![3] + QLegendMarker* marker = qobject_cast (sender()); + Q_ASSERT(marker); +//![3] + +//![4] + switch (marker->type()) +//![4] + { + case QLegendMarker::LegendMarkerTypeXY: + { +//![5] + // Toggle visibility of series + marker->series()->setVisible(!marker->series()->isVisible()); + + // Turn legend marker back to visible, since hiding series also hides the marker + // and we don't want it to happen now. + marker->setVisible(true); +//![5] + +//![6] + // Dim the marker, if series is not visible + qreal alpha = 1.0; + + if (!marker->series()->isVisible()) { + alpha = 0.5; + } + + QColor color; + QBrush brush = marker->labelBrush(); + color = brush.color(); + color.setAlphaF(alpha); + brush.setColor(color); + marker->setLabelBrush(brush); + + brush = marker->brush(); + color = brush.color(); + color.setAlphaF(alpha); + brush.setColor(color); + marker->setBrush(brush); + + QPen pen = marker->pen(); + color = pen.color(); + color.setAlphaF(alpha); + pen.setColor(color); + marker->setPen(pen); + +//![6] + break; + } + default: + { + qDebug() << "Unknown marker type"; + break; + } + } +} diff --git a/examples/charts/legendmarkers/mainwidget.h b/examples/charts/legendmarkers/mainwidget.h new file mode 100644 index 00000000..350808a2 --- /dev/null +++ b/examples/charts/legendmarkers/mainwidget.h @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef MAINWIDGET_H +#define MAINWIDGET_H + +#include "qchartglobal.h" +#include "qchart.h" +#include "qchartview.h" +#include +#include +#include +#include +#include +#include +#include + +QT_CHARTS_USE_NAMESPACE + +class MainWidget : public QWidget +{ + Q_OBJECT +public: + explicit MainWidget(QWidget *parent = 0); + +public slots: + void addSeries(); + void removeSeries(); + void connectMarkers(); + void disconnectMarkers(); + + void handleMarkerClicked(); + +private: + + QChart *m_chart; + QList m_series; + + QChartView *m_chartView; + QGridLayout *m_mainLayout; + QGridLayout *m_fontLayout; + +}; + +#endif // MAINWIDGET_H diff --git a/examples/charts/lineandbar/lineandbar.pro b/examples/charts/lineandbar/lineandbar.pro new file mode 100644 index 00000000..dd94abd5 --- /dev/null +++ b/examples/charts/lineandbar/lineandbar.pro @@ -0,0 +1,6 @@ +!include( ../examples.pri ) { + error( "Couldn't find the examples.pri file!" ) +} + +TARGET = lineandbar +SOURCES += main.cpp diff --git a/examples/charts/lineandbar/main.cpp b/examples/charts/lineandbar/main.cpp new file mode 100644 index 00000000..264d5829 --- /dev/null +++ b/examples/charts/lineandbar/main.cpp @@ -0,0 +1,111 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +QT_CHARTS_USE_NAMESPACE + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + +//![1] + QBarSet *set0 = new QBarSet("Jane"); + QBarSet *set1 = new QBarSet("John"); + QBarSet *set2 = new QBarSet("Axel"); + QBarSet *set3 = new QBarSet("Mary"); + QBarSet *set4 = new QBarSet("Sam"); + + *set0 << 1 << 2 << 3 << 4 << 5 << 6; + *set1 << 5 << 0 << 0 << 4 << 0 << 7; + *set2 << 3 << 5 << 8 << 13 << 8 << 5; + *set3 << 5 << 6 << 7 << 3 << 4 << 5; + *set4 << 9 << 7 << 5 << 3 << 1 << 2; +//![1] + +//![2] + QBarSeries *barseries = new QBarSeries(); + barseries->append(set0); + barseries->append(set1); + barseries->append(set2); + barseries->append(set3); + barseries->append(set4); +//![2] + +//![8] + QLineSeries *lineseries = new QLineSeries(); + lineseries->setName("trend"); + lineseries->append(QPoint(0, 4)); + lineseries->append(QPoint(1, 15)); + lineseries->append(QPoint(2, 20)); + lineseries->append(QPoint(3, 4)); + lineseries->append(QPoint(4, 12)); + lineseries->append(QPoint(5, 17)); +//![8] + +//![3] + QChart *chart = new QChart(); + chart->addSeries(barseries); + chart->addSeries(lineseries); + chart->setTitle("Line and barchart example"); +//![3] + +//![4] + QStringList categories; + categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; + QBarCategoryAxis *axisX = new QBarCategoryAxis(); + axisX->append(categories); + chart->setAxisX(axisX, lineseries); + chart->setAxisX(axisX, barseries); + axisX->setRange(QString("Jan"), QString("Jun")); + + QValueAxis *axisY = new QValueAxis(); + chart->setAxisY(axisY, lineseries); + chart->setAxisY(axisY, barseries); + axisY->setRange(0, 20); +//![4] + +//![5] + chart->legend()->setVisible(true); + chart->legend()->setAlignment(Qt::AlignBottom); +//![5] + +//![6] + QChartView *chartView = new QChartView(chart); + chartView->setRenderHint(QPainter::Antialiasing); +//![6] + +//![7] + QMainWindow window; + window.setCentralWidget(chartView); + window.resize(440, 300); + window.show(); +//![7] + + return a.exec(); +} diff --git a/examples/charts/linechart/linechart.pro b/examples/charts/linechart/linechart.pro new file mode 100644 index 00000000..d3eb640a --- /dev/null +++ b/examples/charts/linechart/linechart.pro @@ -0,0 +1,5 @@ +!include( ../examples.pri ) { + error( "Couldn't find the examples.pri file!" ) +} +TARGET = linechart +SOURCES += main.cpp diff --git a/examples/charts/linechart/main.cpp b/examples/charts/linechart/main.cpp new file mode 100644 index 00000000..c0040e51 --- /dev/null +++ b/examples/charts/linechart/main.cpp @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include + +QT_CHARTS_USE_NAMESPACE + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + +//![1] + QLineSeries *series = new QLineSeries(); +//![1] + +//![2] + series->append(0, 6); + series->append(2, 4); + series->append(3, 8); + series->append(7, 4); + series->append(10, 5); + *series << QPointF(11, 1) << QPointF(13, 3) << QPointF(17, 6) << QPointF(18, 3) << QPointF(20, 2); +//![2] + +//![3] + QChart *chart = new QChart(); + chart->legend()->hide(); + chart->addSeries(series); + chart->createDefaultAxes(); + chart->setTitle("Simple line chart example"); +//![3] + +//![4] + QChartView *chartView = new QChartView(chart); + chartView->setRenderHint(QPainter::Antialiasing); +//![4] + + +//![5] + QMainWindow window; + window.setCentralWidget(chartView); + window.resize(400, 300); + window.show(); +//![5] + + return a.exec(); +} diff --git a/examples/charts/logvalueaxis/logvalueaxis.pro b/examples/charts/logvalueaxis/logvalueaxis.pro new file mode 100644 index 00000000..ede43079 --- /dev/null +++ b/examples/charts/logvalueaxis/logvalueaxis.pro @@ -0,0 +1,5 @@ +!include( ../examples.pri ) { + error( "Couldn't find the examples.pri file!" ) +} +TARGET = logvalueaxis +SOURCES += main.cpp diff --git a/examples/charts/logvalueaxis/main.cpp b/examples/charts/logvalueaxis/main.cpp new file mode 100644 index 00000000..73591ae3 --- /dev/null +++ b/examples/charts/logvalueaxis/main.cpp @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include + +QT_CHARTS_USE_NAMESPACE + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + + //![1] + QLineSeries *series = new QLineSeries(); + *series << QPointF(1, 1) << QPointF(2, 73) << QPointF(3, 268) << QPointF(4, 17) << QPointF(5, 4325) << QPointF(6, 723); + //![1] + + //![2] + QChart *chart = new QChart(); + chart->addSeries(series); + chart->legend()->hide(); + chart->setTitle("Logarithmic axis example"); + //![2] + + //![3] + QValueAxis *axisX = new QValueAxis; + axisX->setTitleText("Data point"); + axisX->setTickCount(6); + axisX->setLabelFormat("%i"); + chart->addAxis(axisX, Qt::AlignBottom); + series->attachAxis(axisX); + + QLogValueAxis *axisY = new QLogValueAxis; + axisY->setLabelFormat("%g"); + axisY->setTitleText("Values"); + axisY->setBase(8); + chart->addAxis(axisY, Qt::AlignLeft); + series->attachAxis(axisY); + //![3] + + //![4] + QChartView *chartView = new QChartView(chart); + chartView->setRenderHint(QPainter::Antialiasing); + //![4] + + //![5] + QMainWindow window; + window.setCentralWidget(chartView); + window.resize(400, 300); + window.show(); + //![5] + + return a.exec(); +} diff --git a/examples/charts/modeldata/customtablemodel.cpp b/examples/charts/modeldata/customtablemodel.cpp new file mode 100644 index 00000000..2bec3c98 --- /dev/null +++ b/examples/charts/modeldata/customtablemodel.cpp @@ -0,0 +1,110 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "customtablemodel.h" +#include +#include +#include +#include + +CustomTableModel::CustomTableModel(QObject *parent) : + QAbstractTableModel(parent) +{ + qsrand(QTime(0, 0, 0).secsTo(QTime::currentTime())); + + m_columnCount = 4; + m_rowCount = 15; + + // m_data + for (int i = 0; i < m_rowCount; i++) { + QVector* dataVec = new QVector(m_columnCount); + for (int k = 0; k < dataVec->size(); k++) { + if (k % 2 == 0) + dataVec->replace(k, i * 50 + qrand() % 20); + else + dataVec->replace(k, qrand() % 100); + } + m_data.append(dataVec); + } +} + +int CustomTableModel::rowCount(const QModelIndex &parent) const +{ + Q_UNUSED(parent) + return m_data.count(); +} + +int CustomTableModel::columnCount(const QModelIndex &parent) const +{ + Q_UNUSED(parent) + return m_columnCount; +} + +QVariant CustomTableModel::headerData(int section, Qt::Orientation orientation, int role) const +{ + if (role != Qt::DisplayRole) + return QVariant(); + + if (orientation == Qt::Horizontal) { + if (section % 2 == 0) + return "x"; + else + return "y"; + } else { + return QString("%1").arg(section + 1); + } +} + +QVariant CustomTableModel::data(const QModelIndex &index, int role) const +{ + if (role == Qt::DisplayRole) { + return m_data[index.row()]->at(index.column()); + } else if (role == Qt::EditRole) { + return m_data[index.row()]->at(index.column()); + } else if (role == Qt::BackgroundRole) { + foreach (QRect rect, m_mapping) { + if (rect.contains(index.column(), index.row())) + return QColor(m_mapping.key(rect)); + } + // cell not mapped return white color + return QColor(Qt::white); + } + return QVariant(); +} + +bool CustomTableModel::setData(const QModelIndex &index, const QVariant &value, int role) +{ + if (index.isValid() && role == Qt::EditRole) { + m_data[index.row()]->replace(index.column(), value.toDouble()); + emit dataChanged(index, index); + return true; + } + return false; +} + +Qt::ItemFlags CustomTableModel::flags(const QModelIndex &index) const +{ + return QAbstractItemModel::flags(index) | Qt::ItemIsEditable; +} + +void CustomTableModel::addMapping(QString color, QRect area) +{ + m_mapping.insertMulti(color, area); +} diff --git a/examples/charts/modeldata/customtablemodel.h b/examples/charts/modeldata/customtablemodel.h new file mode 100644 index 00000000..755f4c7d --- /dev/null +++ b/examples/charts/modeldata/customtablemodel.h @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef CUSTOMTABLEMODEL_H +#define CUSTOMTABLEMODEL_H + +#include +#include +#include + +class CustomTableModel : public QAbstractTableModel +{ + Q_OBJECT +public: + explicit CustomTableModel(QObject *parent = 0); + + int rowCount(const QModelIndex &parent = QModelIndex()) const; + int columnCount(const QModelIndex &parent = QModelIndex()) const; + QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; + bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); + Qt::ItemFlags flags(const QModelIndex &index) const; + + void addMapping(QString color, QRect area); + void clearMapping() { m_mapping.clear(); } + +private: + QList * > m_data; + QHash m_mapping; + int m_columnCount; + int m_rowCount; +}; + +#endif // CUSTOMTABLEMODEL_H diff --git a/examples/charts/modeldata/main.cpp b/examples/charts/modeldata/main.cpp new file mode 100644 index 00000000..bf0b384b --- /dev/null +++ b/examples/charts/modeldata/main.cpp @@ -0,0 +1,30 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include "tablewidget.h" + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + TableWidget w; + w.show(); + return a.exec(); +} diff --git a/examples/charts/modeldata/modeldata.pro b/examples/charts/modeldata/modeldata.pro new file mode 100644 index 00000000..7c302bd9 --- /dev/null +++ b/examples/charts/modeldata/modeldata.pro @@ -0,0 +1,16 @@ +!include( ../examples.pri ) { + error( "Couldn't find the examples.pri file!" ) +} + +QT += core gui + +TARGET = modeldata +TEMPLATE = app + + +SOURCES += main.cpp\ + tablewidget.cpp \ + customtablemodel.cpp + +HEADERS += tablewidget.h \ + customtablemodel.h diff --git a/examples/charts/modeldata/tablewidget.cpp b/examples/charts/modeldata/tablewidget.cpp new file mode 100644 index 00000000..5d50dd70 --- /dev/null +++ b/examples/charts/modeldata/tablewidget.cpp @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "tablewidget.h" +#include "customtablemodel.h" +#include +#include +#include +#include +#include +#include +#include + +QT_CHARTS_USE_NAMESPACE + +TableWidget::TableWidget(QWidget *parent) + : QWidget(parent) +{ + // create simple model for storing data + // user's table data model + //! [1] + CustomTableModel *model = new CustomTableModel; + //! [1] + + //! [2] + // create table view and add model to it + QTableView *tableView = new QTableView; + tableView->setModel(model); + tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); + tableView->verticalHeader()->setSectionResizeMode(QHeaderView::Stretch); + //! [2] + + //! [3] + QChart *chart = new QChart; + chart->setAnimationOptions(QChart::AllAnimations); + //! [3] + + // series 1 + //! [4] + QLineSeries *series = new QLineSeries; + series->setName("Line 1"); + QVXYModelMapper *mapper = new QVXYModelMapper(this); + mapper->setXColumn(0); + mapper->setYColumn(1); + mapper->setSeries(series); + mapper->setModel(model); + chart->addSeries(series); + //! [4] + + //! [5] + // for storing color hex from the series + QString seriesColorHex = "#000000"; + + // get the color of the series and use it for showing the mapped area + seriesColorHex = "#" + QString::number(series->pen().color().rgb(), 16).right(6).toUpper(); + model->addMapping(seriesColorHex, QRect(0, 0, 2, model->rowCount())); + //! [5] + + + // series 2 + //! [6] + series = new QLineSeries; + series->setName("Line 2"); + + mapper = new QVXYModelMapper(this); + mapper->setXColumn(2); + mapper->setYColumn(3); + mapper->setSeries(series); + mapper->setModel(model); + chart->addSeries(series); + //! [6] + + //! [7] + // get the color of the series and use it for showing the mapped area + seriesColorHex = "#" + QString::number(series->pen().color().rgb(), 16).right(6).toUpper(); + model->addMapping(seriesColorHex, QRect(2, 0, 2, model->rowCount())); + //! [7] + + //! [8] + chart->createDefaultAxes(); + QChartView *chartView = new QChartView(chart); + chartView->setRenderHint(QPainter::Antialiasing); + chartView->setMinimumSize(640, 480); + //! [8] + + //! [9] + // create main layout + QGridLayout *mainLayout = new QGridLayout; + mainLayout->addWidget(tableView, 1, 0); + mainLayout->addWidget(chartView, 1, 1); + mainLayout->setColumnStretch(1, 1); + mainLayout->setColumnStretch(0, 0); + setLayout(mainLayout); + //! [9] +} diff --git a/examples/charts/modeldata/tablewidget.h b/examples/charts/modeldata/tablewidget.h new file mode 100644 index 00000000..3846cc11 --- /dev/null +++ b/examples/charts/modeldata/tablewidget.h @@ -0,0 +1,34 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef TABLEWIDGET_H +#define TABLEWIDGET_H + +#include + +class TableWidget : public QWidget +{ + Q_OBJECT + +public: + TableWidget(QWidget *parent = 0); +}; + +#endif // TABLEWIDGET_H diff --git a/examples/charts/multiaxis/main.cpp b/examples/charts/multiaxis/main.cpp new file mode 100644 index 00000000..b6b53e88 --- /dev/null +++ b/examples/charts/multiaxis/main.cpp @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include + +QT_CHARTS_USE_NAMESPACE + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + + //![1] + QChart *chart = new QChart(); + chart->legend()->hide(); + chart->setTitle("Multiaxis chart example"); + //![1] + + //![2] + QValueAxis *axisX = new QValueAxis; + axisX->setTickCount(10); + chart->addAxis(axisX, Qt::AlignBottom); + //![2] + + //![3] + QSplineSeries *series = new QSplineSeries; + *series << QPointF(1, 5) << QPointF(3.5, 18) << QPointF(4.8, 7.5) << QPointF(10, 2.5); + chart->addSeries(series); + + QValueAxis *axisY = new QValueAxis; + axisY->setLinePenColor(series->pen().color()); + + chart->addAxis(axisY, Qt::AlignLeft); + series->attachAxis(axisX); + series->attachAxis(axisY); + //![3] + + //![4] + series = new QSplineSeries; + *series << QPointF(1, 0.5) << QPointF(1.5, 4.5) << QPointF(2.4, 2.5) << QPointF(4.3, 12.5) + << QPointF(5.2, 3.5) << QPointF(7.4, 16.5) << QPointF(8.3, 7.5) << QPointF(10, 17); + chart->addSeries(series); + + QCategoryAxis *axisY3 = new QCategoryAxis; + axisY3->append("Low", 5); + axisY3->append("Medium", 12); + axisY3->append("High", 17); + axisY3->setLinePenColor(series->pen().color()); + axisY3->setGridLinePen((series->pen())); + + chart->addAxis(axisY3, Qt::AlignRight); + series->attachAxis(axisX); + series->attachAxis(axisY3); + //![4] + + //![5] + QChartView *chartView = new QChartView(chart); + chartView->setRenderHint(QPainter::Antialiasing); + //![5] + + //![6] + QMainWindow window; + window.setCentralWidget(chartView); + window.resize(800, 600); + window.show(); + //![6] + + return a.exec(); +} + diff --git a/examples/charts/multiaxis/multiaxis.pro b/examples/charts/multiaxis/multiaxis.pro new file mode 100644 index 00000000..33de57cb --- /dev/null +++ b/examples/charts/multiaxis/multiaxis.pro @@ -0,0 +1,5 @@ +!include( ../examples.pri ) { + error( "Couldn't find the examples.pri file!" ) +} +TARGET = multiaxis +SOURCES += main.cpp diff --git a/examples/charts/nesteddonuts/main.cpp b/examples/charts/nesteddonuts/main.cpp new file mode 100644 index 00000000..0b833a83 --- /dev/null +++ b/examples/charts/nesteddonuts/main.cpp @@ -0,0 +1,29 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include "widget.h" + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + Widget w; + w.show(); + return a.exec(); +} diff --git a/examples/charts/nesteddonuts/nesteddonuts.pro b/examples/charts/nesteddonuts/nesteddonuts.pro new file mode 100644 index 00000000..fadab0cd --- /dev/null +++ b/examples/charts/nesteddonuts/nesteddonuts.pro @@ -0,0 +1,8 @@ +!include( ../examples.pri ) { + error( "Couldn't find the examples.pri file!" ) +} + +TARGET = nesteddonuts +SOURCES += main.cpp\ + widget.cpp +HEADERS += widget.h diff --git a/examples/charts/nesteddonuts/widget.cpp b/examples/charts/nesteddonuts/widget.cpp new file mode 100644 index 00000000..e11c4c7c --- /dev/null +++ b/examples/charts/nesteddonuts/widget.cpp @@ -0,0 +1,128 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "widget.h" +#include +#include +#include +#include +#include +#include +#include +#include + +QT_CHARTS_USE_NAMESPACE + +Widget::Widget(QWidget *parent) + : QWidget(parent) +{ + setMinimumSize(800, 600); + qsrand(QTime(0, 0, 0).secsTo(QTime::currentTime())); + + //! [1] + QChartView *chartView = new QChartView; + chartView->setRenderHint(QPainter::Antialiasing); + QChart *chart = chartView->chart(); + chart->legend()->setVisible(false); + chart->setTitle("Nested donuts demo"); + chart->setAnimationOptions(QChart::AllAnimations); + //! [1] + + //! [2] + qreal minSize = 0.1; + qreal maxSize = 0.9; + int donutCount = 5; + //! [2] + + //! [3] + for (int i = 0; i < donutCount; i++) { + QPieSeries *donut = new QPieSeries; + int sliceCount = 3 + qrand() % 3; + for (int j = 0; j < sliceCount; j++) { + qreal value = 100 + qrand() % 100; + QPieSlice *slice = new QPieSlice(QString("%1").arg(value), value); + slice->setLabelVisible(true); + slice->setLabelColor(Qt::white); + slice->setLabelPosition(QPieSlice::LabelInsideTangential); + connect(slice, SIGNAL(hovered(bool)), this, SLOT(explodeSlice(bool))); + donut->append(slice); + donut->setHoleSize(minSize + i * (maxSize - minSize) / donutCount); + donut->setPieSize(minSize + (i + 1) * (maxSize - minSize) / donutCount); + } + m_donuts.append(donut); + chartView->chart()->addSeries(donut); + } + //! [3] + + // create main layout + //! [4] + QGridLayout *mainLayout = new QGridLayout; + mainLayout->addWidget(chartView, 1, 1); + setLayout(mainLayout); + //! [4] + + //! [5] + updateTimer = new QTimer(this); + connect(updateTimer, SIGNAL(timeout()), this, SLOT(updateRotation())); + updateTimer->start(1250); + //! [5] +} + +Widget::~Widget() +{ + +} + +//! [6] +void Widget::updateRotation() +{ + for (int i = 0; i < m_donuts.count(); i++) { + QPieSeries *donut = m_donuts.at(i); + qreal phaseShift = -50 + qrand() % 100; + donut->setPieStartAngle(donut->pieStartAngle() + phaseShift); + donut->setPieEndAngle(donut->pieEndAngle() + phaseShift); + } +} +//! [6] + +//! [7] +void Widget::explodeSlice(bool exploded) +{ + QPieSlice *slice = qobject_cast(sender()); + if (exploded) { + updateTimer->stop(); + qreal sliceStartAngle = slice->startAngle(); + qreal sliceEndAngle = slice->startAngle() + slice->angleSpan(); + + QPieSeries *donut = slice->series(); + qreal seriesIndex = m_donuts.indexOf(donut); + for (int i = seriesIndex + 1; i < m_donuts.count(); i++) { + m_donuts.at(i)->setPieStartAngle(sliceEndAngle); + m_donuts.at(i)->setPieEndAngle(360 + sliceStartAngle); + } + } else { + for (int i = 0; i < m_donuts.count(); i++) { + m_donuts.at(i)->setPieStartAngle(0); + m_donuts.at(i)->setPieEndAngle(360); + } + updateTimer->start(); + } + slice->setExploded(exploded); +} +//! [7] diff --git a/examples/charts/nesteddonuts/widget.h b/examples/charts/nesteddonuts/widget.h new file mode 100644 index 00000000..6d2b749c --- /dev/null +++ b/examples/charts/nesteddonuts/widget.h @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef WIDGET_H +#define WIDGET_H + +#include +#include + +class QTimer; + +QT_CHARTS_USE_NAMESPACE + +class Widget : public QWidget +{ + Q_OBJECT + +public: + Widget(QWidget *parent = 0); + ~Widget(); + +public slots: + void updateRotation(); + void explodeSlice(bool exploded); + +private: + QList m_donuts; + QTimer *updateTimer; +}; + +#endif // WIDGET_H diff --git a/examples/charts/percentbarchart/main.cpp b/examples/charts/percentbarchart/main.cpp new file mode 100644 index 00000000..15a68206 --- /dev/null +++ b/examples/charts/percentbarchart/main.cpp @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include + +QT_CHARTS_USE_NAMESPACE + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + +//![1] + QBarSet *set0 = new QBarSet("Jane"); + QBarSet *set1 = new QBarSet("John"); + QBarSet *set2 = new QBarSet("Axel"); + QBarSet *set3 = new QBarSet("Mary"); + QBarSet *set4 = new QBarSet("Samantha"); + + *set0 << 1 << 2 << 3 << 4 << 5 << 6; + *set1 << 5 << 0 << 0 << 4 << 0 << 7; + *set2 << 3 << 5 << 8 << 13 << 8 << 5; + *set3 << 5 << 6 << 7 << 3 << 4 << 5; + *set4 << 9 << 7 << 5 << 3 << 1 << 2; +//![1] + +//![2] + QPercentBarSeries *series = new QPercentBarSeries(); + series->append(set0); + series->append(set1); + series->append(set2); + series->append(set3); + series->append(set4); +//![2] + +//![3] + QChart *chart = new QChart(); + chart->addSeries(series); + chart->setTitle("Simple percentbarchart example"); + chart->setAnimationOptions(QChart::SeriesAnimations); +//![3] + +//![4] + QStringList categories; + categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; + QBarCategoryAxis *axis = new QBarCategoryAxis(); + axis->append(categories); + chart->createDefaultAxes(); + chart->setAxisX(axis, series); +//![4] + +//![5] + chart->legend()->setVisible(true); + chart->legend()->setAlignment(Qt::AlignBottom); +//![5] + +//![6] + QChartView *chartView = new QChartView(chart); + chartView->setRenderHint(QPainter::Antialiasing); +//![6] + +//![7] + QMainWindow window; + window.setCentralWidget(chartView); + window.resize(420, 300); + window.show(); +//![7] + + return a.exec(); +} + diff --git a/examples/charts/percentbarchart/percentbarchart.pro b/examples/charts/percentbarchart/percentbarchart.pro new file mode 100644 index 00000000..983159d1 --- /dev/null +++ b/examples/charts/percentbarchart/percentbarchart.pro @@ -0,0 +1,6 @@ +!include( ../examples.pri ) { + error( "Couldn't find the examples.pri file!" ) +} + +TARGET = percentbarchart +SOURCES += main.cpp diff --git a/examples/charts/piechart/main.cpp b/examples/charts/piechart/main.cpp new file mode 100644 index 00000000..5e7b4ef1 --- /dev/null +++ b/examples/charts/piechart/main.cpp @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include + +QT_CHARTS_USE_NAMESPACE + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + +//![1] + QPieSeries *series = new QPieSeries(); + series->append("Jane", 1); + series->append("Joe", 2); + series->append("Andy", 3); + series->append("Barbara", 4); + series->append("Axel", 5); +//![1] + +//![2] + QPieSlice *slice = series->slices().at(1); + slice->setExploded(); + slice->setLabelVisible(); + slice->setPen(QPen(Qt::darkGreen, 2)); + slice->setBrush(Qt::green); +//![2] + +//![3] + QChart *chart = new QChart(); + chart->addSeries(series); + chart->setTitle("Simple piechart example"); + chart->legend()->hide(); +//![3] + +//![4] + QChartView *chartView = new QChartView(chart); + chartView->setRenderHint(QPainter::Antialiasing); +//![4] + +//![5] + QMainWindow window; + window.setCentralWidget(chartView); + window.resize(400, 300); + window.show(); +//![5] + + return a.exec(); +} diff --git a/examples/charts/piechart/piechart.pro b/examples/charts/piechart/piechart.pro new file mode 100644 index 00000000..7bd48514 --- /dev/null +++ b/examples/charts/piechart/piechart.pro @@ -0,0 +1,5 @@ +!include( ../examples.pri ) { + error( "Couldn't find the examples.pri file!" ) +} +TARGET = piechart +SOURCES += main.cpp diff --git a/examples/charts/piechartcustomization/brushtool.cpp b/examples/charts/piechartcustomization/brushtool.cpp new file mode 100644 index 00000000..08dff95a --- /dev/null +++ b/examples/charts/piechartcustomization/brushtool.cpp @@ -0,0 +1,100 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "brushtool.h" +#include +#include +#include +#include + +BrushTool::BrushTool(QString title, QWidget *parent) + : QWidget(parent) +{ + setWindowTitle(title); + setWindowFlags(Qt::Tool); + + m_colorButton = new QPushButton(); + m_styleCombo = new QComboBox(); + m_styleCombo->addItem("Nobrush", (int) Qt::NoBrush); + m_styleCombo->addItem("Solidpattern", (int) Qt::SolidPattern); + m_styleCombo->addItem("Dense1pattern", (int) Qt::Dense1Pattern); + m_styleCombo->addItem("Dense2attern", (int) Qt::Dense2Pattern); + m_styleCombo->addItem("Dense3Pattern", (int) Qt::Dense3Pattern); + m_styleCombo->addItem("Dense4Pattern", (int) Qt::Dense4Pattern); + m_styleCombo->addItem("Dense5Pattern", (int) Qt::Dense5Pattern); + m_styleCombo->addItem("Dense6Pattern", (int) Qt::Dense6Pattern); + m_styleCombo->addItem("Dense7Pattern", (int) Qt::Dense7Pattern); + m_styleCombo->addItem("HorPattern", (int) Qt::HorPattern); + m_styleCombo->addItem("VerPattern", (int) Qt::VerPattern); + m_styleCombo->addItem("CrossPattern", (int) Qt::CrossPattern); + m_styleCombo->addItem("BDiagPattern", (int) Qt::BDiagPattern); + m_styleCombo->addItem("FDiagPattern", (int) Qt::FDiagPattern); + m_styleCombo->addItem("DiagCrossPattern", (int) Qt::DiagCrossPattern); + + QFormLayout *layout = new QFormLayout(); + layout->addRow("Color", m_colorButton); + layout->addRow("Style", m_styleCombo); + setLayout(layout); + + connect(m_colorButton, SIGNAL(clicked()), this, SLOT(showColorDialog())); + connect(m_styleCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(updateStyle())); +} + +void BrushTool::setBrush(QBrush brush) +{ + m_brush = brush; + m_colorButton->setText(m_brush.color().name()); + m_styleCombo->setCurrentIndex(m_brush.style()); // index matches the enum +} + +QBrush BrushTool::brush() const +{ + return m_brush; +} + +QString BrushTool::name() +{ + return name(m_brush); +} + +QString BrushTool::name(const QBrush &brush) +{ + return brush.color().name(); +} + +void BrushTool::showColorDialog() +{ + QColorDialog dialog(m_brush.color()); + dialog.show(); + dialog.exec(); + m_brush.setColor(dialog.selectedColor()); + m_colorButton->setText(m_brush.color().name()); + emit changed(); +} + +void BrushTool::updateStyle() +{ + Qt::BrushStyle style = (Qt::BrushStyle) m_styleCombo->itemData(m_styleCombo->currentIndex()).toInt(); + if (m_brush.style() != style) { + m_brush.setStyle(style); + emit changed(); + } +} + +#include "moc_brushtool.cpp" diff --git a/examples/charts/piechartcustomization/brushtool.h b/examples/charts/piechartcustomization/brushtool.h new file mode 100644 index 00000000..f6e31b72 --- /dev/null +++ b/examples/charts/piechartcustomization/brushtool.h @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef BRUSHTOOL_H +#define BRUSHTOOL_H + +#include +#include + +class QPushButton; +class QComboBox; + +class BrushTool : public QWidget +{ + Q_OBJECT + +public: + explicit BrushTool(QString title, QWidget *parent = 0); + void setBrush(QBrush brush); + QBrush brush() const; + QString name(); + static QString name(const QBrush &brush); + +Q_SIGNALS: + void changed(); + +public Q_SLOTS: + void showColorDialog(); + void updateStyle(); + +private: + QBrush m_brush; + QPushButton *m_colorButton; + QComboBox *m_styleCombo; +}; + +#endif // BRUSHTOOL_H diff --git a/examples/charts/piechartcustomization/customslice.cpp b/examples/charts/piechartcustomization/customslice.cpp new file mode 100644 index 00000000..bbcd1492 --- /dev/null +++ b/examples/charts/piechartcustomization/customslice.cpp @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "customslice.h" + +QT_CHARTS_USE_NAMESPACE + +CustomSlice::CustomSlice(QString label, qreal value) + : QPieSlice(label, value) +{ + connect(this, SIGNAL(hovered(bool)), this, SLOT(showHighlight(bool))); +} + +QBrush CustomSlice::originalBrush() +{ + return m_originalBrush; +} + +void CustomSlice::showHighlight(bool show) +{ + if (show) { + QBrush brush = this->brush(); + m_originalBrush = brush; + brush.setColor(brush.color().lighter()); + setBrush(brush); + } else { + setBrush(m_originalBrush); + } +} + +#include "moc_customslice.cpp" diff --git a/examples/charts/piechartcustomization/customslice.h b/examples/charts/piechartcustomization/customslice.h new file mode 100644 index 00000000..4c8e81fa --- /dev/null +++ b/examples/charts/piechartcustomization/customslice.h @@ -0,0 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef CUSTOMSLICE_H +#define CUSTOMSLICE_H + +#include + +QT_CHARTS_USE_NAMESPACE + +class CustomSlice : public QPieSlice +{ + Q_OBJECT + +public: + CustomSlice(QString label, qreal value); + +public: + QBrush originalBrush(); + +public Q_SLOTS: + void showHighlight(bool show); + +private: + QBrush m_originalBrush; +}; + +#endif // CUSTOMSLICE_H diff --git a/examples/charts/piechartcustomization/main.cpp b/examples/charts/piechartcustomization/main.cpp new file mode 100644 index 00000000..f35fd0fc --- /dev/null +++ b/examples/charts/piechartcustomization/main.cpp @@ -0,0 +1,34 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "mainwidget.h" +#include +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + QMainWindow window; + MainWidget widget; + window.setCentralWidget(&widget); + window.resize(900, 600); + window.show(); + return a.exec(); +} diff --git a/examples/charts/piechartcustomization/mainwidget.cpp b/examples/charts/piechartcustomization/mainwidget.cpp new file mode 100644 index 00000000..fb0ed05d --- /dev/null +++ b/examples/charts/piechartcustomization/mainwidget.cpp @@ -0,0 +1,360 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "mainwidget.h" +#include "customslice.h" +#include "pentool.h" +#include "brushtool.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +QT_CHARTS_USE_NAMESPACE + +MainWidget::MainWidget(QWidget *parent) + : QWidget(parent), + m_slice(0) +{ + // create chart + QChart *chart = new QChart; + chart->setTitle("Piechart customization"); + chart->setAnimationOptions(QChart::AllAnimations); + + // create series + m_series = new QPieSeries(); + *m_series << new CustomSlice("Slice 1", 10.0); + *m_series << new CustomSlice("Slice 2", 20.0); + *m_series << new CustomSlice("Slice 3", 30.0); + *m_series << new CustomSlice("Slice 4", 40.0); + *m_series << new CustomSlice("Slice 5", 50.0); + m_series->setLabelsVisible(); + chart->addSeries(m_series); + + connect(m_series, SIGNAL(clicked(QPieSlice*)), this, SLOT(handleSliceClicked(QPieSlice*))); + + // chart settings + m_themeComboBox = new QComboBox(); + m_themeComboBox->addItem("Light", QChart::ChartThemeLight); + m_themeComboBox->addItem("BlueCerulean", QChart::ChartThemeBlueCerulean); + m_themeComboBox->addItem("Dark", QChart::ChartThemeDark); + m_themeComboBox->addItem("BrownSand", QChart::ChartThemeBrownSand); + m_themeComboBox->addItem("BlueNcs", QChart::ChartThemeBlueNcs); + m_themeComboBox->addItem("High Contrast", QChart::ChartThemeHighContrast); + m_themeComboBox->addItem("Blue Icy", QChart::ChartThemeBlueIcy); + m_themeComboBox->addItem("Qt", QChart::ChartThemeQt); + + m_aaCheckBox = new QCheckBox(); + m_animationsCheckBox = new QCheckBox(); + m_animationsCheckBox->setCheckState(Qt::Checked); + + m_legendCheckBox = new QCheckBox(); + + QFormLayout *chartSettingsLayout = new QFormLayout(); + chartSettingsLayout->addRow("Theme", m_themeComboBox); + chartSettingsLayout->addRow("Antialiasing", m_aaCheckBox); + chartSettingsLayout->addRow("Animations", m_animationsCheckBox); + chartSettingsLayout->addRow("Legend", m_legendCheckBox); + QGroupBox *chartSettings = new QGroupBox("Chart"); + chartSettings->setLayout(chartSettingsLayout); + + connect(m_themeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateChartSettings())); + connect(m_aaCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateChartSettings())); + connect(m_animationsCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateChartSettings())); + connect(m_legendCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateChartSettings())); + + // series settings + m_hPosition = new QDoubleSpinBox(); + m_hPosition->setMinimum(0.0); + m_hPosition->setMaximum(1.0); + m_hPosition->setSingleStep(0.1); + m_hPosition->setValue(m_series->horizontalPosition()); + + m_vPosition = new QDoubleSpinBox(); + m_vPosition->setMinimum(0.0); + m_vPosition->setMaximum(1.0); + m_vPosition->setSingleStep(0.1); + m_vPosition->setValue(m_series->verticalPosition()); + + m_sizeFactor = new QDoubleSpinBox(); + m_sizeFactor->setMinimum(0.0); + m_sizeFactor->setMaximum(1.0); + m_sizeFactor->setSingleStep(0.1); + m_sizeFactor->setValue(m_series->pieSize()); + + m_startAngle = new QDoubleSpinBox(); + m_startAngle->setMinimum(-720); + m_startAngle->setMaximum(720); + m_startAngle->setValue(m_series->pieStartAngle()); + m_startAngle->setSingleStep(1); + + m_endAngle = new QDoubleSpinBox(); + m_endAngle->setMinimum(-720); + m_endAngle->setMaximum(720); + m_endAngle->setValue(m_series->pieEndAngle()); + m_endAngle->setSingleStep(1); + + m_holeSize = new QDoubleSpinBox(); + m_holeSize->setMinimum(0.0); + m_holeSize->setMaximum(1.0); + m_holeSize->setSingleStep(0.1); + m_holeSize->setValue(m_series->holeSize()); + + QPushButton *appendSlice = new QPushButton("Append slice"); + QPushButton *insertSlice = new QPushButton("Insert slice"); + QPushButton *removeSlice = new QPushButton("Remove selected slice"); + + QFormLayout *seriesSettingsLayout = new QFormLayout(); + seriesSettingsLayout->addRow("Horizontal position", m_hPosition); + seriesSettingsLayout->addRow("Vertical position", m_vPosition); + seriesSettingsLayout->addRow("Size factor", m_sizeFactor); + seriesSettingsLayout->addRow("Start angle", m_startAngle); + seriesSettingsLayout->addRow("End angle", m_endAngle); + seriesSettingsLayout->addRow("Hole size", m_holeSize); + seriesSettingsLayout->addRow(appendSlice); + seriesSettingsLayout->addRow(insertSlice); + seriesSettingsLayout->addRow(removeSlice); + QGroupBox *seriesSettings = new QGroupBox("Series"); + seriesSettings->setLayout(seriesSettingsLayout); + + connect(m_vPosition, SIGNAL(valueChanged(double)), this, SLOT(updateSerieSettings())); + connect(m_hPosition, SIGNAL(valueChanged(double)), this, SLOT(updateSerieSettings())); + connect(m_sizeFactor, SIGNAL(valueChanged(double)), this, SLOT(updateSerieSettings())); + connect(m_startAngle, SIGNAL(valueChanged(double)), this, SLOT(updateSerieSettings())); + connect(m_endAngle, SIGNAL(valueChanged(double)), this, SLOT(updateSerieSettings())); + connect(m_holeSize, SIGNAL(valueChanged(double)), this, SLOT(updateSerieSettings())); + connect(appendSlice, SIGNAL(clicked()), this, SLOT(appendSlice())); + connect(insertSlice, SIGNAL(clicked()), this, SLOT(insertSlice())); + connect(removeSlice, SIGNAL(clicked()), this, SLOT(removeSlice())); + + // slice settings + m_sliceName = new QLineEdit(""); + m_sliceName->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum); + m_sliceValue = new QDoubleSpinBox(); + m_sliceValue->setMaximum(1000); + m_sliceLabelVisible = new QCheckBox(); + m_sliceLabelArmFactor = new QDoubleSpinBox(); + m_sliceLabelArmFactor->setSingleStep(0.01); + m_sliceExploded = new QCheckBox(); + m_sliceExplodedFactor = new QDoubleSpinBox(); + m_sliceExplodedFactor->setSingleStep(0.01); + m_pen = new QPushButton(); + m_penTool = new PenTool("Slice pen", this); + m_brush = new QPushButton(); + m_brushTool = new BrushTool("Slice brush", this); + m_font = new QPushButton(); + m_labelBrush = new QPushButton(); + m_labelBrushTool = new BrushTool("Label brush", this); + m_labelPosition = new QComboBox(this); + m_labelPosition->addItem("Outside", QPieSlice::LabelOutside); + m_labelPosition->addItem("Inside horizontal", QPieSlice::LabelInsideHorizontal); + m_labelPosition->addItem("Inside tangential", QPieSlice::LabelInsideTangential); + m_labelPosition->addItem("Inside normal", QPieSlice::LabelInsideNormal); + + QFormLayout *sliceSettingsLayout = new QFormLayout(); + sliceSettingsLayout->addRow("Label", m_sliceName); + sliceSettingsLayout->addRow("Value", m_sliceValue); + sliceSettingsLayout->addRow("Pen", m_pen); + sliceSettingsLayout->addRow("Brush", m_brush); + sliceSettingsLayout->addRow("Label visible", m_sliceLabelVisible); + sliceSettingsLayout->addRow("Label font", m_font); + sliceSettingsLayout->addRow("Label brush", m_labelBrush); + sliceSettingsLayout->addRow("Label position", m_labelPosition); + sliceSettingsLayout->addRow("Label arm length", m_sliceLabelArmFactor); + sliceSettingsLayout->addRow("Exploded", m_sliceExploded); + sliceSettingsLayout->addRow("Explode distance", m_sliceExplodedFactor); + QGroupBox *sliceSettings = new QGroupBox("Selected slice"); + sliceSettings->setLayout(sliceSettingsLayout); + + connect(m_sliceName, SIGNAL(textChanged(QString)), this, SLOT(updateSliceSettings())); + connect(m_sliceValue, SIGNAL(valueChanged(double)), this, SLOT(updateSliceSettings())); + connect(m_pen, SIGNAL(clicked()), m_penTool, SLOT(show())); + connect(m_penTool, SIGNAL(changed()), this, SLOT(updateSliceSettings())); + connect(m_brush, SIGNAL(clicked()), m_brushTool, SLOT(show())); + connect(m_brushTool, SIGNAL(changed()), this, SLOT(updateSliceSettings())); + connect(m_font, SIGNAL(clicked()), this, SLOT(showFontDialog())); + connect(m_labelBrush, SIGNAL(clicked()), m_labelBrushTool, SLOT(show())); + connect(m_labelBrushTool, SIGNAL(changed()), this, SLOT(updateSliceSettings())); + connect(m_sliceLabelVisible, SIGNAL(toggled(bool)), this, SLOT(updateSliceSettings())); + connect(m_sliceLabelVisible, SIGNAL(toggled(bool)), this, SLOT(updateSliceSettings())); + connect(m_sliceLabelArmFactor, SIGNAL(valueChanged(double)), this, SLOT(updateSliceSettings())); + connect(m_sliceExploded, SIGNAL(toggled(bool)), this, SLOT(updateSliceSettings())); + connect(m_sliceExplodedFactor, SIGNAL(valueChanged(double)), this, SLOT(updateSliceSettings())); + connect(m_labelPosition, SIGNAL(currentIndexChanged(int)), this, SLOT(updateSliceSettings())); + + // create chart view + m_chartView = new QChartView(chart); + + // create main layout + QVBoxLayout *settingsLayout = new QVBoxLayout(); + settingsLayout->addWidget(chartSettings); + settingsLayout->addWidget(seriesSettings); + settingsLayout->addWidget(sliceSettings); + settingsLayout->addStretch(); + + QGridLayout *baseLayout = new QGridLayout(); + baseLayout->addLayout(settingsLayout, 0, 0); + baseLayout->addWidget(m_chartView, 0, 1); + setLayout(baseLayout); + + updateSerieSettings(); + updateChartSettings(); +} + + +void MainWidget::updateChartSettings() +{ + QChart::ChartTheme theme = (QChart::ChartTheme) m_themeComboBox->itemData(m_themeComboBox->currentIndex()).toInt(); + m_chartView->chart()->setTheme(theme); + m_chartView->setRenderHint(QPainter::Antialiasing, m_aaCheckBox->isChecked()); + + if (m_animationsCheckBox->checkState() == Qt::Checked) + m_chartView->chart()->setAnimationOptions(QChart::AllAnimations); + else + m_chartView->chart()->setAnimationOptions(QChart::NoAnimation); + + if (m_legendCheckBox->checkState() == Qt::Checked) + m_chartView->chart()->legend()->show(); + else + m_chartView->chart()->legend()->hide(); +} + +void MainWidget::updateSerieSettings() +{ + m_series->setHorizontalPosition(m_hPosition->value()); + m_series->setVerticalPosition(m_vPosition->value()); + m_series->setPieSize(m_sizeFactor->value()); + m_holeSize->setMaximum(m_sizeFactor->value()); + m_series->setPieStartAngle(m_startAngle->value()); + m_series->setPieEndAngle(m_endAngle->value()); + m_series->setHoleSize(m_holeSize->value()); +} + +void MainWidget::updateSliceSettings() +{ + if (!m_slice) + return; + + m_slice->setLabel(m_sliceName->text()); + + m_slice->setValue(m_sliceValue->value()); + + m_slice->setPen(m_penTool->pen()); + m_slice->setBrush(m_brushTool->brush()); + + m_slice->setLabelBrush(m_labelBrushTool->brush()); + m_slice->setLabelVisible(m_sliceLabelVisible->isChecked()); + m_slice->setLabelArmLengthFactor(m_sliceLabelArmFactor->value()); + m_slice->setLabelPosition((QPieSlice::LabelPosition)m_labelPosition->currentIndex()); // assumes that index is in sync with the enum + + m_slice->setExploded(m_sliceExploded->isChecked()); + m_slice->setExplodeDistanceFactor(m_sliceExplodedFactor->value()); +} + +void MainWidget::handleSliceClicked(QPieSlice *slice) +{ + m_slice = static_cast(slice); + + // name + m_sliceName->blockSignals(true); + m_sliceName->setText(slice->label()); + m_sliceName->blockSignals(false); + + // value + m_sliceValue->blockSignals(true); + m_sliceValue->setValue(slice->value()); + m_sliceValue->blockSignals(false); + + // pen + m_pen->setText(PenTool::name(m_slice->pen())); + m_penTool->setPen(m_slice->pen()); + + // brush + m_brush->setText(m_slice->originalBrush().color().name()); + m_brushTool->setBrush(m_slice->originalBrush()); + + // label + m_labelBrush->setText(BrushTool::name(m_slice->labelBrush())); + m_labelBrushTool->setBrush(m_slice->labelBrush()); + m_font->setText(slice->labelFont().toString()); + m_sliceLabelVisible->blockSignals(true); + m_sliceLabelVisible->setChecked(slice->isLabelVisible()); + m_sliceLabelVisible->blockSignals(false); + m_sliceLabelArmFactor->blockSignals(true); + m_sliceLabelArmFactor->setValue(slice->labelArmLengthFactor()); + m_sliceLabelArmFactor->blockSignals(false); + m_labelPosition->blockSignals(true); + m_labelPosition->setCurrentIndex(slice->labelPosition()); // assumes that index is in sync with the enum + m_labelPosition->blockSignals(false); + + // exploded + m_sliceExploded->blockSignals(true); + m_sliceExploded->setChecked(slice->isExploded()); + m_sliceExploded->blockSignals(false); + m_sliceExplodedFactor->blockSignals(true); + m_sliceExplodedFactor->setValue(slice->explodeDistanceFactor()); + m_sliceExplodedFactor->blockSignals(false); +} + +void MainWidget::showFontDialog() +{ + if (!m_slice) + return; + + QFontDialog dialog(m_slice->labelFont()); + dialog.show(); + dialog.exec(); + + m_slice->setLabelFont(dialog.currentFont()); + m_font->setText(dialog.currentFont().toString()); +} + +void MainWidget::appendSlice() +{ + *m_series << new CustomSlice("Slice " + QString::number(m_series->count() + 1), 10.0); +} + +void MainWidget::insertSlice() +{ + if (!m_slice) + return; + + int i = m_series->slices().indexOf(m_slice); + + m_series->insert(i, new CustomSlice("Slice " + QString::number(m_series->count() + 1), 10.0)); +} + +void MainWidget::removeSlice() +{ + if (!m_slice) + return; + + m_sliceName->setText(""); + + m_series->remove(m_slice); + m_slice = 0; +} + +#include "moc_mainwidget.cpp" diff --git a/examples/charts/piechartcustomization/mainwidget.h b/examples/charts/piechartcustomization/mainwidget.h new file mode 100644 index 00000000..e9d3ada1 --- /dev/null +++ b/examples/charts/piechartcustomization/mainwidget.h @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef MAINWIDGET_H +#define MAINWIDGET_H + +#include +#include + +class QLineEdit; +class QPushButton; +class QCheckBox; +class QComboBox; +class QDoubleSpinBox; +class PenTool; +class BrushTool; +class CustomSlice; + +QT_CHARTS_BEGIN_NAMESPACE +class QChartView; +class QPieSeries; +class QPieSlice; +QT_CHARTS_END_NAMESPACE + +QT_CHARTS_USE_NAMESPACE + +class MainWidget : public QWidget +{ + Q_OBJECT + +public: + explicit MainWidget(QWidget *parent = 0); + +public Q_SLOTS: + void updateChartSettings(); + void updateSerieSettings(); + void updateSliceSettings(); + void handleSliceClicked(QPieSlice *slice); + void showFontDialog(); + void appendSlice(); + void insertSlice(); + void removeSlice(); + +private: + QComboBox *m_themeComboBox; + QCheckBox *m_aaCheckBox; + QCheckBox *m_animationsCheckBox; + QCheckBox *m_legendCheckBox; + + QChartView *m_chartView; + QPieSeries *m_series; + CustomSlice *m_slice; + + QDoubleSpinBox *m_hPosition; + QDoubleSpinBox *m_vPosition; + QDoubleSpinBox *m_sizeFactor; + QDoubleSpinBox *m_startAngle; + QDoubleSpinBox *m_endAngle; + QDoubleSpinBox *m_holeSize; + + QLineEdit *m_sliceName; + QDoubleSpinBox *m_sliceValue; + QCheckBox *m_sliceLabelVisible; + QDoubleSpinBox *m_sliceLabelArmFactor; + QCheckBox *m_sliceExploded; + QDoubleSpinBox *m_sliceExplodedFactor; + QPushButton *m_brush; + BrushTool *m_brushTool; + QPushButton *m_pen; + PenTool *m_penTool; + QPushButton *m_font; + QPushButton *m_labelBrush; + QComboBox *m_labelPosition; + BrushTool *m_labelBrushTool; +}; + +#endif // MAINWIDGET_H diff --git a/examples/charts/piechartcustomization/pentool.cpp b/examples/charts/piechartcustomization/pentool.cpp new file mode 100644 index 00000000..104231ee --- /dev/null +++ b/examples/charts/piechartcustomization/pentool.cpp @@ -0,0 +1,141 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "pentool.h" +#include +#include +#include +#include +#include + +PenTool::PenTool(QString title, QWidget *parent) + : QWidget(parent) +{ + setWindowTitle(title); + setWindowFlags(Qt::Tool); + + m_colorButton = new QPushButton(); + + m_widthSpinBox = new QDoubleSpinBox(); + + m_styleCombo = new QComboBox(); + m_styleCombo->addItem("NoPen"); + m_styleCombo->addItem("SolidLine"); + m_styleCombo->addItem("DashLine"); + m_styleCombo->addItem("DotLine"); + m_styleCombo->addItem("DashDotLine"); + m_styleCombo->addItem("DashDotDotLine"); + + m_capStyleCombo = new QComboBox(); + m_capStyleCombo->addItem("FlatCap", Qt::FlatCap); + m_capStyleCombo->addItem("SquareCap", Qt::SquareCap); + m_capStyleCombo->addItem("RoundCap", Qt::RoundCap); + + m_joinStyleCombo = new QComboBox(); + m_joinStyleCombo->addItem("MiterJoin", Qt::MiterJoin); + m_joinStyleCombo->addItem("BevelJoin", Qt::BevelJoin); + m_joinStyleCombo->addItem("RoundJoin", Qt::RoundJoin); + m_joinStyleCombo->addItem("SvgMiterJoin", Qt::SvgMiterJoin); + + QFormLayout *layout = new QFormLayout(); + layout->addRow("Color", m_colorButton); + layout->addRow("Width", m_widthSpinBox); + layout->addRow("Style", m_styleCombo); + layout->addRow("Cap style", m_capStyleCombo); + layout->addRow("Join style", m_joinStyleCombo); + setLayout(layout); + + connect(m_colorButton, SIGNAL(clicked()), this, SLOT(showColorDialog())); + connect(m_widthSpinBox, SIGNAL(valueChanged(double)), this, SLOT(updateWidth(double))); + connect(m_styleCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(updateStyle(int))); + connect(m_capStyleCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(updateCapStyle(int))); + connect(m_joinStyleCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(updateJoinStyle(int))); +} + +void PenTool::setPen(const QPen &pen) +{ + m_pen = pen; + m_colorButton->setText(m_pen.color().name()); + m_widthSpinBox->setValue(m_pen.widthF()); + m_styleCombo->setCurrentIndex(m_pen.style()); // index matches the enum + m_capStyleCombo->setCurrentIndex(m_capStyleCombo->findData(m_pen.capStyle())); + m_joinStyleCombo->setCurrentIndex(m_joinStyleCombo->findData(m_pen.joinStyle())); +} + +QPen PenTool::pen() const +{ + return m_pen; +} + +QString PenTool::name() +{ + return name(m_pen); +} + +QString PenTool::name(const QPen &pen) +{ + return pen.color().name() + ":" + QString::number(pen.widthF()); +} + +void PenTool::showColorDialog() +{ + QColorDialog dialog(m_pen.color()); + dialog.show(); + dialog.exec(); + m_pen.setColor(dialog.selectedColor()); + m_colorButton->setText(m_pen.color().name()); + emit changed(); +} + +void PenTool::updateWidth(double width) +{ + if (!qFuzzyCompare((qreal) width, m_pen.widthF())) { + m_pen.setWidthF(width); + emit changed(); + } +} + +void PenTool::updateStyle(int style) +{ + if (m_pen.style() != style) { + m_pen.setStyle((Qt::PenStyle) style); + emit changed(); + } +} + +void PenTool::updateCapStyle(int index) +{ + Qt::PenCapStyle capStyle = (Qt::PenCapStyle) m_capStyleCombo->itemData(index).toInt(); + if (m_pen.capStyle() != capStyle) { + m_pen.setCapStyle(capStyle); + emit changed(); + } +} + +void PenTool::updateJoinStyle(int index) +{ + Qt::PenJoinStyle joinStyle = (Qt::PenJoinStyle) m_joinStyleCombo->itemData(index).toInt(); + if (m_pen.joinStyle() != joinStyle) { + m_pen.setJoinStyle(joinStyle); + emit changed(); + } +} + +#include "moc_pentool.cpp" diff --git a/examples/charts/piechartcustomization/pentool.h b/examples/charts/piechartcustomization/pentool.h new file mode 100644 index 00000000..66e7ab10 --- /dev/null +++ b/examples/charts/piechartcustomization/pentool.h @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef PENTOOL_H +#define PENTOOL_H + +#include +#include + +class QPushButton; +class QDoubleSpinBox; +class QComboBox; + +class PenTool : public QWidget +{ + Q_OBJECT + +public: + explicit PenTool(QString title, QWidget *parent = 0); + void setPen(const QPen &pen); + QPen pen() const; + QString name(); + static QString name(const QPen &pen); + +Q_SIGNALS: + void changed(); + +public Q_SLOTS: + void showColorDialog(); + void updateWidth(double width); + void updateStyle(int style); + void updateCapStyle(int index); + void updateJoinStyle(int index); + +private: + QPen m_pen; + QPushButton *m_colorButton; + QDoubleSpinBox *m_widthSpinBox; + QComboBox *m_styleCombo; + QComboBox *m_capStyleCombo; + QComboBox *m_joinStyleCombo; +}; + +#endif // PENTOOL_H diff --git a/examples/charts/piechartcustomization/piechartcustomization.pro b/examples/charts/piechartcustomization/piechartcustomization.pro new file mode 100644 index 00000000..722744de --- /dev/null +++ b/examples/charts/piechartcustomization/piechartcustomization.pro @@ -0,0 +1,16 @@ +!include( ../examples.pri ) { + error( "Couldn't find the examples.pri file!" ) +} + +TARGET = piechartcustomization +SOURCES += main.cpp \ + pentool.cpp \ + brushtool.cpp \ + customslice.cpp \ + mainwidget.cpp + +HEADERS += \ + pentool.h \ + brushtool.h \ + customslice.h \ + mainwidget.h diff --git a/examples/charts/piechartdrilldown/drilldownchart.cpp b/examples/charts/piechartdrilldown/drilldownchart.cpp new file mode 100644 index 00000000..b326472c --- /dev/null +++ b/examples/charts/piechartdrilldown/drilldownchart.cpp @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "drilldownchart.h" +#include "drilldownslice.h" + +QT_CHARTS_USE_NAMESPACE + +DrilldownChart::DrilldownChart(QGraphicsItem *parent, Qt::WindowFlags wFlags) + : QChart(QChart::ChartTypeCartesian, parent, wFlags), + m_currentSeries(0) +{ + +} + +DrilldownChart::~DrilldownChart() +{ + +} + +void DrilldownChart::changeSeries(QAbstractSeries *series) +{ + // NOTE: if the series is owned by the chart it will be deleted + // here the "window" owns the series... + if (m_currentSeries) + removeSeries(m_currentSeries); + m_currentSeries = series; + addSeries(series); + setTitle(series->name()); +} + +void DrilldownChart::handleSliceClicked(QPieSlice *slice) +{ + DrilldownSlice *drilldownSlice = static_cast(slice); + changeSeries(drilldownSlice->drilldownSeries()); +} + +#include "moc_drilldownchart.cpp" diff --git a/examples/charts/piechartdrilldown/drilldownchart.h b/examples/charts/piechartdrilldown/drilldownchart.h new file mode 100644 index 00000000..554b6651 --- /dev/null +++ b/examples/charts/piechartdrilldown/drilldownchart.h @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef DRILLDOWNCHART_H +#define DRILLDOWNCHART_H + +#include + +QT_CHARTS_BEGIN_NAMESPACE +class QAbstractSeries; +class QPieSlice; +QT_CHARTS_END_NAMESPACE + +QT_CHARTS_USE_NAMESPACE + +class DrilldownChart : public QChart +{ + Q_OBJECT +public: + explicit DrilldownChart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0); + ~DrilldownChart(); + void changeSeries(QAbstractSeries *series); + +public Q_SLOTS: + void handleSliceClicked(QPieSlice *slice); + +private: + QAbstractSeries *m_currentSeries; +}; + +#endif // DRILLDOWNCHART_H diff --git a/examples/charts/piechartdrilldown/drilldownslice.cpp b/examples/charts/piechartdrilldown/drilldownslice.cpp new file mode 100644 index 00000000..c04d7fe7 --- /dev/null +++ b/examples/charts/piechartdrilldown/drilldownslice.cpp @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "drilldownslice.h" + +QT_CHARTS_USE_NAMESPACE + +DrilldownSlice::DrilldownSlice(qreal value, QString prefix, QAbstractSeries *drilldownSeries) + : m_drilldownSeries(drilldownSeries), + m_prefix(prefix) +{ + setValue(value); + updateLabel(); + setLabelFont(QFont("Arial", 8)); + connect(this, SIGNAL(percentageChanged()), this, SLOT(updateLabel())); + connect(this, SIGNAL(hovered(bool)), this, SLOT(showHighlight(bool))); +} + +DrilldownSlice::~DrilldownSlice() +{ + +} + +QAbstractSeries *DrilldownSlice::drilldownSeries() const +{ + return m_drilldownSeries; +} + +void DrilldownSlice::updateLabel() +{ + QString label = m_prefix; + label += " $"; + label += QString::number(this->value()); + label += ", "; + label += QString::number(this->percentage() * 100, 'f', 1); + label += "%"; + setLabel(label); +} + +void DrilldownSlice::showHighlight(bool show) +{ + setLabelVisible(show); + setExploded(show); +} + +#include "moc_drilldownslice.cpp" diff --git a/examples/charts/piechartdrilldown/drilldownslice.h b/examples/charts/piechartdrilldown/drilldownslice.h new file mode 100644 index 00000000..9743e852 --- /dev/null +++ b/examples/charts/piechartdrilldown/drilldownslice.h @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef DRILLDOWNSLICE_H +#define DRILLDOWNSLICE_H + +#include + +QT_CHARTS_BEGIN_NAMESPACE +class QAbstractSeries; +QT_CHARTS_END_NAMESPACE + +QT_CHARTS_USE_NAMESPACE + +class DrilldownSlice : public QPieSlice +{ + Q_OBJECT + +public: + DrilldownSlice(qreal value, QString prefix, QAbstractSeries *drilldownSeries); + virtual ~DrilldownSlice(); + QAbstractSeries *drilldownSeries() const; + +public Q_SLOTS: + void updateLabel(); + void showHighlight(bool show); + +private: + QAbstractSeries *m_drilldownSeries; + QString m_prefix; +}; + +#endif // DRILLDOWNSLICE_H diff --git a/examples/charts/piechartdrilldown/main.cpp b/examples/charts/piechartdrilldown/main.cpp new file mode 100644 index 00000000..a32587ff --- /dev/null +++ b/examples/charts/piechartdrilldown/main.cpp @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "drilldownchart.h" +#include "drilldownslice.h" +#include +#include +#include +#include +#include +#include + +QT_CHARTS_USE_NAMESPACE + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + + qsrand(QTime(0, 0, 0).secsTo(QTime::currentTime())); + + QMainWindow window; + + DrilldownChart *chart = new DrilldownChart(); + chart->setTheme(QChart::ChartThemeLight); + chart->setAnimationOptions(QChart::AllAnimations); + chart->legend()->setVisible(true); + chart->legend()->setAlignment(Qt::AlignRight); + + QPieSeries *yearSeries = new QPieSeries(&window); + yearSeries->setName("Sales by year - All"); + + QList months; + months << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun" << "Jul" << "Aug" << "Sep" << "Oct" << "Nov" << "Dec"; + QList names; + names << "Jane" << "John" << "Axel" << "Mary" << "Susan" << "Bob"; + + foreach (QString name, names) { + QPieSeries *series = new QPieSeries(&window); + series->setName("Sales by month - " + name); + + foreach (QString month, months) + *series << new DrilldownSlice(qrand() % 1000, month, yearSeries); + + QObject::connect(series, SIGNAL(clicked(QPieSlice*)), chart, SLOT(handleSliceClicked(QPieSlice*))); + + *yearSeries << new DrilldownSlice(series->sum(), name, series); + } + + QObject::connect(yearSeries, SIGNAL(clicked(QPieSlice*)), chart, SLOT(handleSliceClicked(QPieSlice*))); + + chart->changeSeries(yearSeries); + + QChartView *chartView = new QChartView(chart); + chartView->setRenderHint(QPainter::Antialiasing); + window.setCentralWidget(chartView); + window.resize(800, 500); + window.show(); + + return a.exec(); +} diff --git a/examples/charts/piechartdrilldown/piechartdrilldown.pro b/examples/charts/piechartdrilldown/piechartdrilldown.pro new file mode 100644 index 00000000..0f9626c9 --- /dev/null +++ b/examples/charts/piechartdrilldown/piechartdrilldown.pro @@ -0,0 +1,11 @@ +!include( ../examples.pri ) { + error( "Couldn't find the examples.pri file!" ) +} +TARGET = piechartdrilldown +SOURCES += main.cpp \ + drilldownslice.cpp \ + drilldownchart.cpp + +HEADERS += \ + drilldownchart.h \ + drilldownslice.h diff --git a/examples/charts/polarchart/chartview.cpp b/examples/charts/polarchart/chartview.cpp new file mode 100644 index 00000000..038ce709 --- /dev/null +++ b/examples/charts/polarchart/chartview.cpp @@ -0,0 +1,111 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "chartview.h" +#include +#include +#include +#include + +QT_CHARTS_USE_NAMESPACE + +ChartView::ChartView(QWidget *parent) + : QChartView(parent) +{ +} + +//![1] +void ChartView::keyPressEvent(QKeyEvent *event) +{ + switch (event->key()) { + case Qt::Key_Plus: + chart()->zoomIn(); + break; + case Qt::Key_Minus: + chart()->zoomOut(); + break; + case Qt::Key_Left: + chart()->scroll(-1.0, 0); + break; + case Qt::Key_Right: + chart()->scroll(1.0, 0); + break; + case Qt::Key_Up: + chart()->scroll(0, 1.0); + break; + case Qt::Key_Down: + chart()->scroll(0, -1.0); + break; + case Qt::Key_Space: + switchChartType(); + break; + default: + QGraphicsView::keyPressEvent(event); + break; + } +} +//![1] + +//![2] +void ChartView::switchChartType() +{ + QChart *newChart; + QChart *oldChart = chart(); + + if (oldChart->chartType() == QChart::ChartTypeCartesian) + newChart = new QPolarChart(); + else + newChart = new QChart(); + + // Move series and axes from old chart to new one + QList seriesList = oldChart->series(); + QList axisList = oldChart->axes(); + QList > axisRanges; + + foreach (QAbstractAxis *axis, axisList) { + QValueAxis *valueAxis = static_cast(axis); + axisRanges.append(QPair(valueAxis->min(), valueAxis->max())); + } + + foreach (QAbstractSeries *series, seriesList) + oldChart->removeSeries(series); + + foreach (QAbstractAxis *axis, axisList) { + oldChart->removeAxis(axis); + newChart->addAxis(axis, axis->alignment()); + } + + foreach (QAbstractSeries *series, seriesList) { + newChart->addSeries(series); + foreach (QAbstractAxis *axis, axisList) + series->attachAxis(axis); + } + + int count = 0; + foreach (QAbstractAxis *axis, axisList) { + axis->setRange(axisRanges[count].first, axisRanges[count].second); + count++; + } + + newChart->setTitle(oldChart->title()); + setChart(newChart); + delete oldChart; +} +//![2] diff --git a/examples/charts/polarchart/chartview.h b/examples/charts/polarchart/chartview.h new file mode 100644 index 00000000..9f59b469 --- /dev/null +++ b/examples/charts/polarchart/chartview.h @@ -0,0 +1,41 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef CHARTVIEW_H +#define CHARTVIEW_H + +#include +#include + +QT_CHARTS_USE_NAMESPACE + +class ChartView : public QChartView +{ +public: + ChartView(QWidget *parent = 0); + +protected: + void keyPressEvent(QKeyEvent *event); + +private: + void switchChartType(); +}; + +#endif diff --git a/examples/charts/polarchart/main.cpp b/examples/charts/polarchart/main.cpp new file mode 100644 index 00000000..cc959519 --- /dev/null +++ b/examples/charts/polarchart/main.cpp @@ -0,0 +1,137 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "chartview.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +QT_CHARTS_USE_NAMESPACE + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + + const qreal angularMin = -100; + const qreal angularMax = 100; + + const qreal radialMin = -100; + const qreal radialMax = 100; + + QScatterSeries *series1 = new QScatterSeries(); + series1->setName("scatter"); + for (int i = angularMin; i <= angularMax; i += 10) + series1->append(i, (i / radialMax) * radialMax + 8.0); + + QSplineSeries *series2 = new QSplineSeries(); + series2->setName("spline"); + for (int i = angularMin; i <= angularMax; i += 10) + series2->append(i, (i / radialMax) * radialMax); + + QLineSeries *series3 = new QLineSeries(); + series3->setName("star outer"); + qreal ad = (angularMax - angularMin) / 8; + qreal rd = (radialMax - radialMin) / 3 * 1.3; + series3->append(angularMin, radialMax); + series3->append(angularMin + ad*1, radialMin + rd); + series3->append(angularMin + ad*2, radialMax); + series3->append(angularMin + ad*3, radialMin + rd); + series3->append(angularMin + ad*4, radialMax); + series3->append(angularMin + ad*5, radialMin + rd); + series3->append(angularMin + ad*6, radialMax); + series3->append(angularMin + ad*7, radialMin + rd); + series3->append(angularMin + ad*8, radialMax); + + QLineSeries *series4 = new QLineSeries(); + series4->setName("star inner"); + ad = (angularMax - angularMin) / 8; + rd = (radialMax - radialMin) / 3; + series4->append(angularMin, radialMax); + series4->append(angularMin + ad*1, radialMin + rd); + series4->append(angularMin + ad*2, radialMax); + series4->append(angularMin + ad*3, radialMin + rd); + series4->append(angularMin + ad*4, radialMax); + series4->append(angularMin + ad*5, radialMin + rd); + series4->append(angularMin + ad*6, radialMax); + series4->append(angularMin + ad*7, radialMin + rd); + series4->append(angularMin + ad*8, radialMax); + + QAreaSeries *series5 = new QAreaSeries(); + series5->setName("star area"); + series5->setUpperSeries(series3); + series5->setLowerSeries(series4); + series5->setOpacity(0.5); + + //![1] + QPolarChart *chart = new QPolarChart(); + //![1] + chart->addSeries(series1); + chart->addSeries(series2); + chart->addSeries(series3); + chart->addSeries(series4); + chart->addSeries(series5); + + chart->setTitle("Use arrow keys to scroll, +/- to zoom, and space to switch chart type."); + + //![2] + QValueAxis *angularAxis = new QValueAxis(); + angularAxis->setTickCount(9); // First and last ticks are co-located on 0/360 angle. + angularAxis->setLabelFormat("%.1f"); + angularAxis->setShadesVisible(true); + angularAxis->setShadesBrush(QBrush(QColor(249, 249, 255))); + chart->addAxis(angularAxis, QPolarChart::PolarOrientationAngular); + + QValueAxis *radialAxis = new QValueAxis(); + radialAxis->setTickCount(9); + radialAxis->setLabelFormat("%d"); + chart->addAxis(radialAxis, QPolarChart::PolarOrientationRadial); + //![2] + + series1->attachAxis(radialAxis); + series1->attachAxis(angularAxis); + series2->attachAxis(radialAxis); + series2->attachAxis(angularAxis); + series3->attachAxis(radialAxis); + series3->attachAxis(angularAxis); + series4->attachAxis(radialAxis); + series4->attachAxis(angularAxis); + series5->attachAxis(radialAxis); + series5->attachAxis(angularAxis); + + radialAxis->setRange(radialMin, radialMax); + angularAxis->setRange(angularMin, angularMax); + + ChartView *chartView = new ChartView(); + chartView->setChart(chart); + chartView->setRenderHint(QPainter::Antialiasing); + + QMainWindow window; + window.setCentralWidget(chartView); + window.resize(800, 600); + window.show(); + + return a.exec(); +} diff --git a/examples/charts/polarchart/polarchart.pro b/examples/charts/polarchart/polarchart.pro new file mode 100644 index 00000000..8759c1ce --- /dev/null +++ b/examples/charts/polarchart/polarchart.pro @@ -0,0 +1,6 @@ +!include( ../examples.pri ) { + error( "Couldn't find the examples.pri file!" ) +} +TARGET = polarchart +SOURCES += main.cpp chartview.cpp +HEADERS += chartview.h diff --git a/examples/charts/qmlaxes/main.cpp b/examples/charts/qmlaxes/main.cpp new file mode 100644 index 00000000..bb0957e8 --- /dev/null +++ b/examples/charts/qmlaxes/main.cpp @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include + +int main(int argc, char *argv[]) +{ + // Qt Charts uses Qt Graphics View Framework for drawing, therefore QApplication must be used. + QApplication app(argc, argv); + + QQuickView viewer; + + // The following are needed to make examples run without having to install the module + // in desktop environments. +#ifdef Q_OS_WIN + QString extraImportPath(QStringLiteral("%1/../../../../%2")); +#else + QString extraImportPath(QStringLiteral("%1/../../../%2")); +#endif + viewer.engine()->addImportPath(extraImportPath.arg(QGuiApplication::applicationDirPath(), + QString::fromLatin1("qml"))); + QObject::connect(viewer.engine(), &QQmlEngine::quit, &viewer, &QWindow::close); + + viewer.setTitle(QStringLiteral("QML Axes")); + viewer.setSource(QUrl("qrc:/qml/qmlaxes/main.qml")); + viewer.setResizeMode(QQuickView::SizeRootObjectToView); + viewer.show(); + + return app.exec(); +} diff --git a/examples/charts/qmlaxes/qml/qmlaxes/View1.qml b/examples/charts/qmlaxes/qml/qmlaxes/View1.qml new file mode 100644 index 00000000..4c09e269 --- /dev/null +++ b/examples/charts/qmlaxes/qml/qmlaxes/View1.qml @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtCharts 2.0 + +Rectangle { + anchors.fill: parent + + //![1] + ChartView { + title: "Two Series, Common Axes" + anchors.fill: parent + legend.visible: false + antialiasing: true + + ValueAxis { + id: axisX + min: 0 + max: 10 + tickCount: 5 + } + + ValueAxis { + id: axisY + min: -0.5 + max: 1.5 + } + + LineSeries { + id: series1 + axisX: axisX + axisY: axisY + } + + ScatterSeries { + id: series2 + axisX: axisX + axisY: axisY + } + } + + // Add data dynamically to the series + Component.onCompleted: { + for (var i = 0; i <= 10; i++) { + series1.append(i, Math.random()); + series2.append(i, Math.random()); + } + } + //![1] +} diff --git a/examples/charts/qmlaxes/qml/qmlaxes/View2.qml b/examples/charts/qmlaxes/qml/qmlaxes/View2.qml new file mode 100644 index 00000000..4672c19f --- /dev/null +++ b/examples/charts/qmlaxes/qml/qmlaxes/View2.qml @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtCharts 2.0 + +Rectangle { + anchors.fill: parent + + //![1] + ChartView { + title: "Accurate Historical Data" + anchors.fill: parent + legend.visible: false + antialiasing: true + + LineSeries { + axisX: DateTimeAxis { + format: "yyyy MMM" + tickCount: 5 + } + axisY: ValueAxis { + min: 0 + max: 150 + } + + // Please note that month in JavaScript months are zero based, so 2 means March + XYPoint { x: toMsecsSinceEpoch(new Date(1950, 2, 15)); y: 5 } + XYPoint { x: toMsecsSinceEpoch(new Date(1970, 0, 1)); y: 50 } + XYPoint { x: toMsecsSinceEpoch(new Date(1987, 12, 31)); y: 102 } + XYPoint { x: toMsecsSinceEpoch(new Date(1998, 7, 1)); y: 100 } + XYPoint { x: toMsecsSinceEpoch(new Date(2012, 8, 2)); y: 110 } + } + } + + // DateTimeAxis is based on QDateTimes so we must convert our JavaScript dates to + // milliseconds since epoch to make them match the DateTimeAxis values + function toMsecsSinceEpoch(date) { + var msecs = date.getTime(); + return msecs; + } + //![1] +} diff --git a/examples/charts/qmlaxes/qml/qmlaxes/View3.qml b/examples/charts/qmlaxes/qml/qmlaxes/View3.qml new file mode 100644 index 00000000..711833c6 --- /dev/null +++ b/examples/charts/qmlaxes/qml/qmlaxes/View3.qml @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtCharts 2.0 + +Rectangle { + anchors.fill: parent + + //![1] + ChartView { + title: "Numerical Data for Dummies" + anchors.fill: parent + legend.visible: false + antialiasing: true + + LineSeries { + axisY: CategoryAxis { + min: 0 + max: 30 + CategoryRange { + label: "critical" + endValue: 2 + } + CategoryRange { + label: "low" + endValue: 4 + } + CategoryRange { + label: "normal" + endValue: 7 + } + CategoryRange { + label: "high" + endValue: 15 + } + CategoryRange { + label: "extremely high" + endValue: 30 + } + } + + XYPoint { x: 0; y: 4.3 } + XYPoint { x: 1; y: 4.1 } + XYPoint { x: 2; y: 4.7 } + XYPoint { x: 3; y: 3.9 } + XYPoint { x: 4; y: 5.2 } + } + } + //![1] +} diff --git a/examples/charts/qmlaxes/qml/qmlaxes/main.qml b/examples/charts/qmlaxes/qml/qmlaxes/main.qml new file mode 100644 index 00000000..cc75dca3 --- /dev/null +++ b/examples/charts/qmlaxes/qml/qmlaxes/main.qml @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + width: 440 + height: 330 + property bool sourceLoaded: false + + ListView { + id: root + focus: true + anchors.fill: parent + snapMode: ListView.SnapOneItem + highlightRangeMode: ListView.StrictlyEnforceRange + highlightMoveDuration: 250 + orientation: ListView.Horizontal + boundsBehavior: Flickable.StopAtBounds + + onCurrentIndexChanged: { + if (infoText.opacity > 0.0) { + if (sourceLoaded) + infoText.opacity = 0.0; + else if (currentIndex != 0) + currentIndex = 0; + } + } + + model: ListModel { + ListElement {component: "View1.qml"} + ListElement {component: "View2.qml"} + ListElement {component: "View3.qml"} + } + + delegate: Loader { + width: root.width + height: root.height + + source: component + asynchronous: true + + onLoaded: sourceLoaded = true + } + } + + Rectangle { + id: infoText + anchors.centerIn: parent + width: parent.width + height: 40 + color: "black" + Text { + color: "white" + anchors.centerIn: parent + text: "You can navigate between views using swipe or arrow keys" + } + + Behavior on opacity { + NumberAnimation { duration: 400 } + } + } +} diff --git a/examples/charts/qmlaxes/qmlaxes.pro b/examples/charts/qmlaxes/qmlaxes.pro new file mode 100644 index 00000000..50b4c012 --- /dev/null +++ b/examples/charts/qmlaxes/qmlaxes.pro @@ -0,0 +1,7 @@ +!include( ../examples.pri ) { + error( "Couldn't find the examples.pri file!" ) +} + +RESOURCES += resources.qrc +SOURCES += main.cpp +OTHER_FILES += qml/qmlaxes/* diff --git a/examples/charts/qmlaxes/resources.qrc b/examples/charts/qmlaxes/resources.qrc new file mode 100644 index 00000000..c30b2f2c --- /dev/null +++ b/examples/charts/qmlaxes/resources.qrc @@ -0,0 +1,8 @@ + + + qml/qmlaxes/main.qml + qml/qmlaxes/View1.qml + qml/qmlaxes/View2.qml + qml/qmlaxes/View3.qml + + diff --git a/examples/charts/qmlboxplot/main.cpp b/examples/charts/qmlboxplot/main.cpp new file mode 100644 index 00000000..709bd5d2 --- /dev/null +++ b/examples/charts/qmlboxplot/main.cpp @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include + +int main(int argc, char *argv[]) +{ + // Qt Charts uses Qt Graphics View Framework for drawing, therefore QApplication must be used. + QApplication app(argc, argv); + + QQuickView viewer; + + // The following are needed to make examples run without having to install the module + // in desktop environments. +#ifdef Q_OS_WIN + QString extraImportPath(QStringLiteral("%1/../../../../%2")); +#else + QString extraImportPath(QStringLiteral("%1/../../../%2")); +#endif + viewer.engine()->addImportPath(extraImportPath.arg(QGuiApplication::applicationDirPath(), + QString::fromLatin1("qml"))); + QObject::connect(viewer.engine(), &QQmlEngine::quit, &viewer, &QWindow::close); + + viewer.setTitle(QStringLiteral("QML Box Plot")); + viewer.setSource(QUrl("qrc:/qml/qmlboxplot/main.qml")); + viewer.setResizeMode(QQuickView::SizeRootObjectToView); + viewer.show(); + + return app.exec(); +} diff --git a/examples/charts/qmlboxplot/qml/qmlboxplot/main.qml b/examples/charts/qmlboxplot/qml/qmlboxplot/main.qml new file mode 100644 index 00000000..bb71b5df --- /dev/null +++ b/examples/charts/qmlboxplot/qml/qmlboxplot/main.qml @@ -0,0 +1,41 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtCharts 2.0 + +ChartView { + title: "Box Plot series" + width: 400 + height: 300 + theme: ChartView.ChartThemeBrownSand + legend.alignment: Qt.AlignBottom + antialiasing: true + + BoxPlotSeries { + id: plotSeries + name: "Income" + BoxSet { label: "Jan"; values: [3, 4, 5.1, 6.2, 8.5] } + BoxSet { label: "Feb"; values: [5, 6, 7.5, 8.6, 11.8] } + BoxSet { label: "Mar"; values: [3.2, 5, 5.7, 8, 9.2] } + BoxSet { label: "Apr"; values: [3.8, 5, 6.4, 7, 8] } + BoxSet { label: "May"; values: [4, 5, 5.2, 6, 7] } + } +} diff --git a/examples/charts/qmlboxplot/qmlboxplot.pro b/examples/charts/qmlboxplot/qmlboxplot.pro new file mode 100644 index 00000000..237f05f1 --- /dev/null +++ b/examples/charts/qmlboxplot/qmlboxplot.pro @@ -0,0 +1,9 @@ +!include( ../examples.pri ) { + error( "Couldn't find the examples.pri file!" ) +} + +RESOURCES += resources.qrc +SOURCES += main.cpp + +OTHER_FILES += \ + qml/qmlboxplot/main.qml diff --git a/examples/charts/qmlboxplot/resources.qrc b/examples/charts/qmlboxplot/resources.qrc new file mode 100644 index 00000000..49a98f16 --- /dev/null +++ b/examples/charts/qmlboxplot/resources.qrc @@ -0,0 +1,5 @@ + + + qml/qmlboxplot/main.qml + + diff --git a/examples/charts/qmlchart/main.cpp b/examples/charts/qmlchart/main.cpp new file mode 100644 index 00000000..16327b97 --- /dev/null +++ b/examples/charts/qmlchart/main.cpp @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include + +int main(int argc, char *argv[]) +{ + // Qt Charts uses Qt Graphics View Framework for drawing, therefore QApplication must be used. + QApplication app(argc, argv); + + QQuickView viewer; + // The following are needed to make examples run without having to install the module + // in desktop environments. +#ifdef Q_OS_WIN + QString extraImportPath(QStringLiteral("%1/../../../../%2")); +#else + QString extraImportPath(QStringLiteral("%1/../../../%2")); +#endif + viewer.engine()->addImportPath(extraImportPath.arg(QGuiApplication::applicationDirPath(), + QString::fromLatin1("qml"))); + QObject::connect(viewer.engine(), &QQmlEngine::quit, &viewer, &QWindow::close); + + viewer.setTitle(QStringLiteral("QML Chart")); + + viewer.setSource(QUrl("qrc:/qml/qmlchart/main.qml")); + viewer.setResizeMode(QQuickView::SizeRootObjectToView); + viewer.show(); + + return app.exec(); +} diff --git a/examples/charts/qmlchart/qml/qmlchart/View1.qml b/examples/charts/qmlchart/qml/qmlchart/View1.qml new file mode 100644 index 00000000..20590780 --- /dev/null +++ b/examples/charts/qmlchart/qml/qmlchart/View1.qml @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![2] +import QtQuick 2.0 +//![2] +import QtCharts 2.0 + +Rectangle { + anchors.fill: parent + property variant othersSlice: 0 + + //![1] + ChartView { + id: chart + title: "Top-5 car brand shares in Finland" + anchors.fill: parent + legend.alignment: Qt.AlignBottom + antialiasing: true + + PieSeries { + id: pieSeries + PieSlice { label: "Volkswagen"; value: 13.5 } + PieSlice { label: "Toyota"; value: 10.9 } + PieSlice { label: "Ford"; value: 8.6 } + PieSlice { label: "Skoda"; value: 8.2 } + PieSlice { label: "Volvo"; value: 6.8 } + } + } + + Component.onCompleted: { + // You can also manipulate slices dynamically + othersSlice = pieSeries.append("Others", 52.0); + pieSeries.find("Volkswagen").exploded = true; + } + //![1] +} diff --git a/examples/charts/qmlchart/qml/qmlchart/View10.qml b/examples/charts/qmlchart/qml/qmlchart/View10.qml new file mode 100644 index 00000000..a3e3442b --- /dev/null +++ b/examples/charts/qmlchart/qml/qmlchart/View10.qml @@ -0,0 +1,42 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtCharts 2.0 + +Rectangle { + anchors.fill: parent + + //![1] + ChartView { + title: "Horizontal Stacked Bar series" + anchors.fill: parent + legend.alignment: Qt.AlignBottom + antialiasing: true + + HorizontalStackedBarSeries { + axisY: BarCategoryAxis { categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] } + BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] } + BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } + BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } + } + } + //![1] +} diff --git a/examples/charts/qmlchart/qml/qmlchart/View11.qml b/examples/charts/qmlchart/qml/qmlchart/View11.qml new file mode 100644 index 00000000..68aaf907 --- /dev/null +++ b/examples/charts/qmlchart/qml/qmlchart/View11.qml @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtCharts 2.0 + +Rectangle { + anchors.fill: parent + + //![1] + ChartView { + title: "Horizontal Percent Bar series" + anchors.fill: parent + legend.alignment: Qt.AlignBottom + antialiasing: true + + HorizontalPercentBarSeries { + axisY: BarCategoryAxis { categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] } + BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] } + BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } + BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } + } + } + //![1] +} + diff --git a/examples/charts/qmlchart/qml/qmlchart/View12.qml b/examples/charts/qmlchart/qml/qmlchart/View12.qml new file mode 100644 index 00000000..04be8f00 --- /dev/null +++ b/examples/charts/qmlchart/qml/qmlchart/View12.qml @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtCharts 2.0 + +Rectangle { + anchors.fill: parent + + //![1] + ChartView { + id: chart + title: "Production costs" + anchors.fill: parent + legend.visible: false + antialiasing: true + + PieSeries { + id: pieOuter + size: 0.96 + holeSize: 0.7 + PieSlice { id: slice; label: "Alpha"; value: 19511; color: "#8AB846"; borderColor: "#163430" } + PieSlice { label: "Epsilon"; value: 11105; color: "#C0EEFF"; borderColor: "#3B391C" } + PieSlice { label: "Psi"; value: 9352; color: "#DF8939"; borderColor: "#13060C" } + } + + PieSeries { + size: 0.7 + id: pieInner + holeSize: 0.25 + + PieSlice { label: "Materials"; value: 10334; color: "#8AB846"; borderColor: "#163430" } + PieSlice { label: "Employee"; value: 3066; color: "#AAE356"; borderColor: "#163430" } + PieSlice { label: "Logistics"; value: 6111; color: "#99CC4E"; borderColor: "#163430" } + + PieSlice { label: "Materials"; value: 7371; color: "#C0EEFF"; borderColor: "#3B391C" } + PieSlice { label: "Employee"; value: 2443; color: "#C9FAFF"; borderColor: "#3B391C" } + PieSlice { label: "Logistics"; value: 1291; color: "#B0FAFF"; borderColor: "#3B391C" } + + PieSlice { label: "Materials"; value: 4022; color: "#DF8939"; borderColor: "#13060C" } + PieSlice { label: "Employee"; value: 3998; color: "#FC9D42"; borderColor: "#13060C" } + PieSlice { label: "Logistics"; value: 1332; color: "#F2963F"; borderColor: "#13060C" } + } + } + + Component.onCompleted: { + // Set the common slice properties dynamically for convenience + for (var i = 0; i < pieOuter.count; i++) { + pieOuter.at(i).labelPosition = PieSlice.LabelOutside; + pieOuter.at(i).labelVisible = true; + pieOuter.at(i).borderWidth = 3; + } + for (var i = 0; i < pieInner.count; i++) { + pieInner.at(i).labelPosition = PieSlice.LabelInsideNormal; + pieInner.at(i).labelVisible = true; + pieInner.at(i).borderWidth = 2; + } + } + //![1] +} diff --git a/examples/charts/qmlchart/qml/qmlchart/View2.qml b/examples/charts/qmlchart/qml/qmlchart/View2.qml new file mode 100644 index 00000000..be0ae18d --- /dev/null +++ b/examples/charts/qmlchart/qml/qmlchart/View2.qml @@ -0,0 +1,45 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtCharts 2.0 + +Rectangle { + anchors.fill: parent + + //![1] + ChartView { + title: "Line" + anchors.fill: parent + antialiasing: true + + LineSeries { + name: "LineSeries" + XYPoint { x: 0; y: 0 } + XYPoint { x: 1.1; y: 2.1 } + XYPoint { x: 1.9; y: 3.3 } + XYPoint { x: 2.1; y: 2.1 } + XYPoint { x: 2.9; y: 4.9 } + XYPoint { x: 3.4; y: 3.0 } + XYPoint { x: 4.1; y: 3.3 } + } + } + //![1] +} diff --git a/examples/charts/qmlchart/qml/qmlchart/View3.qml b/examples/charts/qmlchart/qml/qmlchart/View3.qml new file mode 100644 index 00000000..e7680bea --- /dev/null +++ b/examples/charts/qmlchart/qml/qmlchart/View3.qml @@ -0,0 +1,45 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtCharts 2.0 + +Rectangle { + anchors.fill: parent + + //![1] + ChartView { + title: "Spline" + anchors.fill: parent + antialiasing: true + + SplineSeries { + name: "SplineSeries" + XYPoint { x: 0; y: 0.0 } + XYPoint { x: 1.1; y: 3.2 } + XYPoint { x: 1.9; y: 2.4 } + XYPoint { x: 2.1; y: 2.1 } + XYPoint { x: 2.9; y: 2.6 } + XYPoint { x: 3.4; y: 2.3 } + XYPoint { x: 4.1; y: 3.1 } + } + } + //![1] +} diff --git a/examples/charts/qmlchart/qml/qmlchart/View4.qml b/examples/charts/qmlchart/qml/qmlchart/View4.qml new file mode 100644 index 00000000..5ba5dc15 --- /dev/null +++ b/examples/charts/qmlchart/qml/qmlchart/View4.qml @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtCharts 2.0 + +Rectangle { + anchors.fill: parent + + //![1] + ChartView { + title: "NHL All-Star Team Players" + anchors.fill: parent + antialiasing: true + + ValueAxis { + id: valueAxis + min: 2000 + max: 2011 + tickCount: 12 + labelFormat: "%.0f" + } + + AreaSeries { + name: "Russian" + color: "#FFD52B1E" + borderColor: "#FF0039A5" + borderWidth: 3 + axisX: valueAxis + upperSeries: LineSeries { + XYPoint { x: 2000; y: 1 } + XYPoint { x: 2001; y: 1 } + XYPoint { x: 2002; y: 1 } + XYPoint { x: 2003; y: 1 } + XYPoint { x: 2004; y: 1 } + XYPoint { x: 2005; y: 0 } + XYPoint { x: 2006; y: 1 } + XYPoint { x: 2007; y: 1 } + XYPoint { x: 2008; y: 4 } + XYPoint { x: 2009; y: 3 } + XYPoint { x: 2010; y: 2 } + XYPoint { x: 2011; y: 1 } + } + } + //![1] + + AreaSeries { + name: "Swedish" + color: "#AF005292" + borderColor: "#AFFDCA00" + borderWidth: 3 + axisX: valueAxis + upperSeries: LineSeries { + XYPoint { x: 2000; y: 1 } + XYPoint { x: 2001; y: 1 } + XYPoint { x: 2002; y: 3 } + XYPoint { x: 2003; y: 3 } + XYPoint { x: 2004; y: 2 } + XYPoint { x: 2005; y: 0 } + XYPoint { x: 2006; y: 2 } + XYPoint { x: 2007; y: 1 } + XYPoint { x: 2008; y: 2 } + XYPoint { x: 2009; y: 1 } + XYPoint { x: 2010; y: 3 } + XYPoint { x: 2011; y: 3 } + } + } + + AreaSeries { + name: "Finnish" + color: "#00357F" + borderColor: "#FEFEFE" + borderWidth: 3 + axisX: valueAxis + upperSeries: LineSeries { + XYPoint { x: 2000; y: 0 } + XYPoint { x: 2001; y: 0 } + XYPoint { x: 2002; y: 0 } + XYPoint { x: 2003; y: 0 } + XYPoint { x: 2004; y: 0 } + XYPoint { x: 2005; y: 0 } + XYPoint { x: 2006; y: 1 } + XYPoint { x: 2007; y: 0 } + XYPoint { x: 2008; y: 0 } + XYPoint { x: 2009; y: 0 } + XYPoint { x: 2010; y: 0 } + XYPoint { x: 2011; y: 1 } + } + } + } +} diff --git a/examples/charts/qmlchart/qml/qmlchart/View5.qml b/examples/charts/qmlchart/qml/qmlchart/View5.qml new file mode 100644 index 00000000..7cce1d77 --- /dev/null +++ b/examples/charts/qmlchart/qml/qmlchart/View5.qml @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtCharts 2.0 + +Rectangle { + anchors.fill: parent + + //![1] + ChartView { + title: "Scatters" + anchors.fill: parent + antialiasing: true + + ScatterSeries { + id: scatter1 + name: "Scatter1" + XYPoint { x: 1.5; y: 1.5 } + XYPoint { x: 1.5; y: 1.6 } + XYPoint { x: 1.57; y: 1.55 } + XYPoint { x: 1.8; y: 1.8 } + XYPoint { x: 1.9; y: 1.6 } + XYPoint { x: 2.1; y: 1.3 } + XYPoint { x: 2.5; y: 2.1 } + } + + ScatterSeries { + name: "Scatter2" + //![1] + XYPoint { x: 2.0; y: 2.0 } + XYPoint { x: 2.0; y: 2.1 } + XYPoint { x: 2.07; y: 2.05 } + XYPoint { x: 2.2; y: 2.9 } + XYPoint { x: 2.4; y: 2.7 } + XYPoint { x: 2.67; y: 2.65 } + } + } +} diff --git a/examples/charts/qmlchart/qml/qmlchart/View6.qml b/examples/charts/qmlchart/qml/qmlchart/View6.qml new file mode 100644 index 00000000..78d3a834 --- /dev/null +++ b/examples/charts/qmlchart/qml/qmlchart/View6.qml @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtCharts 2.0 + +Rectangle { + anchors.fill: parent + + //![1] + ChartView { + title: "Bar series" + anchors.fill: parent + legend.alignment: Qt.AlignBottom + antialiasing: true + + BarSeries { + id: mySeries + axisX: BarCategoryAxis { categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] } + BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] } + BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } + BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } + } + } + //![1] +} diff --git a/examples/charts/qmlchart/qml/qmlchart/View7.qml b/examples/charts/qmlchart/qml/qmlchart/View7.qml new file mode 100644 index 00000000..4980e70b --- /dev/null +++ b/examples/charts/qmlchart/qml/qmlchart/View7.qml @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtCharts 2.0 + +Rectangle { + anchors.fill: parent + + //![1] + ChartView { + title: "Stacked Bar series" + anchors.fill: parent + legend.alignment: Qt.AlignBottom + antialiasing: true + + StackedBarSeries { + id: mySeries + axisX: BarCategoryAxis { categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] } + BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] } + BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } + BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } + } + } + //![1] +} diff --git a/examples/charts/qmlchart/qml/qmlchart/View8.qml b/examples/charts/qmlchart/qml/qmlchart/View8.qml new file mode 100644 index 00000000..bba51cc9 --- /dev/null +++ b/examples/charts/qmlchart/qml/qmlchart/View8.qml @@ -0,0 +1,42 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtCharts 2.0 + +Rectangle { + anchors.fill: parent + + //![1] + ChartView { + title: "Percent Bar series" + anchors.fill: parent + legend.alignment: Qt.AlignBottom + antialiasing: true + + PercentBarSeries { + axisX: BarCategoryAxis { categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] } + BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] } + BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } + BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } + } + } + //![1] +} diff --git a/examples/charts/qmlchart/qml/qmlchart/View9.qml b/examples/charts/qmlchart/qml/qmlchart/View9.qml new file mode 100644 index 00000000..fe0f0a55 --- /dev/null +++ b/examples/charts/qmlchart/qml/qmlchart/View9.qml @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtCharts 2.0 + +Rectangle { + anchors.fill: parent + + //![1] + ChartView { + title: "Horizontal Bar series" + anchors.fill: parent + legend.alignment: Qt.AlignBottom + antialiasing: true + + HorizontalBarSeries { + axisY: BarCategoryAxis { categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] } + BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] } + BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } + BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } + } + } + //![1] +} + diff --git a/examples/charts/qmlchart/qml/qmlchart/main.qml b/examples/charts/qmlchart/qml/qmlchart/main.qml new file mode 100644 index 00000000..0a384636 --- /dev/null +++ b/examples/charts/qmlchart/qml/qmlchart/main.qml @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![1] +import QtQuick 2.0 +//![1] + +Rectangle { + width: 600 + height: 400 + property bool sourceLoaded: false + + ListView { + id: root + focus: true + anchors.fill: parent + snapMode: ListView.SnapOneItem + highlightRangeMode: ListView.StrictlyEnforceRange + highlightMoveDuration: 250 + orientation: ListView.Horizontal + boundsBehavior: Flickable.StopAtBounds + + onCurrentIndexChanged: { + if (infoText.opacity > 0.0) { + if (sourceLoaded) + infoText.opacity = 0.0; + else if (currentIndex != 0) + currentIndex = 0; + } + } + + model: ListModel { + ListElement {component: "View1.qml"} + ListElement {component: "View2.qml"} + ListElement {component: "View3.qml"} + ListElement {component: "View4.qml"} + ListElement {component: "View5.qml"} + ListElement {component: "View6.qml"} + ListElement {component: "View7.qml"} + ListElement {component: "View8.qml"} + ListElement {component: "View9.qml"} + ListElement {component: "View10.qml"} + ListElement {component: "View11.qml"} + ListElement {component: "View12.qml"} + } + + delegate: Loader { + width: root.width + height: root.height + + source: component + asynchronous: true + + onLoaded: sourceLoaded = true + } + } + + Rectangle { + id: infoText + anchors.centerIn: parent + width: parent.width + height: 40 + color: "black" + Text { + color: "white" + anchors.centerIn: parent + text: "You can navigate between views using swipe or arrow keys" + } + + Behavior on opacity { + NumberAnimation { duration: 400 } + } + } +} diff --git a/examples/charts/qmlchart/qmlchart.pro b/examples/charts/qmlchart/qmlchart.pro new file mode 100644 index 00000000..82426424 --- /dev/null +++ b/examples/charts/qmlchart/qmlchart.pro @@ -0,0 +1,7 @@ +!include( ../examples.pri ) { + error( "Couldn't find the examples.pri file!" ) +} + +RESOURCES += resources.qrc +SOURCES += main.cpp +OTHER_FILES += qml/qmlchart/* diff --git a/examples/charts/qmlchart/resources.qrc b/examples/charts/qmlchart/resources.qrc new file mode 100644 index 00000000..7b14dace --- /dev/null +++ b/examples/charts/qmlchart/resources.qrc @@ -0,0 +1,17 @@ + + + qml/qmlchart/main.qml + qml/qmlchart/View1.qml + qml/qmlchart/View2.qml + qml/qmlchart/View3.qml + qml/qmlchart/View4.qml + qml/qmlchart/View5.qml + qml/qmlchart/View6.qml + qml/qmlchart/View7.qml + qml/qmlchart/View8.qml + qml/qmlchart/View9.qml + qml/qmlchart/View10.qml + qml/qmlchart/View11.qml + qml/qmlchart/View12.qml + + diff --git a/examples/charts/qmlcustomizations/main.cpp b/examples/charts/qmlcustomizations/main.cpp new file mode 100644 index 00000000..e36fd058 --- /dev/null +++ b/examples/charts/qmlcustomizations/main.cpp @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include + +int main(int argc, char *argv[]) +{ + // Qt Charts uses Qt Graphics View Framework for drawing, therefore QApplication must be used. + QApplication app(argc, argv); + + QQuickView viewer; + // The following are needed to make examples run without having to install the module + // in desktop environments. +#ifdef Q_OS_WIN + QString extraImportPath(QStringLiteral("%1/../../../../%2")); +#else + QString extraImportPath(QStringLiteral("%1/../../../%2")); +#endif + viewer.engine()->addImportPath(extraImportPath.arg(QGuiApplication::applicationDirPath(), + QString::fromLatin1("qml"))); + QObject::connect(viewer.engine(), &QQmlEngine::quit, &viewer, &QWindow::close); + + viewer.setTitle(QStringLiteral("QML Customizations")); + viewer.setSource(QUrl("qrc:/qml/qmlcustomizations/main.qml")); + viewer.setResizeMode(QQuickView::SizeRootObjectToView); + viewer.show(); + + return app.exec(); +} diff --git a/examples/charts/qmlcustomizations/qml/qmlcustomizations/main.qml b/examples/charts/qmlcustomizations/qml/qmlcustomizations/main.qml new file mode 100644 index 00000000..8000caf7 --- /dev/null +++ b/examples/charts/qmlcustomizations/qml/qmlcustomizations/main.qml @@ -0,0 +1,102 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtCharts 2.0 + +Rectangle { + width: 400 + height: 300 + property int __activeIndex: 1 + property real __intervalCoefficient: 0 + + //![1] + ChartView { + id: chartView + anchors.fill: parent + title: "Wheel of fortune" + legend.visible: false + antialiasing: true + + PieSeries { + id: wheelOfFortune + horizontalPosition: 0.3 + } + + SplineSeries { + id: splineSeries + } + + ScatterSeries { + id: scatterSeries + } + } + //![1] + + //![2] + Component.onCompleted: { + __intervalCoefficient = Math.random() + 0.1; + + for (var i = 0; i < 20; i++) + wheelOfFortune.append("", 1); + + var interval = 1; + for (var j = 0; interval < 800; j++) { + interval = __intervalCoefficient * j * j; + splineSeries.append(j, interval); + } + chartView.axisX(scatterSeries).max = j; + chartView.axisY(scatterSeries).max = 1000; + } + //![2] + + Timer { + triggeredOnStart: true + running: true + repeat: true + interval: 100 + onTriggered: { + var index = __activeIndex % wheelOfFortune.count; + if (interval < 700) { + //![3] + wheelOfFortune.at(index).exploded = false; + __activeIndex++; + index = __activeIndex % wheelOfFortune.count; + wheelOfFortune.at(index).exploded = true; + //![3] + interval = splineSeries.at(__activeIndex).y; + //![4] + scatterSeries.clear(); + scatterSeries.append(__activeIndex, interval); + scatterSeries.color = Qt.tint(scatterSeries.color, "#05FF0000"); + scatterSeries.markerSize += 0.5; + //![4] + } else { + //![5] + // Switch the colors of the slice and the border + wheelOfFortune.at(index).borderWidth = 2; + var borderColor = wheelOfFortune.at(index).borderColor; + wheelOfFortune.at(index).borderColor = wheelOfFortune.at(index).color; + wheelOfFortune.at(index).color = borderColor; + //![5] + } + } + } +} diff --git a/examples/charts/qmlcustomizations/qmlcustomizations.pro b/examples/charts/qmlcustomizations/qmlcustomizations.pro new file mode 100644 index 00000000..ae2d4e5b --- /dev/null +++ b/examples/charts/qmlcustomizations/qmlcustomizations.pro @@ -0,0 +1,7 @@ +!include( ../examples.pri ) { + error( "Couldn't find the examples.pri file!" ) +} + +RESOURCES += resources.qrc +SOURCES += main.cpp +OTHER_FILES += qml/qmlcustomizations/* diff --git a/examples/charts/qmlcustomizations/resources.qrc b/examples/charts/qmlcustomizations/resources.qrc new file mode 100644 index 00000000..35dd1b54 --- /dev/null +++ b/examples/charts/qmlcustomizations/resources.qrc @@ -0,0 +1,5 @@ + + + qml/qmlcustomizations/main.qml + + diff --git a/examples/charts/qmlcustomlegend/main.cpp b/examples/charts/qmlcustomlegend/main.cpp new file mode 100644 index 00000000..82cda036 --- /dev/null +++ b/examples/charts/qmlcustomlegend/main.cpp @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include + +int main(int argc, char *argv[]) +{ + // Qt Charts uses Qt Graphics View Framework for drawing, therefore QApplication must be used. + QApplication app(argc, argv); + + QQuickView viewer; + // The following are needed to make examples run without having to install the module + // in desktop environments. +#ifdef Q_OS_WIN + QString extraImportPath(QStringLiteral("%1/../../../../%2")); +#else + QString extraImportPath(QStringLiteral("%1/../../../%2")); +#endif + viewer.engine()->addImportPath(extraImportPath.arg(QGuiApplication::applicationDirPath(), + QString::fromLatin1("qml"))); + QObject::connect(viewer.engine(), &QQmlEngine::quit, &viewer, &QWindow::close); + + viewer.setTitle(QStringLiteral("QML Custom Legend")); + viewer.setSource(QUrl("qrc:/qml/qmlcustomlegend/main.qml")); + viewer.setResizeMode(QQuickView::SizeRootObjectToView); + viewer.show(); + + return app.exec(); +} diff --git a/examples/charts/qmlcustomlegend/qml/qmlcustomlegend/AnimatedAreaSeries.qml b/examples/charts/qmlcustomlegend/qml/qmlcustomlegend/AnimatedAreaSeries.qml new file mode 100644 index 00000000..0af6b5c3 --- /dev/null +++ b/examples/charts/qmlcustomlegend/qml/qmlcustomlegend/AnimatedAreaSeries.qml @@ -0,0 +1,30 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtCharts 2.0 + +AreaSeries { + id: series + + Behavior on opacity { + NumberAnimation { duration: 250 } + } +} diff --git a/examples/charts/qmlcustomlegend/qml/qmlcustomlegend/ChartViewHighlighted.qml b/examples/charts/qmlcustomlegend/qml/qmlcustomlegend/ChartViewHighlighted.qml new file mode 100644 index 00000000..7ca033b2 --- /dev/null +++ b/examples/charts/qmlcustomlegend/qml/qmlcustomlegend/ChartViewHighlighted.qml @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtCharts 2.0 + +//![1] +ChartView { + id: chartViewHighlighted + title: "" + property variant selectedSeries + signal clicked + legend.visible: false + margins.top: 10 + margins.bottom: 0 + antialiasing: true + + LineSeries { + id: lineSeries + + axisX: ValueAxis { + min: 2006 + max: 2012 + labelFormat: "%.0f" + tickCount: 7 + } + axisY: ValueAxis { + id: axisY + titleText: "EUR" + min: 0 + max: 40000 + niceNumbersEnabled: true + labelFormat: "%.0f" + tickCount: 5 + } + } +//![1] + + MouseArea { + anchors.fill: parent + onClicked: { + chartViewHighlighted.clicked(); + } + } + + onSelectedSeriesChanged: { + lineSeries.clear(); + lineSeries.color = selectedSeries.color; + var maxVal = 0.0; + for (var i = 0; i < selectedSeries.upperSeries.count; i++ ) { + var y = selectedSeries.upperSeries.at(i).y - selectedSeries.lowerSeries.at(i).y; + lineSeries.append(selectedSeries.upperSeries.at(i).x, y); + if (maxVal < y) + maxVal = y; + } + chartViewHighlighted.title = selectedSeries.name; + axisY.max = maxVal; + } +} + diff --git a/examples/charts/qmlcustomlegend/qml/qmlcustomlegend/ChartViewSelector.qml b/examples/charts/qmlcustomlegend/qml/qmlcustomlegend/ChartViewSelector.qml new file mode 100644 index 00000000..86714a01 --- /dev/null +++ b/examples/charts/qmlcustomlegend/qml/qmlcustomlegend/ChartViewSelector.qml @@ -0,0 +1,100 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtCharts 2.0 + +Rectangle { + id: chartViewSelector + width: parent.width + height: parent.height + signal seriesAdded(string seriesName, color seriesColor) + + function highlightSeries(seriesName) { + if (seriesName == "") { + if (state != "") + state = ""; + + for (var i = 0; i < chartViewStacked.count; i++) + chartViewStacked.series(i).opacity = 1.0; + } else { + var targetOpacity = 0.1; + for (var j = 0; j < chartViewStacked.count; j++) { + if (chartViewStacked.series(j).name != seriesName) + chartViewStacked.series(j).opacity = 0.25; + else if (state == "highlight") + chartViewSelected.selectedSeries = chartViewStacked.series(j); + } + } + } + + function selectSeries(seriesName) { + for (var i = 0; i < chartViewStacked.count; i++) { + if (chartViewStacked.series(i).name == seriesName) { + chartViewSelected.selectedSeries = chartViewStacked.series(i); + if (chartViewSelector.state == "") + chartViewSelector.state = "highlighted"; + else + chartViewSelector.state = ""; + } + } + } + + ChartViewStacked { + id: chartViewStacked + anchors.left: parent.left + anchors.leftMargin: 0 + width: parent.width + height: parent.height + onSeriesAdded: chartViewSelector.seriesAdded(series.name, series.color); + } + + ChartViewHighlighted { + id: chartViewSelected + anchors.left: chartViewStacked.right + width: parent.width + height: parent.height + + opacity: 0.0 + onClicked: { + chartViewSelector.state = ""; + } + } + + states: State { + name: "highlighted" + PropertyChanges { + target: chartViewSelected + opacity: 1.0 + } + PropertyChanges { + target: chartViewStacked + anchors.leftMargin: -chartViewStacked.width + opacity: 0.0 + } + } + + transitions: Transition { + PropertyAnimation { + properties: "width, height, opacity, anchors.leftMargin" + duration: 400 + } + } +} diff --git a/examples/charts/qmlcustomlegend/qml/qmlcustomlegend/ChartViewStacked.qml b/examples/charts/qmlcustomlegend/qml/qmlcustomlegend/ChartViewStacked.qml new file mode 100644 index 00000000..ade88c04 --- /dev/null +++ b/examples/charts/qmlcustomlegend/qml/qmlcustomlegend/ChartViewStacked.qml @@ -0,0 +1,117 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtCharts 2.0 + +ChartView { + id: chartView + title: "Government Taxes" + legend.visible: false + signal entered(string seriesName) + signal exited(string seriesName) + margins.top: 10 + margins.bottom: 0 + antialiasing: true + + ValueAxis { + id: axisX + min: 2006 + max: 2012 + tickCount: 7 + labelFormat: "%.0f" + } + + ValueAxis { + id: axisY + titleText: "EUR" + min: 0 + max: 90000 + tickCount: 10 + labelFormat: "%.0f" + } + + AnimatedAreaSeries { + id: stateSeries + name: "state" + axisX: axisX + axisY: axisY + borderWidth: 0 + upperSeries: LineSeries { + id: stateUpper + XYPoint { x: 2006; y: 33119 } + XYPoint { x: 2007; y: 37941 } + XYPoint { x: 2008; y: 40122 } + XYPoint { x: 2009; y: 38991 } + XYPoint { x: 2010; y: 34055 } + XYPoint { x: 2011; y: 34555 } + XYPoint { x: 2012; y: 38991 } + } + lowerSeries: LineSeries { + XYPoint { x: 2006; y: 0 } + XYPoint { x: 2007; y: 0 } + XYPoint { x: 2008; y: 0 } + XYPoint { x: 2009; y: 0 } + XYPoint { x: 2010; y: 0 } + XYPoint { x: 2011; y: 0 } + XYPoint { x: 2012; y: 0 } + } + } + + //![1] + AnimatedAreaSeries { + id: municipalSeries + name: "municipal" + axisX: axisX + axisY: axisY + borderWidth: 0 + upperSeries: LineSeries { + id: municipalUpper + XYPoint { x: 2006; y: 33119 + 13443 } + XYPoint { x: 2007; y: 37941 + 15311 } + XYPoint { x: 2008; y: 40122 + 16552 } + XYPoint { x: 2009; y: 38991 + 17904 } + XYPoint { x: 2010; y: 34055 + 17599 } + XYPoint { x: 2011; y: 34555 + 19002 } + XYPoint { x: 2012; y: 38991 + 19177 } + } + lowerSeries: stateUpper + } + //![1] + + AnimatedAreaSeries { + id: socialSeries + name: "social sec." + axisX: axisX + axisY: axisY + borderWidth: 0 + upperSeries: LineSeries { + id: socialUpper + XYPoint { x: 2006; y: 33119 + 13443 + 18855 } + XYPoint { x: 2007; y: 37941 + 15311 + 20238 } + XYPoint { x: 2008; y: 40122 + 16552 + 21347 } + XYPoint { x: 2009; y: 38991 + 17904 + 22376 } + XYPoint { x: 2010; y: 34055 + 17599 + 22076 } + XYPoint { x: 2011; y: 34555 + 19002 + 22631 } + XYPoint { x: 2012; y: 38991 + 19177 + 23686 } + } + lowerSeries: municipalUpper + } +} diff --git a/examples/charts/qmlcustomlegend/qml/qmlcustomlegend/CustomLegend.qml b/examples/charts/qmlcustomlegend/qml/qmlcustomlegend/CustomLegend.qml new file mode 100644 index 00000000..d146f83c --- /dev/null +++ b/examples/charts/qmlcustomlegend/qml/qmlcustomlegend/CustomLegend.qml @@ -0,0 +1,136 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtCharts 2.0 + +Rectangle { + id: legend + color: "lightgray" + + property int seriesCount: 0 + property variant seriesNames: [] + property variant seriesColors: [] + signal entered(string seriesName) + signal exited(string seriesName) + signal selected(string seriesName) + + function addSeries(seriesName, color) { + var names = seriesNames; + names[seriesCount] = seriesName; + seriesNames = names; + + var colors = seriesColors; + colors[seriesCount] = color; + seriesColors = colors; + + seriesCount++; + } + + Gradient { + id: buttonGradient + GradientStop { position: 0.0; color: "#F0F0F0" } + GradientStop { position: 1.0; color: "#A0A0A0" } + } + + Gradient { + id: buttonGradientHovered + GradientStop { position: 0.0; color: "#FFFFFF" } + GradientStop { position: 1.0; color: "#B0B0B0" } + } + + //![2] + Component { + id: legendDelegate + Rectangle { + id: rect + //![2] + property string name: seriesNames[index] + property color markerColor: seriesColors[index] + gradient: buttonGradient + border.color: "#A0A0A0" + border.width: 1 + radius: 4 + + implicitWidth: label.implicitWidth + marker.implicitWidth + 30 + implicitHeight: label.implicitHeight + marker.implicitHeight + 10 + + Row { + id: row + spacing: 5 + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.left + anchors.leftMargin: 5 + Rectangle { + id: marker + anchors.verticalCenter: parent.verticalCenter + color: markerColor + opacity: 0.3 + radius: 4 + width: 12 + height: 10 + } + Text { + id: label + anchors.verticalCenter: parent.verticalCenter + anchors.verticalCenterOffset: -1 + text: name + } + } + + //![3] + MouseArea { + id: mouseArea + anchors.fill: parent + hoverEnabled: true + onEntered: { + rect.gradient = buttonGradientHovered; + legend.entered(label.text); + } + onExited: { + rect.gradient = buttonGradient; + legend.exited(label.text); + marker.opacity = 0.3; + marker.height = 10; + } + onClicked: { + legend.selected(label.text); + marker.opacity = 1.0; + marker.height = 12; + } + } + //![3] + } + } + + //![1] + Row { + id: legendRow + anchors.centerIn: parent + spacing: 10 + + Repeater { + id: legendRepeater + model: seriesCount + delegate: legendDelegate + } + } + //![1] +} diff --git a/examples/charts/qmlcustomlegend/qml/qmlcustomlegend/main.qml b/examples/charts/qmlcustomlegend/qml/qmlcustomlegend/main.qml new file mode 100644 index 00000000..815d5331 --- /dev/null +++ b/examples/charts/qmlcustomlegend/qml/qmlcustomlegend/main.qml @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtCharts 2.0 + +Rectangle { + id: main + width: 400 + height: 320 + + Column { + id: column + anchors.fill: parent + anchors.bottomMargin: 10 + spacing: 0 + + ChartViewSelector { + id: chartViewSelector + width: parent.width + height: parent.height - customLegend.height - anchors.bottomMargin + onSeriesAdded: customLegend.addSeries(seriesName, seriesColor); + } + + CustomLegend { + id: customLegend + width: parent.width + height: 50 + anchors.horizontalCenter: parent.horizontalCenter + onEntered: chartViewSelector.highlightSeries(seriesName); + onExited: chartViewSelector.highlightSeries(""); + onSelected: chartViewSelector.selectSeries(seriesName); + } + } + + states: State { + name: "highlighted" + PropertyChanges { + target: chartViewHighlighted + width: column.width + height: (column.height - column.anchors.margins * 2 - customLegend.height) + } + PropertyChanges { + target: chartViewStacked + width: 1 + height: 1 + } + } +} diff --git a/examples/charts/qmlcustomlegend/qmlcustomlegend.pro b/examples/charts/qmlcustomlegend/qmlcustomlegend.pro new file mode 100644 index 00000000..d42afded --- /dev/null +++ b/examples/charts/qmlcustomlegend/qmlcustomlegend.pro @@ -0,0 +1,7 @@ +!include( ../examples.pri ) { + error( "Couldn't find the examples.pri file!" ) +} + +RESOURCES += resources.qrc +SOURCES += main.cpp +OTHER_FILES += qml/qmlcustomlegend/* diff --git a/examples/charts/qmlcustomlegend/resources.qrc b/examples/charts/qmlcustomlegend/resources.qrc new file mode 100644 index 00000000..bd49690b --- /dev/null +++ b/examples/charts/qmlcustomlegend/resources.qrc @@ -0,0 +1,10 @@ + + + qml/qmlcustomlegend/main.qml + qml/qmlcustomlegend/CustomLegend.qml + qml/qmlcustomlegend/ChartViewStacked.qml + qml/qmlcustomlegend/ChartViewHighlighted.qml + qml/qmlcustomlegend/ChartViewSelector.qml + qml/qmlcustomlegend/AnimatedAreaSeries.qml + + diff --git a/examples/charts/qmlf1legends/main.cpp b/examples/charts/qmlf1legends/main.cpp new file mode 100644 index 00000000..df79b769 --- /dev/null +++ b/examples/charts/qmlf1legends/main.cpp @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include + +int main(int argc, char *argv[]) +{ + // Qt Charts uses Qt Graphics View Framework for drawing, therefore QApplication must be used. + QApplication app(argc, argv); + + QQuickView viewer; + // The following are needed to make examples run without having to install the module + // in desktop environments. +#ifdef Q_OS_WIN + QString extraImportPath(QStringLiteral("%1/../../../../%2")); +#else + QString extraImportPath(QStringLiteral("%1/../../../%2")); +#endif + viewer.engine()->addImportPath(extraImportPath.arg(QGuiApplication::applicationDirPath(), + QString::fromLatin1("qml"))); + QObject::connect(viewer.engine(), &QQmlEngine::quit, &viewer, &QWindow::close); + + viewer.setTitle(QStringLiteral("QML F1 Legends")); + viewer.setSource(QUrl("qrc:/qml/qmlf1legends/main.qml")); + viewer.setResizeMode(QQuickView::SizeRootObjectToView); + viewer.show(); + + return app.exec(); +} diff --git a/examples/charts/qmlf1legends/qml/qmlf1legends/SpeedsXml.qml b/examples/charts/qmlf1legends/qml/qmlf1legends/SpeedsXml.qml new file mode 100644 index 00000000..00d45a17 --- /dev/null +++ b/examples/charts/qmlf1legends/qml/qmlf1legends/SpeedsXml.qml @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick.XmlListModel 2.0 + +//![1] +XmlListModel { + // Hard-coded test data + xml: "0Fittipaldi104.12" + +"0Stewart106.12" + +"0Hunt106.12" +//![1] + +"1Fittipaldi115.12" + +"1Stewart114.12" + +"1Hunt115.12" + +"2Hunt165.23" + +"2Fittipaldi175.23" + +"2Stewart168.23" + +"3Hunt104.87" + +"3Fittipaldi104.43" + +"3Stewart94.83" + +"4Hunt107.87" + +"4Fittipaldi111.84" + +"4Stewart106.84" + +"5Hunt94.87" + +"5Stewart92.37" + +"5Fittipaldi99.37" + +"6Hunt52.87" + +"6Fittipaldi42.87" + +"6Stewart55.87" + +"7Hunt77.87" + +"7Fittipaldi72.87" + +"7Stewart87.87" + +"8Hunt94.17" + +"8Fittipaldi98.17" + +"8Stewart84.17" + +"9Hunt91.87" + +"9Fittipaldi71.87" + +"9Stewart81.87" + +"10Hunt104.87" + +"10Fittipaldi115.87" + +"10Stewart119.87" + +"11Hunt162.87" + +"11Fittipaldi155.84" + +"11Stewart152.84" + +"12Hunt181.87" + +"12Fittipaldi161.85" + +"12Stewart167.85" + +"13Hunt155.87" + +"13Fittipaldi154.87" + +"13Stewart164.87" + +"14Hunt197.57" + +"14Fittipaldi187.54" + +"14Stewart180.54" + +"15Fittipaldi216.87" + +"15Hunt207.87" + +"15Stewart197.87" + +"16Hunt82.87" + +"16Fittipaldi79.37" + +"16Stewart85.37" + +"17Hunt153.87" + +"17Fittipaldi143.87" + +"17Stewart133.87" + +"18Hunt89.87" + +"18Fittipaldi95.85" + +"18Stewart98.85" + +"19Hunt169.87" + +"19Stewart167.87" + +"19Fittipaldi154.87" + +"" +//![2] + query: "/results/row" + + XmlRole { name: "speedTrap"; query: "speedTrap/string()" } + XmlRole { name: "driver"; query: "driver/string()" } + XmlRole { name: "speed"; query: "speed/string()" } +} +//![2] diff --git a/examples/charts/qmlf1legends/qml/qmlf1legends/main.qml b/examples/charts/qmlf1legends/qml/qmlf1legends/main.qml new file mode 100644 index 00000000..9aaec276 --- /dev/null +++ b/examples/charts/qmlf1legends/qml/qmlf1legends/main.qml @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtCharts 2.0 +import QtQuick.XmlListModel 2.0 + +Rectangle { + width: 400 + height: 300 + property int currentIndex: -1 + + //![1] + ChartView { + id: chartView + title: "Driver Speeds, lap 1" + anchors.fill: parent + legend.alignment: Qt.AlignTop + animationOptions: ChartView.SeriesAnimations + antialiasing: true + } + //![1] + + //![2] + // An example XmlListModel containing F1 legend drivers' speeds at speed traps + SpeedsXml { + id: speedsXml + onStatusChanged: { + if (status == XmlListModel.Ready) { + timer.start(); + } + } + } + //![2] + + //![3] + // A timer to mimic refreshing the data dynamically + Timer { + id: timer + interval: 700 + repeat: true + triggeredOnStart: true + running: false + onTriggered: { + currentIndex++; + if (currentIndex < speedsXml.count) { + // Check if there is a series for the data already (we are using driver name to identify series) + var lineSeries = chartView.series(speedsXml.get(currentIndex).driver); + if (!lineSeries) { + lineSeries = chartView.createSeries(ChartView.SeriesTypeLine, speedsXml.get(currentIndex).driver); + chartView.axisY().min = 0; + chartView.axisY().max = 250; + chartView.axisY().tickCount = 6; + chartView.axisY().titleText = "speed (kph)"; + chartView.axisX().titleText = "speed trap"; + chartView.axisX().labelFormat = "%.0f"; + } + lineSeries.append(speedsXml.get(currentIndex).speedTrap, speedsXml.get(currentIndex).speed); + + if (speedsXml.get(currentIndex).speedTrap > 3) { + chartView.axisX().max = Number(speedsXml.get(currentIndex).speedTrap) + 1; + chartView.axisX().min = chartView.axisX().max - 5; + } else { + chartView.axisX().max = 5; + chartView.axisX().min = 0; + } + chartView.axisX().tickCount = chartView.axisX().max - chartView.axisX().min + 1; + } else { + // No more data, change x-axis range to show all the data + timer.stop(); + chartView.animationOptions = ChartView.AllAnimations; + chartView.axisX().min = 0; + chartView.axisX().max = speedsXml.get(currentIndex - 1).speedTrap; + } + } + } + //![3] +} diff --git a/examples/charts/qmlf1legends/qmlf1legends.pro b/examples/charts/qmlf1legends/qmlf1legends.pro new file mode 100644 index 00000000..fc8c04f4 --- /dev/null +++ b/examples/charts/qmlf1legends/qmlf1legends.pro @@ -0,0 +1,7 @@ +!include( ../examples.pri ) { + error( "Couldn't find the examples.pri file!" ) +} + +RESOURCES += resources.qrc +SOURCES += main.cpp +OTHER_FILES += qml/qmlf1legends/* diff --git a/examples/charts/qmlf1legends/resources.qrc b/examples/charts/qmlf1legends/resources.qrc new file mode 100644 index 00000000..2a89c915 --- /dev/null +++ b/examples/charts/qmlf1legends/resources.qrc @@ -0,0 +1,6 @@ + + + qml/qmlf1legends/main.qml + qml/qmlf1legends/SpeedsXml.qml + + diff --git a/examples/charts/qmloscilloscope/datasource.cpp b/examples/charts/qmloscilloscope/datasource.cpp new file mode 100644 index 00000000..ff651110 --- /dev/null +++ b/examples/charts/qmloscilloscope/datasource.cpp @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "datasource.h" +#include +#include +#include +#include +#include +#include + +QT_CHARTS_USE_NAMESPACE + +Q_DECLARE_METATYPE(QAbstractSeries *) +Q_DECLARE_METATYPE(QAbstractAxis *) + +DataSource::DataSource(QQuickView *appViewer, QObject *parent) : + QObject(parent), + m_appViewer(appViewer), + m_index(-1) +{ + qRegisterMetaType(); + qRegisterMetaType(); + + generateData(0, 5, 1024); +} + +void DataSource::update(QAbstractSeries *series) +{ + if (series) { + QXYSeries *xySeries = static_cast(series); + m_index++; + if (m_index > m_data.count() - 1) + m_index = 0; + + QList points = m_data.at(m_index); + // Use replace instead of clear + append, it's optimized for performance + xySeries->replace(points); + } +} + +void DataSource::generateData(int type, int rowCount, int colCount) +{ + // Remove previous data + foreach (QList row, m_data) + row.clear(); + m_data.clear(); + + // Append the new data depending on the type + for (int i(0); i < rowCount; i++) { + QList points; + for (int j(0); j < colCount; j++) { + qreal x(0); + qreal y(0); + switch (type) { + case 0: + // data with sin + random component + y = qSin(3.14159265358979 / 50 * j) + 0.5 + (qreal) rand() / (qreal) RAND_MAX; + x = j; + break; + case 1: + // linear data + x = j; + y = (qreal) i / 10; + break; + default: + // unknown, do nothing + break; + } + points.append(QPointF(x, y)); + } + m_data.append(points); + } +} diff --git a/examples/charts/qmloscilloscope/datasource.h b/examples/charts/qmloscilloscope/datasource.h new file mode 100644 index 00000000..8cb8daa7 --- /dev/null +++ b/examples/charts/qmloscilloscope/datasource.h @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef DATASOURCE_H +#define DATASOURCE_H + +#include +#include + +class QQuickView; + +QT_CHARTS_USE_NAMESPACE + +class DataSource : public QObject +{ + Q_OBJECT +public: + explicit DataSource(QQuickView *appViewer, QObject *parent = 0); + +signals: + +public slots: + void generateData(int type, int rowCount, int colCount); + void update(QAbstractSeries *series); + +private: + QQuickView *m_appViewer; + QList > m_data; + int m_index; +}; + +#endif // DATASOURCE_H diff --git a/examples/charts/qmloscilloscope/main.cpp b/examples/charts/qmloscilloscope/main.cpp new file mode 100644 index 00000000..cb68260f --- /dev/null +++ b/examples/charts/qmloscilloscope/main.cpp @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include "datasource.h" + +int main(int argc, char *argv[]) +{ + // Qt Charts uses Qt Graphics View Framework for drawing, therefore QApplication must be used. + QApplication app(argc, argv); + + QQuickView viewer; + + // The following are needed to make examples run without having to install the module + // in desktop environments. +#ifdef Q_OS_WIN + QString extraImportPath(QStringLiteral("%1/../../../../%2")); +#else + QString extraImportPath(QStringLiteral("%1/../../../%2")); +#endif + viewer.engine()->addImportPath(extraImportPath.arg(QGuiApplication::applicationDirPath(), + QString::fromLatin1("qml"))); + QObject::connect(viewer.engine(), &QQmlEngine::quit, &viewer, &QWindow::close); + + viewer.setTitle(QStringLiteral("QML Oscilloscope")); + + DataSource dataSource(&viewer); + viewer.rootContext()->setContextProperty("dataSource", &dataSource); + + viewer.setSource(QUrl("qrc:/qml/qmloscilloscope/main.qml")); + viewer.setResizeMode(QQuickView::SizeRootObjectToView); + viewer.show(); + + return app.exec(); +} diff --git a/examples/charts/qmloscilloscope/qml/qmloscilloscope/ControlPanel.qml b/examples/charts/qmloscilloscope/qml/qmloscilloscope/ControlPanel.qml new file mode 100644 index 00000000..72b9b5df --- /dev/null +++ b/examples/charts/qmloscilloscope/qml/qmloscilloscope/ControlPanel.qml @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Layouts 1.0 + +ColumnLayout { + spacing: 8 + Layout.fillHeight: true + signal animationsEnabled(bool enabled) + signal seriesTypeChanged(string type) + signal refreshRateChanged(variant rate); + signal signalSourceChanged(string source, int signalCount, int sampleCount); + signal antialiasingEnabled(bool enabled) + + Text { + text: "Scope" + font.pointSize: 18 + color: "white" + } + + MultiButton { + text: "Graph: " + items: ["line", "spline", "scatter"] + currentSelection: 0 + onSelectionChanged: seriesTypeChanged(items[currentSelection]); + } + + MultiButton { + id: signalSourceButton + text: "Source: " + items: ["sin", "linear"] + currentSelection: 0 + onSelectionChanged: signalSourceChanged( + selection, + 5, + sampleCountButton.items[sampleCountButton.currentSelection]); + } + + MultiButton { + id: sampleCountButton + text: "Samples: " + items: [6, 128, 1024, 10000] + currentSelection: 2 + onSelectionChanged: signalSourceChanged( + signalSourceButton.items[signalSourceButton.currentSelection], + 5, + selection); + } + + MultiButton { + text: "Refresh rate: " + items: [1, 24, 60, 100] + currentSelection: 2 + onSelectionChanged: refreshRateChanged(items[currentSelection]); + } + + MultiButton { + text: "Animations: " + items: ["OFF", "ON"] + currentSelection: 0 + onSelectionChanged: animationsEnabled(currentSelection == 1); + } + + MultiButton { + text: "Antialias: " + items: ["OFF", "ON"] + currentSelection: 0 + onSelectionChanged: antialiasingEnabled(currentSelection == 1); + } +} diff --git a/examples/charts/qmloscilloscope/qml/qmloscilloscope/MultiButton.qml b/examples/charts/qmloscilloscope/qml/qmloscilloscope/MultiButton.qml new file mode 100644 index 00000000..8f6e1e1e --- /dev/null +++ b/examples/charts/qmloscilloscope/qml/qmloscilloscope/MultiButton.qml @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Controls 1.0 +import QtQuick.Controls.Styles 1.0 + +Item { + id: button + + property string text: "Option: " + property variant items: ["first"] + property int currentSelection: 0 + signal selectionChanged(variant selection) + + signal clicked + + implicitWidth: buttonText.implicitWidth + 5 + implicitHeight: buttonText.implicitHeight + 10 + + Button { + id: buttonText + width: parent.width + height: parent.height + + style: ButtonStyle { + label: Component { + Text { + text: button.text + button.items[currentSelection] + clip: true + wrapMode: Text.WordWrap + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter + anchors.fill: parent + } + } + } + onClicked: { + currentSelection = (currentSelection + 1) % items.length; + selectionChanged(button.items[currentSelection]); + } + } +} diff --git a/examples/charts/qmloscilloscope/qml/qmloscilloscope/ScopeView.qml b/examples/charts/qmloscilloscope/qml/qmloscilloscope/ScopeView.qml new file mode 100644 index 00000000..d27bf0aa --- /dev/null +++ b/examples/charts/qmloscilloscope/qml/qmloscilloscope/ScopeView.qml @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtCharts 2.0 + +//![1] +ChartView { + id: chartView + animationOptions: ChartView.NoAnimation + theme: ChartView.ChartThemeDark + + ValueAxis { + id: axisY1 + min: -1 + max: 4 + } + + ValueAxis { + id: axisY2 + min: -10 + max: 5 + } + + ValueAxis { + id: axisX + min: 0 + max: 1000 + } + + LineSeries { + id: lineSeries1 + name: "signal 1" + axisX: axisX + axisY: axisY1 + } + LineSeries { + id: lineSeries2 + name: "signal 2" + axisX: axisX + axisYRight: axisY2 + } +//![1] + + //![2] + Timer { + id: refreshTimer + interval: 1 / 60 * 1000 // 60 Hz + running: true + repeat: true + onTriggered: { + dataSource.update(chartView.series(0)); + dataSource.update(chartView.series(1)); + } + } + //![2] + + //![3] + function changeSeriesType(type) { + chartView.removeAllSeries(); + + // Create two new series of the correct type. Axis x is the same for both of the series, + // but the series have their own y-axes to make it possible to control the y-offset + // of the "signal sources". + if (type == "line") { + chartView.createSeries(ChartView.SeriesTypeLine, "signal 1", axisX, axisY1); + chartView.createSeries(ChartView.SeriesTypeLine, "signal 2", axisX, axisY2); + } else if (type == "spline") { + chartView.createSeries(ChartView.SeriesTypeSpline, "signal 1", axisX, axisY1); + chartView.createSeries(ChartView.SeriesTypeSpline, "signal 2", axisX, axisY2); + } else { + var series1 = chartView.createSeries(ChartView.SeriesTypeScatter, "signal 1", axisX, axisY1); + series1.markerSize = 3; + series1.borderColor = "transparent"; + var series2 = chartView.createSeries(ChartView.SeriesTypeScatter, "signal 2", axisX, axisY2); + series2.markerSize = 3; + series2.borderColor = "transparent"; + } + } + + function createAxis(min, max) { + // The following creates a ValueAxis object that can be then set as a x or y axis for a series + return Qt.createQmlObject("import QtQuick 2.0; import QtCharts 2.0; ValueAxis { min: " + + min + "; max: " + max + " }", chartView); + } + //![3] + + function setAnimations(enabled) { + if (enabled) + chartView.animationOptions = ChartView.SeriesAnimations; + else + chartView.animationOptions = ChartView.NoAnimation; + } + + function changeRefreshRate(rate) { + refreshTimer.interval = 1 / Number(rate) * 1000; + } +} diff --git a/examples/charts/qmloscilloscope/qml/qmloscilloscope/main.qml b/examples/charts/qmloscilloscope/qml/qmloscilloscope/main.qml new file mode 100644 index 00000000..c88dfab3 --- /dev/null +++ b/examples/charts/qmloscilloscope/qml/qmloscilloscope/main.qml @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +//![1] +Rectangle { + id: main + width: 400 + height: 300 + color: "#404040" + + ControlPanel { + id: controlPanel + anchors.top: parent.top + anchors.topMargin: 10 + anchors.bottom: parent.bottom + anchors.left: parent.left + anchors.leftMargin: 10 +//![1] + + onSignalSourceChanged: { + if (source == "sin") + dataSource.generateData(0, signalCount, sampleCount); + else + dataSource.generateData(1, signalCount, sampleCount); + } + onAnimationsEnabled: scopeView.setAnimations(enabled); + onSeriesTypeChanged: scopeView.changeSeriesType(type); + onRefreshRateChanged: scopeView.changeRefreshRate(rate); + onAntialiasingEnabled: scopeView.antialiasing = enabled; + } + +//![2] + ScopeView { + id: scopeView + anchors.top: parent.top + anchors.bottom: parent.bottom + anchors.right: parent.right + anchors.left: controlPanel.right + height: main.height + } +//![2] +} diff --git a/examples/charts/qmloscilloscope/qmloscilloscope.pro b/examples/charts/qmloscilloscope/qmloscilloscope.pro new file mode 100644 index 00000000..a66fabcd --- /dev/null +++ b/examples/charts/qmloscilloscope/qmloscilloscope.pro @@ -0,0 +1,11 @@ +!include( ../examples.pri ) { + error( "Couldn't find the examples.pri file!" ) +} + +RESOURCES += resources.qrc +SOURCES += main.cpp \ + datasource.cpp +OTHER_FILES += qml/qmloscilloscope/* + +HEADERS += \ + datasource.h diff --git a/examples/charts/qmloscilloscope/resources.qrc b/examples/charts/qmloscilloscope/resources.qrc new file mode 100644 index 00000000..e2aadae8 --- /dev/null +++ b/examples/charts/qmloscilloscope/resources.qrc @@ -0,0 +1,8 @@ + + + qml/qmloscilloscope/main.qml + qml/qmloscilloscope/ControlPanel.qml + qml/qmloscilloscope/ScopeView.qml + qml/qmloscilloscope/MultiButton.qml + + diff --git a/examples/charts/qmlpiechart/main.cpp b/examples/charts/qmlpiechart/main.cpp new file mode 100644 index 00000000..5162b540 --- /dev/null +++ b/examples/charts/qmlpiechart/main.cpp @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include + +int main(int argc, char *argv[]) +{ + // Qt Charts uses Qt Graphics View Framework for drawing, therefore QApplication must be used. + QApplication app(argc, argv); + + QQuickView viewer; + // The following are needed to make examples run without having to install the module + // in desktop environments. +#ifdef Q_OS_WIN + QString extraImportPath(QStringLiteral("%1/../../../../%2")); +#else + QString extraImportPath(QStringLiteral("%1/../../../%2")); +#endif + viewer.engine()->addImportPath(extraImportPath.arg(QGuiApplication::applicationDirPath(), + QString::fromLatin1("qml"))); + QObject::connect(viewer.engine(), &QQmlEngine::quit, &viewer, &QWindow::close); + + viewer.setTitle(QStringLiteral("QML Pie Chart")); + viewer.setSource(QUrl("qrc:/qml/qmlpiechart/main.qml")); + viewer.setResizeMode(QQuickView::SizeRootObjectToView); + viewer.show(); + + return app.exec(); +} diff --git a/examples/charts/qmlpiechart/qml/qmlpiechart/main.qml b/examples/charts/qmlpiechart/qml/qmlpiechart/main.qml new file mode 100644 index 00000000..b836539b --- /dev/null +++ b/examples/charts/qmlpiechart/qml/qmlpiechart/main.qml @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![1] +import QtQuick 2.0 +import QtCharts 2.0 + +ChartView { + width: 400 + height: 300 + theme: ChartView.ChartThemeBrownSand + antialiasing: true + +//![1] +//![2] + PieSeries { + id: pieSeries + PieSlice { label: "eaten"; value: 94.9 } + PieSlice { label: "not yet eaten"; value: 5.1 } + } +//![2] + + Component.onCompleted: { + if (false) { + //![4] + pieSeries.append("don't care", 1.1); + //![4] + + //![5] + pieSeries.at(0).exploded = true; + //![5] + } + } + +//![3] +} +//![3] diff --git a/examples/charts/qmlpiechart/qmlpiechart.pro b/examples/charts/qmlpiechart/qmlpiechart.pro new file mode 100644 index 00000000..926f9c2d --- /dev/null +++ b/examples/charts/qmlpiechart/qmlpiechart.pro @@ -0,0 +1,7 @@ +!include( ../examples.pri ) { + error( "Couldn't find the examples.pri file!" ) +} + +RESOURCES += resources.qrc +SOURCES += main.cpp +OTHER_FILES += qml/qmlpiechart/* diff --git a/examples/charts/qmlpiechart/qmlpiechart.svg b/examples/charts/qmlpiechart/qmlpiechart.svg new file mode 100644 index 00000000..566acfad --- /dev/null +++ b/examples/charts/qmlpiechart/qmlpiechart.svg @@ -0,0 +1,93 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + diff --git a/examples/charts/qmlpiechart/resources.qrc b/examples/charts/qmlpiechart/resources.qrc new file mode 100644 index 00000000..2501bcc8 --- /dev/null +++ b/examples/charts/qmlpiechart/resources.qrc @@ -0,0 +1,5 @@ + + + qml/qmlpiechart/main.qml + + diff --git a/examples/charts/qmlpolarchart/main.cpp b/examples/charts/qmlpolarchart/main.cpp new file mode 100644 index 00000000..a850da1f --- /dev/null +++ b/examples/charts/qmlpolarchart/main.cpp @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include + +int main(int argc, char *argv[]) +{ + // Qt Charts uses Qt Graphics View Framework for drawing, therefore QApplication must be used. + QApplication app(argc, argv); + + QQuickView viewer; + // The following are needed to make examples run without having to install the module + // in desktop environments. +#ifdef Q_OS_WIN + QString extraImportPath(QStringLiteral("%1/../../../../%2")); +#else + QString extraImportPath(QStringLiteral("%1/../../../%2")); +#endif + viewer.engine()->addImportPath(extraImportPath.arg(QGuiApplication::applicationDirPath(), + QString::fromLatin1("qml"))); + QObject::connect(viewer.engine(), &QQmlEngine::quit, &viewer, &QWindow::close); + + viewer.setTitle(QStringLiteral("QML Polar Chart")); + viewer.setSource(QUrl("qrc:/qml/qmlpolarchart/main.qml")); + viewer.setResizeMode(QQuickView::SizeRootObjectToView); + viewer.show(); + + return app.exec(); +} diff --git a/examples/charts/qmlpolarchart/qml/qmlpolarchart/View1.qml b/examples/charts/qmlpolarchart/qml/qmlpolarchart/View1.qml new file mode 100644 index 00000000..b6c921fa --- /dev/null +++ b/examples/charts/qmlpolarchart/qml/qmlpolarchart/View1.qml @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtCharts 2.0 + +Rectangle { + anchors.fill: parent + //![1] + PolarChartView { + title: "Two Series, Common Axes" + anchors.fill: parent + legend.visible: false + antialiasing: true + + ValueAxis { + id: axisAngular + min: 0 + max: 20 + tickCount: 9 + } + + ValueAxis { + id: axisRadial + min: -0.5 + max: 1.5 + } + + SplineSeries { + id: series1 + axisAngular: axisAngular + axisRadial: axisRadial + pointsVisible: true + } + + ScatterSeries { + id: series2 + axisAngular: axisAngular + axisRadial: axisRadial + markerSize: 10 + } + } + + // Add data dynamically to the series + Component.onCompleted: { + for (var i = 0; i <= 20; i++) { + series1.append(i, Math.random()); + series2.append(i, Math.random()); + } + } + //![1] +} diff --git a/examples/charts/qmlpolarchart/qml/qmlpolarchart/View2.qml b/examples/charts/qmlpolarchart/qml/qmlpolarchart/View2.qml new file mode 100644 index 00000000..9df1f66b --- /dev/null +++ b/examples/charts/qmlpolarchart/qml/qmlpolarchart/View2.qml @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtCharts 2.0 + +Rectangle { + anchors.fill: parent + + //![1] + PolarChartView { + title: "Historical Area Series" + anchors.fill: parent + legend.visible: false + antialiasing: true + + DateTimeAxis { + id: axis1 + format: "yyyy MMM" + tickCount: 13 + } + ValueAxis { + id: axis2 + } + LineSeries { + id: lowerLine + axisAngular: axis1 + axisRadial: axis2 + + // Please note that month in JavaScript months are zero based, so 2 means March + XYPoint { x: toMsecsSinceEpoch(new Date(1950, 0, 1)); y: 15 } + XYPoint { x: toMsecsSinceEpoch(new Date(1962, 4, 1)); y: 35 } + XYPoint { x: toMsecsSinceEpoch(new Date(1970, 0, 1)); y: 50 } + XYPoint { x: toMsecsSinceEpoch(new Date(1978, 2, 1)); y: 75 } + XYPoint { x: toMsecsSinceEpoch(new Date(1987, 11, 1)); y: 102 } + XYPoint { x: toMsecsSinceEpoch(new Date(1992, 1, 1)); y: 132 } + XYPoint { x: toMsecsSinceEpoch(new Date(1998, 7, 1)); y: 100 } + XYPoint { x: toMsecsSinceEpoch(new Date(2002, 4, 1)); y: 120 } + XYPoint { x: toMsecsSinceEpoch(new Date(2012, 8, 1)); y: 140 } + XYPoint { x: toMsecsSinceEpoch(new Date(2013, 5, 1)); y: 150 } + } + LineSeries { + id: upperLine + axisAngular: axis1 + axisRadial: axis2 + + // Please note that month in JavaScript months are zero based, so 2 means March + XYPoint { x: toMsecsSinceEpoch(new Date(1950, 0, 1)); y: 30 } + XYPoint { x: toMsecsSinceEpoch(new Date(1962, 4, 1)); y: 55 } + XYPoint { x: toMsecsSinceEpoch(new Date(1970, 0, 1)); y: 80 } + XYPoint { x: toMsecsSinceEpoch(new Date(1978, 2, 1)); y: 105 } + XYPoint { x: toMsecsSinceEpoch(new Date(1987, 11, 1)); y: 125 } + XYPoint { x: toMsecsSinceEpoch(new Date(1992, 1, 1)); y: 160 } + XYPoint { x: toMsecsSinceEpoch(new Date(1998, 7, 1)); y: 140 } + XYPoint { x: toMsecsSinceEpoch(new Date(2002, 4, 1)); y: 140 } + XYPoint { x: toMsecsSinceEpoch(new Date(2012, 8, 1)); y: 170 } + XYPoint { x: toMsecsSinceEpoch(new Date(2013, 5, 1)); y: 200 } + } + AreaSeries { + axisAngular: axis1 + axisRadial: axis2 + lowerSeries: lowerLine + upperSeries: upperLine + } + } + // DateTimeAxis is based on QDateTimes so we must convert our JavaScript dates to + // milliseconds since epoch to make them match the DateTimeAxis values + function toMsecsSinceEpoch(date) { + var msecs = date.getTime(); + return msecs; + } + //![1] +} diff --git a/examples/charts/qmlpolarchart/qml/qmlpolarchart/View3.qml b/examples/charts/qmlpolarchart/qml/qmlpolarchart/View3.qml new file mode 100644 index 00000000..0a5304b4 --- /dev/null +++ b/examples/charts/qmlpolarchart/qml/qmlpolarchart/View3.qml @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtCharts 2.0 + +Rectangle { + anchors.fill: parent + + //![1] + PolarChartView { + title: "Numerical Data for Dummies" + anchors.fill: parent + legend.visible: false + antialiasing: true + + LineSeries { + axisRadial: CategoryAxis { + min: 0 + max: 30 + CategoryRange { + label: "critical" + endValue: 2 + } + CategoryRange { + label: "low" + endValue: 7 + } + CategoryRange { + label: "normal" + endValue: 12 + } + CategoryRange { + label: "high" + endValue: 18 + } + CategoryRange { + label: "extremely high" + endValue: 30 + } + } + + axisAngular: ValueAxis { + tickCount: 13 + } + + XYPoint { x: 0; y: 4.3 } + XYPoint { x: 1; y: 4.1 } + XYPoint { x: 2; y: 4.7 } + XYPoint { x: 3; y: 3.9 } + XYPoint { x: 4; y: 5.2 } + XYPoint { x: 5; y: 5.3 } + XYPoint { x: 6; y: 6.1 } + XYPoint { x: 7; y: 7.7 } + XYPoint { x: 8; y: 12.9 } + XYPoint { x: 9; y: 19.2 } + } + } + //![1] +} diff --git a/examples/charts/qmlpolarchart/qml/qmlpolarchart/main.qml b/examples/charts/qmlpolarchart/qml/qmlpolarchart/main.qml new file mode 100644 index 00000000..ce5a4ed4 --- /dev/null +++ b/examples/charts/qmlpolarchart/qml/qmlpolarchart/main.qml @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + width: 800 + height: 600 + property bool sourceLoaded: false + + ListView { + id: root + focus: true + anchors.fill: parent + snapMode: ListView.SnapOneItem + highlightRangeMode: ListView.StrictlyEnforceRange + highlightMoveDuration: 250 + orientation: ListView.Horizontal + boundsBehavior: Flickable.StopAtBounds + + onCurrentIndexChanged: { + if (infoText.opacity > 0.0) { + if (sourceLoaded) + infoText.opacity = 0.0; + else if (currentIndex != 0) + currentIndex = 0; + } + } + + model: ListModel { + ListElement {component: "View1.qml"} + ListElement {component: "View2.qml"} + ListElement {component: "View3.qml"} + } + + delegate: Loader { + width: root.width + height: root.height + + source: component + asynchronous: true + + onLoaded: sourceLoaded = true + } + } + + Rectangle { + id: infoText + anchors.centerIn: parent + width: parent.width + height: 40 + color: "black" + Text { + color: "white" + anchors.centerIn: parent + text: "You can navigate between views using swipe or arrow keys" + } + + Behavior on opacity { + NumberAnimation { duration: 400 } + } + } +} diff --git a/examples/charts/qmlpolarchart/qmlpolarchart.pro b/examples/charts/qmlpolarchart/qmlpolarchart.pro new file mode 100644 index 00000000..aa3341a5 --- /dev/null +++ b/examples/charts/qmlpolarchart/qmlpolarchart.pro @@ -0,0 +1,7 @@ +!include( ../examples.pri ) { + error( "Couldn't find the examples.pri file!" ) +} + +RESOURCES += resources.qrc +SOURCES += main.cpp +OTHER_FILES += qml/qmlpolarchart/* diff --git a/examples/charts/qmlpolarchart/resources.qrc b/examples/charts/qmlpolarchart/resources.qrc new file mode 100644 index 00000000..a4a975ed --- /dev/null +++ b/examples/charts/qmlpolarchart/resources.qrc @@ -0,0 +1,8 @@ + + + qml/qmlpolarchart/main.qml + qml/qmlpolarchart/View1.qml + qml/qmlpolarchart/View2.qml + qml/qmlpolarchart/View3.qml + + diff --git a/examples/charts/qmlweather/main.cpp b/examples/charts/qmlweather/main.cpp new file mode 100644 index 00000000..9bdd28d1 --- /dev/null +++ b/examples/charts/qmlweather/main.cpp @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include + +int main(int argc, char *argv[]) +{ + // Qt Charts uses Qt Graphics View Framework for drawing, therefore QApplication must be used. + QApplication app(argc, argv); + + QQuickView viewer; + // The following are needed to make examples run without having to install the module + // in desktop environments. +#ifdef Q_OS_WIN + QString extraImportPath(QStringLiteral("%1/../../../../%2")); +#else + QString extraImportPath(QStringLiteral("%1/../../../%2")); +#endif + viewer.engine()->addImportPath(extraImportPath.arg(QGuiApplication::applicationDirPath(), + QString::fromLatin1("qml"))); + QObject::connect(viewer.engine(), &QQmlEngine::quit, &viewer, &QWindow::close); + + QString appKey; + if (argc > 1) { + appKey = argv[1]; + qDebug() << "App key for worldweatheronline.com:" << appKey; + } else { + qWarning() << "No app key for worldweatheronline.com given. Using static test data instead of live data."; + } + viewer.setTitle(QStringLiteral("QML Weather")); + viewer.rootContext()->setContextProperty("weatherAppKey", appKey); + viewer.setSource(QUrl("qrc:/qml/qmlweather/main.qml")); + viewer.setResizeMode(QQuickView::SizeRootObjectToView); + viewer.show(); + + return app.exec(); +} diff --git a/examples/charts/qmlweather/qml/qmlweather/main.qml b/examples/charts/qmlweather/qml/qmlweather/main.qml new file mode 100644 index 00000000..23d3ee23 --- /dev/null +++ b/examples/charts/qmlweather/qml/qmlweather/main.qml @@ -0,0 +1,201 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtCharts 2.0 + +Rectangle { + width: 500 + height: 400 + gradient: Gradient { + GradientStop { position: 0.0; color: "lightblue" } + GradientStop { position: 1.0; color: "white" } + } + + //![1] + ChartView { + id: chartView + title: "Weather forecast" + //![1] + anchors.top: parent.top + anchors.bottom: weatherImageRow.top + anchors.left: parent.left + anchors.right: parent.right + legend.alignment: Qt.AlignTop + antialiasing: true + + //![2] + BarCategoryAxis { + id: barCategoriesAxis + titleText: "Date" + } + + ValueAxis{ + id: valueAxisY2 + min: 0 + max: 10 + titleText: "Rainfall [mm]" + } + + ValueAxis { + id: valueAxisX + // Hide the value axis; it is only used to map the line series to bar categories axis + visible: false + min: 0 + max: 5 + } + + ValueAxis{ + id: valueAxisY + min: 0 + max: 15 + titleText: "Temperature [°C]" + } + + LineSeries { + id: maxTempSeries + axisX: valueAxisX + axisY: valueAxisY + name: "Max. temperature" + } + + LineSeries { + id: minTempSeries + axisX: valueAxisX + axisY: valueAxisY + name: "Min. temperature" + } + + BarSeries { + id: myBarSeries + axisX: barCategoriesAxis + axisYRight: valueAxisY2 + BarSet { + id: rainfallSet + label: "Rainfall" + } + } + //![2] + } + + // A timer to refresh the forecast every 5 minutes + Timer { + interval: 300000 + repeat: true + triggeredOnStart: true + running: true + onTriggered: { + if (weatherAppKey != "") { + //![3] + // Make HTTP GET request and parse the result + var xhr = new XMLHttpRequest; + xhr.open("GET", + "http://free.worldweatheronline.com/feed/weather.ashx?q=Jyv%c3%a4skyl%c3%a4,Finland&format=json&num_of_days=5&key=" + + weatherAppKey); + xhr.onreadystatechange = function() { + if (xhr.readyState == XMLHttpRequest.DONE) { + var a = JSON.parse(xhr.responseText); + parseWeatherData(a); + } + } + xhr.send(); + //![3] + } else { + // No app key for worldweatheronline.com given by the user -> use dummy static data + var responseText = "{ \"data\": { \"current_condition\": [ {\"cloudcover\": \"10\", \"humidity\": \"61\", \"observation_time\": \"06:26 AM\", \"precipMM\": \"0.0\", \"pressure\": \"1022\", \"temp_C\": \"6\", \"temp_F\": \"43\", \"visibility\": \"10\", \"weatherCode\": \"113\", \"weatherDesc\": [ {\"value\": \"Sunny\" } ], \"weatherIconUrl\": [ {\"value\": \"http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0001_sunny.png\" } ], \"winddir16Point\": \"SE\", \"winddirDegree\": \"140\", \"windspeedKmph\": \"7\", \"windspeedMiles\": \"4\" } ], \"request\": [ {\"query\": \"Jyvaskyla, Finland\", \"type\": \"City\" } ], \"weather\": [ {\"date\": \"2012-05-09\", \"precipMM\": \"0.4\", \"tempMaxC\": \"14\", \"tempMaxF\": \"57\", \"tempMinC\": \"7\", \"tempMinF\": \"45\", \"weatherCode\": \"116\", \"weatherDesc\": [ {\"value\": \"Partly Cloudy\" } ], \"weatherIconUrl\": [ {\"value\": \"http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0002_sunny_intervals.png\" } ], \"winddir16Point\": \"S\", \"winddirDegree\": \"179\", \"winddirection\": \"S\", \"windspeedKmph\": \"20\", \"windspeedMiles\": \"12\" }, {\"date\": \"2012-05-10\", \"precipMM\": \"2.4\", \"tempMaxC\": \"13\", \"tempMaxF\": \"55\", \"tempMinC\": \"8\", \"tempMinF\": \"46\", \"weatherCode\": \"266\", \"weatherDesc\": [ {\"value\": \"Light drizzle\" } ], \"weatherIconUrl\": [ {\"value\": \"http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0017_cloudy_with_light_rain.png\" } ], \"winddir16Point\": \"SW\", \"winddirDegree\": \"219\", \"winddirection\": \"SW\", \"windspeedKmph\": \"21\", \"windspeedMiles\": \"13\" }, {\"date\": \"2012-05-11\", \"precipMM\": \"11.1\", \"tempMaxC\": \"15\", \"tempMaxF\": \"59\", \"tempMinC\": \"7\", \"tempMinF\": \"44\", \"weatherCode\": \"266\", \"weatherDesc\": [ {\"value\": \"Light drizzle\" } ], \"weatherIconUrl\": [ {\"value\": \"http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0017_cloudy_with_light_rain.png\" } ], \"winddir16Point\": \"SSW\", \"winddirDegree\": \"200\", \"winddirection\": \"SSW\", \"windspeedKmph\": \"20\", \"windspeedMiles\": \"12\" }, {\"date\": \"2012-05-12\", \"precipMM\": \"2.8\", \"tempMaxC\": \"7\", \"tempMaxF\": \"44\", \"tempMinC\": \"2\", \"tempMinF\": \"35\", \"weatherCode\": \"317\", \"weatherDesc\": [ {\"value\": \"Light sleet\" } ], \"weatherIconUrl\": [ {\"value\": \"http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0021_cloudy_with_sleet.png\" } ], \"winddir16Point\": \"NW\", \"winddirDegree\": \"311\", \"winddirection\": \"NW\", \"windspeedKmph\": \"24\", \"windspeedMiles\": \"15\" }, {\"date\": \"2012-05-13\", \"precipMM\": \"0.4\", \"tempMaxC\": \"6\", \"tempMaxF\": \"42\", \"tempMinC\": \"2\", \"tempMinF\": \"35\", \"weatherCode\": \"116\", \"weatherDesc\": [ {\"value\": \"Partly Cloudy\" } ], \"weatherIconUrl\": [ {\"value\": \"http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0002_sunny_intervals.png\" } ], \"winddir16Point\": \"WNW\", \"winddirDegree\": \"281\", \"winddirection\": \"WNW\", \"windspeedKmph\": \"21\", \"windspeedMiles\": \"13\" } ] }}"; + var a = JSON.parse(responseText); + parseWeatherData(a); + } + } + } + + Row { + id: weatherImageRow + anchors.bottom: poweredByText.top + anchors.bottomMargin: 10 + anchors.left: parent.left + anchors.leftMargin: 25 + anchors.right: parent.right + anchors.rightMargin: 25 + + ListModel { + id: weatherImageModel + } + + Repeater { + id: repeater + model: weatherImageModel + delegate: Image { + source: imageSource + width: weatherImageRow.width / weatherImageModel.count + height: width + fillMode: Image.PreserveAspectCrop + } + } + } + + Text { + id: poweredByText + anchors.bottom: parent.bottom + anchors.bottomMargin: 10 + anchors.left: parent.left + anchors.leftMargin: 25 + text: "Powered by World Weather Online" + } + + function parseWeatherData(weatherData) { + // Clear previous values + maxTempSeries.clear(); + minTempSeries.clear(); + weatherImageModel.clear(); + + //![4] + // Loop through the parsed JSON + for (var i in weatherData.data.weather) { + var weatherObj = weatherData.data.weather[i]; + //![4] + + //![5] + // Store temperature values, rainfall and weather icon. + // The temperature values begin from 0.5 instead of 0.0 to make the start from the + // middle of the rainfall bars. This makes the temperature lines visually better + // synchronized with the rainfall bars. + maxTempSeries.append(Number(i) + 0.5, weatherObj.tempMaxC); + minTempSeries.append(Number(i) + 0.5, weatherObj.tempMinC); + rainfallSet.append(i, weatherObj.precipMM); + weatherImageModel.append({"imageSource":weatherObj.weatherIconUrl[0].value}); + //![5] + + // Update scale of the chart + valueAxisY.max = Math.max(chartView.axisY().max,weatherObj.tempMaxC); + valueAxisX.min = 0; + valueAxisX.max = Number(i) + 1; + + // Set the x-axis labels to the dates of the forecast + var xLabels = barCategoriesAxis.categories; + xLabels[Number(i)] = weatherObj.date.substring(5, 10); + barCategoriesAxis.categories = xLabels; + barCategoriesAxis.visible = true; + barCategoriesAxis.min = 0; + barCategoriesAxis.max = xLabels.length - 1; + } + } + +} diff --git a/examples/charts/qmlweather/qmlweather.pro b/examples/charts/qmlweather/qmlweather.pro new file mode 100644 index 00000000..5e0d8df4 --- /dev/null +++ b/examples/charts/qmlweather/qmlweather.pro @@ -0,0 +1,7 @@ +!include( ../examples.pri ) { + error( "Couldn't find the examples.pri file!" ) +} + +RESOURCES += resources.qrc +SOURCES += main.cpp +OTHER_FILES += qml/qmlweather/* diff --git a/examples/charts/qmlweather/resources.qrc b/examples/charts/qmlweather/resources.qrc new file mode 100644 index 00000000..7205906f --- /dev/null +++ b/examples/charts/qmlweather/resources.qrc @@ -0,0 +1,5 @@ + + + qml/qmlweather/main.qml + + diff --git a/examples/charts/scatterchart/chartview.cpp b/examples/charts/scatterchart/chartview.cpp new file mode 100644 index 00000000..345be195 --- /dev/null +++ b/examples/charts/scatterchart/chartview.cpp @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "chartview.h" +#include +#include +#include +#include +#include + +const float Pi = 3.14159f; + +ChartView::ChartView(QWidget *parent) : + QChartView(new QChart(), parent) +{ + //![1] + QScatterSeries *series0 = new QScatterSeries(); + series0->setName("scatter1"); + series0->setMarkerShape(QScatterSeries::MarkerShapeCircle); + series0->setMarkerSize(15.0); + + QScatterSeries *series1 = new QScatterSeries(); + series1->setName("scatter2"); + series1->setMarkerShape(QScatterSeries::MarkerShapeRectangle); + series1->setMarkerSize(20.0); + + QScatterSeries *series2 = new QScatterSeries(); + series2->setName("scatter3"); + series2->setMarkerShape(QScatterSeries::MarkerShapeRectangle); + series2->setMarkerSize(30.0); + //![1] + + //![2] + series0->append(0, 6); + series0->append(2, 4); + series0->append(3, 8); + series0->append(7, 4); + series0->append(10, 5); + + *series1 << QPointF(1, 1) << QPointF(3, 3) << QPointF(7, 6) << QPointF(8, 3) << QPointF(10, 2); + *series2 << QPointF(1, 5) << QPointF(4, 6) << QPointF(6, 3) << QPointF(9, 5); + //![2] + + //![3] + QPainterPath starPath; + starPath.moveTo(30, 15); + for (int i = 1; i < 5; ++i) { + starPath.lineTo(15 + 15 * qCos(0.8 * i * Pi), + 15 + 15 * qSin(0.8 * i * Pi)); + } + starPath.closeSubpath(); + + QImage star(30, 30, QImage::Format_ARGB32); + star.fill(Qt::transparent); + + QPainter painter(&star); + painter.setRenderHint(QPainter::Antialiasing); + painter.setPen(QRgb(0xf6a625)); + painter.setBrush(painter.pen().color()); + painter.drawPath(starPath); + + series2->setBrush(star); + //![3] + + //![4] + setRenderHint(QPainter::Antialiasing); + chart()->addSeries(series0); + chart()->addSeries(series1); + chart()->addSeries(series2); + + chart()->setTitle("Simple scatterchart example"); + chart()->createDefaultAxes(); + chart()->setDropShadowEnabled(false); + //![4] + + //![5] + QList markers = chart()->legend()->markers(series2); + for (int i = 0; i < markers.count(); i++) + markers.at(i)->setBrush(painter.pen().color()); + //![5] +} diff --git a/examples/charts/scatterchart/chartview.h b/examples/charts/scatterchart/chartview.h new file mode 100644 index 00000000..c2c03038 --- /dev/null +++ b/examples/charts/scatterchart/chartview.h @@ -0,0 +1,35 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef CHARTVIEW_H +#define CHARTVIEW_H + +#include + +QT_CHARTS_USE_NAMESPACE + +class ChartView : public QChartView +{ + Q_OBJECT +public: + explicit ChartView(QWidget *parent = 0); +}; + +#endif // CHARTVIEW_H diff --git a/examples/charts/scatterchart/main.cpp b/examples/charts/scatterchart/main.cpp new file mode 100644 index 00000000..e1a76ed2 --- /dev/null +++ b/examples/charts/scatterchart/main.cpp @@ -0,0 +1,40 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include "chartview.h" + +QT_CHARTS_USE_NAMESPACE + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + +//![4] + ChartView *chartView = new ChartView(); + QMainWindow window; + window.setCentralWidget(chartView); + window.resize(400, 300); + window.show(); +//![4] + + return a.exec(); +} diff --git a/examples/charts/scatterchart/scatterchart.pro b/examples/charts/scatterchart/scatterchart.pro new file mode 100644 index 00000000..8170d6f4 --- /dev/null +++ b/examples/charts/scatterchart/scatterchart.pro @@ -0,0 +1,9 @@ +!include( ../examples.pri ) { + error( "Couldn't find the examples.pri file!" ) +} +TARGET = scatterchart +SOURCES += main.cpp \ + chartview.cpp + +HEADERS += \ + chartview.h diff --git a/examples/charts/scatterinteractions/chartview.cpp b/examples/charts/scatterinteractions/chartview.cpp new file mode 100644 index 00000000..7e55c4e0 --- /dev/null +++ b/examples/charts/scatterinteractions/chartview.cpp @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "chartview.h" +#include +#include + +QT_CHARTS_USE_NAMESPACE + +ChartView::ChartView(QWidget *parent) + : QChartView(new QChart(), parent), + m_scatter(0), + m_scatter2(0) +{ + setRenderHint(QPainter::Antialiasing); + + chart()->setTitle("Click to interact with scatter points"); + + m_scatter = new QScatterSeries(); + m_scatter->setName("scatter1"); + for (qreal x(0.5); x <= 4.0; x += 0.5) { + for (qreal y(0.5); y <= 4.0; y += 0.5) { + *m_scatter << QPointF(x, y); + } + } + m_scatter2 = new QScatterSeries(); + m_scatter2->setName("scatter2"); + + chart()->addSeries(m_scatter2); + chart()->addSeries(m_scatter); + chart()->createDefaultAxes(); + chart()->axisX()->setRange(0, 4.5); + chart()->axisY()->setRange(0, 4.5); + + connect(m_scatter, SIGNAL(clicked(QPointF)), this, SLOT(handleClickedPoint(QPointF))); +} + +ChartView::~ChartView() +{ +} + +void ChartView::handleClickedPoint(const QPointF &point) +{ + QPointF clickedPoint = point; + // Find the closest point from series 1 + QPointF closest(INT_MAX, INT_MAX); + qreal distance(INT_MAX); + foreach (QPointF currentPoint, m_scatter->points()) { + qreal currentDistance = qSqrt((currentPoint.x() - clickedPoint.x()) + * (currentPoint.x() - clickedPoint.x()) + + (currentPoint.y() - clickedPoint.y()) + * (currentPoint.y() - clickedPoint.y())); + if (currentDistance < distance) { + distance = currentDistance; + closest = currentPoint; + } + } + + // Remove the closes point from series 1 and append it to series 2 + m_scatter->remove(closest); + m_scatter2->append(closest); +} diff --git a/examples/charts/scatterinteractions/chartview.h b/examples/charts/scatterinteractions/chartview.h new file mode 100644 index 00000000..da280051 --- /dev/null +++ b/examples/charts/scatterinteractions/chartview.h @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef CHARTVIEW_H +#define CHARTVIEW_H + +#include +#include +#include + +QT_CHARTS_USE_NAMESPACE + +class ChartView : public QChartView +{ + Q_OBJECT + +public: + ChartView(QWidget *parent = 0); + ~ChartView(); + +private Q_SLOTS: + void handleClickedPoint(const QPointF &point); + +private: + QScatterSeries *m_scatter; + QScatterSeries *m_scatter2; +}; + +#endif // CHARTVIEW_H diff --git a/examples/charts/scatterinteractions/main.cpp b/examples/charts/scatterinteractions/main.cpp new file mode 100644 index 00000000..fb5dd8fc --- /dev/null +++ b/examples/charts/scatterinteractions/main.cpp @@ -0,0 +1,35 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include "chartview.h" + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + QMainWindow window; + ChartView chartView(&window); + window.setCentralWidget(&chartView); + window.resize(400, 300); + window.show(); + + return a.exec(); +} diff --git a/examples/charts/scatterinteractions/scatterinteractions.pro b/examples/charts/scatterinteractions/scatterinteractions.pro new file mode 100644 index 00000000..596fe020 --- /dev/null +++ b/examples/charts/scatterinteractions/scatterinteractions.pro @@ -0,0 +1,9 @@ +!include( ../examples.pri ) { + error( "Couldn't find the examples.pri file!" ) +} + +TARGET = scatterinteractions +SOURCES += main.cpp \ + chartview.cpp +HEADERS += \ + chartview.h diff --git a/examples/charts/splinechart/main.cpp b/examples/charts/splinechart/main.cpp new file mode 100644 index 00000000..e6a40dd0 --- /dev/null +++ b/examples/charts/splinechart/main.cpp @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include + +QT_CHARTS_USE_NAMESPACE + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + + //![1] + QSplineSeries *series = new QSplineSeries(); + series->setName("spline"); + //![1] + + //![2] + series->append(0, 6); + series->append(2, 4); + series->append(3, 8); + series->append(7, 4); + series->append(10, 5); + *series << QPointF(11, 1) << QPointF(13, 3) << QPointF(17, 6) << QPointF(18, 3) << QPointF(20, 2); + //![2] + + //![3] + QChart *chart = new QChart(); + chart->legend()->hide(); + chart->addSeries(series); + chart->setTitle("Simple spline chart example"); + chart->createDefaultAxes(); + chart->axisY()->setRange(0, 10); + //![3] + + //![4] + QChartView *chartView = new QChartView(chart); + chartView->setRenderHint(QPainter::Antialiasing); + //![4] + + //![5] + QMainWindow window; + window.setCentralWidget(chartView); + window.resize(400, 300); + window.show(); + //![5] + + return a.exec(); +} diff --git a/examples/charts/splinechart/splinechart.pro b/examples/charts/splinechart/splinechart.pro new file mode 100644 index 00000000..b2624f53 --- /dev/null +++ b/examples/charts/splinechart/splinechart.pro @@ -0,0 +1,5 @@ +!include( ../examples.pri ) { + error( "Couldn't find the examples.pri file!" ) +} +TARGET = splinechart +SOURCES += main.cpp diff --git a/examples/charts/stackedbarchart/main.cpp b/examples/charts/stackedbarchart/main.cpp new file mode 100644 index 00000000..c94b18de --- /dev/null +++ b/examples/charts/stackedbarchart/main.cpp @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include + +QT_CHARTS_USE_NAMESPACE + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + +//![1] + QBarSet *set0 = new QBarSet("Jane"); + QBarSet *set1 = new QBarSet("John"); + QBarSet *set2 = new QBarSet("Axel"); + QBarSet *set3 = new QBarSet("Mary"); + QBarSet *set4 = new QBarSet("Samantha"); + + *set0 << 1 << 2 << 3 << 4 << 5 << 6; + *set1 << 5 << 0 << 0 << 4 << 0 << 7; + *set2 << 3 << 5 << 8 << 13 << 8 << 5; + *set3 << 5 << 6 << 7 << 3 << 4 << 5; + *set4 << 9 << 7 << 5 << 3 << 1 << 2; +//![1] + +//![2] + QStackedBarSeries *series = new QStackedBarSeries(); + series->append(set0); + series->append(set1); + series->append(set2); + series->append(set3); + series->append(set4); +//![2] + +//![3] + QChart *chart = new QChart(); + chart->addSeries(series); + chart->setTitle("Simple stackedbarchart example"); + chart->setAnimationOptions(QChart::SeriesAnimations); +//![3] + +//![4] + QStringList categories; + categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; + QBarCategoryAxis *axis = new QBarCategoryAxis(); + axis->append(categories); + chart->createDefaultAxes(); + chart->setAxisX(axis, series); +//![4] + +//![5] + chart->legend()->setVisible(true); + chart->legend()->setAlignment(Qt::AlignBottom); +//![5] + +//![6] + QChartView *chartView = new QChartView(chart); + chartView->setRenderHint(QPainter::Antialiasing); +//![6] + +//![7] + QMainWindow window; + window.setCentralWidget(chartView); + window.resize(420, 300); + window.show(); +//![7] + + return a.exec(); +} + diff --git a/examples/charts/stackedbarchart/stackedbarchart.pro b/examples/charts/stackedbarchart/stackedbarchart.pro new file mode 100644 index 00000000..f6a77b6a --- /dev/null +++ b/examples/charts/stackedbarchart/stackedbarchart.pro @@ -0,0 +1,5 @@ +!include( ../examples.pri ) { + error( "Couldn't find the examples.pri file!" ) +} +TARGET = stackedbarchart +SOURCES += main.cpp diff --git a/examples/charts/stackedbarchartdrilldown/drilldownchart.cpp b/examples/charts/stackedbarchartdrilldown/drilldownchart.cpp new file mode 100644 index 00000000..1acfa172 --- /dev/null +++ b/examples/charts/stackedbarchartdrilldown/drilldownchart.cpp @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "drilldownchart.h" +#include + +QT_CHARTS_USE_NAMESPACE + +DrilldownChart::DrilldownChart(QGraphicsItem *parent, Qt::WindowFlags wFlags) + : QChart(QChart::ChartTypeCartesian, parent, wFlags), + m_currentSeries(0) +{ +} + +void DrilldownChart::changeSeries(DrilldownBarSeries *series) +{ + if (m_currentSeries) { + removeSeries(m_currentSeries); + } + + m_currentSeries = series; + + // Reset axis + QBarCategoryAxis *axis = new QBarCategoryAxis(); + axis->append(m_currentSeries->categories()); + + addSeries(series); + + createDefaultAxes(); + setAxisX(axis, series); + axisY()->setTitleText("Crops"); + + setTitle(series->name()); +} + +void DrilldownChart::handleClicked(int index, QBarSet *barset) +{ + Q_UNUSED(barset) + DrilldownBarSeries *series = static_cast(sender()); + changeSeries(series->drilldownSeries(index)); +} + +#include "moc_drilldownchart.cpp" diff --git a/examples/charts/stackedbarchartdrilldown/drilldownchart.h b/examples/charts/stackedbarchartdrilldown/drilldownchart.h new file mode 100644 index 00000000..c75216f7 --- /dev/null +++ b/examples/charts/stackedbarchartdrilldown/drilldownchart.h @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef DRILLDOWNCHART_H +#define DRILLDOWNCHART_H + +#include +#include "drilldownseries.h" + +QT_CHARTS_USE_NAMESPACE + +//! [1] +class DrilldownChart : public QChart +{ + Q_OBJECT +public: + explicit DrilldownChart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0); + + void changeSeries(DrilldownBarSeries *series); + +public Q_SLOTS: + void handleClicked(int index, QBarSet *barset); + +private: + DrilldownBarSeries *m_currentSeries; +}; +//! [1] + +#endif // DRILLDOWNCHART_H diff --git a/examples/charts/stackedbarchartdrilldown/drilldownseries.cpp b/examples/charts/stackedbarchartdrilldown/drilldownseries.cpp new file mode 100644 index 00000000..87d70b5a --- /dev/null +++ b/examples/charts/stackedbarchartdrilldown/drilldownseries.cpp @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "drilldownseries.h" + +QT_CHARTS_USE_NAMESPACE + +DrilldownBarSeries::DrilldownBarSeries(QStringList categories, QObject *parent) + : QStackedBarSeries(parent) +{ + m_categories = categories; +} + +void DrilldownBarSeries::mapDrilldownSeries(int index, DrilldownBarSeries *drilldownSeries) +{ + m_DrilldownSeries[index] = drilldownSeries; +} + +DrilldownBarSeries *DrilldownBarSeries::drilldownSeries(int index) +{ + return m_DrilldownSeries[index]; +} + +QStringList DrilldownBarSeries::categories() +{ + return m_categories; +} + +#include "moc_drilldownseries.cpp" diff --git a/examples/charts/stackedbarchartdrilldown/drilldownseries.h b/examples/charts/stackedbarchartdrilldown/drilldownseries.h new file mode 100644 index 00000000..5a340839 --- /dev/null +++ b/examples/charts/stackedbarchartdrilldown/drilldownseries.h @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef DRILLDOWNSERIES_H +#define DRILLDOWNSERIES_H + +#include +#include + +QT_CHARTS_USE_NAMESPACE + +//! [1] +class DrilldownBarSeries : public QStackedBarSeries +{ + Q_OBJECT +public: + DrilldownBarSeries(QStringList categories, QObject *parent = 0); + + void mapDrilldownSeries(int index, DrilldownBarSeries *drilldownSeries); + + DrilldownBarSeries *drilldownSeries(int index); + + QStringList categories(); + +private: + QMap m_DrilldownSeries; + QStringList m_categories; +}; +//! [1] + +#endif // DRILLDOWNSERIES_H diff --git a/examples/charts/stackedbarchartdrilldown/main.cpp b/examples/charts/stackedbarchartdrilldown/main.cpp new file mode 100644 index 00000000..6a46520d --- /dev/null +++ b/examples/charts/stackedbarchartdrilldown/main.cpp @@ -0,0 +1,113 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include "drilldownseries.h" +#include "drilldownchart.h" + +QT_CHARTS_USE_NAMESPACE + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + QMainWindow window; + +//! [1] + DrilldownChart *drilldownChart = new DrilldownChart(); + drilldownChart->setTheme(QChart::ChartThemeBlueIcy); + drilldownChart->setAnimationOptions(QChart::SeriesAnimations); +//! [1] + +//! [2] + // Define categories + QStringList months; + months << "May" << "Jun" << "Jul" << "Aug" << "Sep"; + QStringList weeks; + weeks << "week 1" << "week 2" << "week 3" << "week 4"; + QStringList plants; + plants << "Habanero" << "Lemon Drop" << "Starfish" << "Aji Amarillo"; +//! [2] + +//! [3] + // Create drilldown structure + DrilldownBarSeries *seasonSeries = new DrilldownBarSeries(months, drilldownChart); + seasonSeries->setName("Crop by month - Season"); + + // Each month in season series has drilldown series for weekly data + for (int month = 0; month < months.count(); month++) { + + // Create drilldown series for every week + DrilldownBarSeries *weeklySeries = new DrilldownBarSeries(weeks, drilldownChart); + seasonSeries->mapDrilldownSeries(month, weeklySeries); + + // Drilling down from weekly data brings us back to season data. + for (int week = 0; week < weeks.count(); week++) { + weeklySeries->mapDrilldownSeries(week, seasonSeries); + weeklySeries->setName(QString("Crop by week - " + months.at(month))); + } + + // Use clicked signal to implement drilldown + QObject::connect(weeklySeries, SIGNAL(clicked(int,QBarSet*)), drilldownChart, SLOT(handleClicked(int,QBarSet*))); + } + + // Enable drilldown from season series using clicked signal + QObject::connect(seasonSeries, SIGNAL(clicked(int,QBarSet*)), drilldownChart, SLOT(handleClicked(int,QBarSet*))); +//! [3] + +//! [4] + // Fill monthly and weekly series with data + foreach (QString plant, plants) { + QBarSet *monthlyCrop = new QBarSet(plant); + for (int month = 0; month < months.count(); month++) { + QBarSet *weeklyCrop = new QBarSet(plant); + for (int week = 0; week < weeks.count(); week++) + *weeklyCrop << (qrand() % 20); + // Get the drilldown series from season series and add crop to it. + seasonSeries->drilldownSeries(month)->append(weeklyCrop); + *monthlyCrop << weeklyCrop->sum(); + } + seasonSeries->append(monthlyCrop); + } +//! [4] + +//! [5] + // Show season series in initial view + drilldownChart->changeSeries(seasonSeries); + drilldownChart->setTitle(seasonSeries->name()); +//! [5] + +//! [6] + drilldownChart->axisX()->setGridLineVisible(false); + drilldownChart->legend()->setVisible(true); + drilldownChart->legend()->setAlignment(Qt::AlignBottom); +//! [6] + + QChartView *chartView = new QChartView(drilldownChart); + window.setCentralWidget(chartView); + window.resize(480, 300); + window.show(); + + return a.exec(); +} + diff --git a/examples/charts/stackedbarchartdrilldown/stackedbarchartdrilldown.pro b/examples/charts/stackedbarchartdrilldown/stackedbarchartdrilldown.pro new file mode 100644 index 00000000..c10066f4 --- /dev/null +++ b/examples/charts/stackedbarchartdrilldown/stackedbarchartdrilldown.pro @@ -0,0 +1,6 @@ +!include( ../examples.pri ) { + error( "Couldn't find the examples.pri file!" ) +} +TARGET = stackedbarchartdrilldown +SOURCES += main.cpp drilldownseries.cpp drilldownchart.cpp +HEADERS += drilldownseries.h drilldownchart.h diff --git a/examples/charts/temperaturerecords/main.cpp b/examples/charts/temperaturerecords/main.cpp new file mode 100644 index 00000000..24caec8e --- /dev/null +++ b/examples/charts/temperaturerecords/main.cpp @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include + +QT_CHARTS_USE_NAMESPACE + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + +//![1] + QBarSet *low = new QBarSet("Min"); + QBarSet *high = new QBarSet("Max"); + + *low << -52 << -50 << -45.3 << -37.0 << -25.6 << -8.0 << -6.0 << -11.8 << -19.7 << -32.8 << -43.0 << -48.0; + *high << 11.9 << 12.8 << 18.5 << 26.5 << 32.0 << 34.8 << 38.2 << 34.8 << 29.8 << 20.4 << 15.1 << 11.8; +//![1] + +//![2] + QStackedBarSeries *series = new QStackedBarSeries(); + series->append(low); + series->append(high); +//![2] + +//![3] + QChart *chart = new QChart(); + chart->addSeries(series); + chart->setTitle("Temperature records in celcius"); + chart->setAnimationOptions(QChart::SeriesAnimations); +//![3] + +//![4] + QStringList categories; + categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun" << "Jul" << "Aug" << "Sep" << "Oct" << "Nov" << "Dec"; + + QBarCategoryAxis *axis = new QBarCategoryAxis(); + axis->append(categories); + axis->setTitleText("Month"); + chart->createDefaultAxes(); + chart->setAxisX(axis, series); + chart->axisY(series)->setRange(-52, 52); + chart->axisY(series)->setTitleText("Temperature [°C]"); +//![4] + +//![5] + chart->legend()->setVisible(true); + chart->legend()->setAlignment(Qt::AlignBottom); +//![5] + +//![6] + QChartView *chartView = new QChartView(chart); + chartView->setRenderHint(QPainter::Antialiasing); +//![6] + +//![7] + QMainWindow window; + window.setCentralWidget(chartView); + window.resize(600, 300); + window.show(); +//![7] + + return a.exec(); +} diff --git a/examples/charts/temperaturerecords/temperaturerecords.pro b/examples/charts/temperaturerecords/temperaturerecords.pro new file mode 100644 index 00000000..e2eb6be3 --- /dev/null +++ b/examples/charts/temperaturerecords/temperaturerecords.pro @@ -0,0 +1,6 @@ +!include( ../examples.pri ) { + error( "Couldn't find the examples.pri file!" ) +} + +TARGET = temperaturerecords +SOURCES += main.cpp diff --git a/examples/charts/zoomlinechart/chart.cpp b/examples/charts/zoomlinechart/chart.cpp new file mode 100644 index 00000000..890c6c03 --- /dev/null +++ b/examples/charts/zoomlinechart/chart.cpp @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "chart.h" +#include +#include +#include + +Chart::Chart(QGraphicsItem *parent, Qt::WindowFlags wFlags) + : QChart(QChart::ChartTypeCartesian, parent, wFlags) +{ + // Seems that QGraphicsView (QChartView) does not grab gestures. + // They can only be grabbed here in the QGraphicsWidget (QChart). + grabGesture(Qt::PanGesture); + grabGesture(Qt::PinchGesture); +} + +Chart::~Chart() +{ + +} + +//![1] +bool Chart::sceneEvent(QEvent *event) +{ + if (event->type() == QEvent::Gesture) + return gestureEvent(static_cast(event)); + return QChart::event(event); +} + +bool Chart::gestureEvent(QGestureEvent *event) +{ + if (QGesture *gesture = event->gesture(Qt::PanGesture)) { + QPanGesture *pan = static_cast(gesture); + QChart::scroll(-(pan->delta().x()), pan->delta().y()); + } + + if (QGesture *gesture = event->gesture(Qt::PinchGesture)) { + QPinchGesture *pinch = static_cast(gesture); + if (pinch->changeFlags() & QPinchGesture::ScaleFactorChanged) + QChart::zoom(pinch->scaleFactor()); + } + + return true; +} +//![1] diff --git a/examples/charts/zoomlinechart/chart.h b/examples/charts/zoomlinechart/chart.h new file mode 100644 index 00000000..a0ebb223 --- /dev/null +++ b/examples/charts/zoomlinechart/chart.h @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef CHART_H +#define CHART_H + +#include + +class QGestureEvent; + +QT_CHARTS_USE_NAMESPACE + +//![1] +class Chart : public QChart +//![1] +{ +public: + explicit Chart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0); + ~Chart(); + +protected: + bool sceneEvent(QEvent *event); + +private: + bool gestureEvent(QGestureEvent *event); + +private: + +}; + +#endif // CHART_H diff --git a/examples/charts/zoomlinechart/chartview.cpp b/examples/charts/zoomlinechart/chartview.cpp new file mode 100644 index 00000000..64369c62 --- /dev/null +++ b/examples/charts/zoomlinechart/chartview.cpp @@ -0,0 +1,100 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "chartview.h" +#include + +ChartView::ChartView(QChart *chart, QWidget *parent) : + QChartView(chart, parent), + m_isTouching(false) +{ + setRubberBand(QChartView::RectangleRubberBand); +} + +bool ChartView::viewportEvent(QEvent *event) +{ + if (event->type() == QEvent::TouchBegin) { + // By default touch events are converted to mouse events. So + // after this event we will get a mouse event also but we want + // to handle touch events as gestures only. So we need this safeguard + // to block mouse events that are actually generated from touch. + m_isTouching = true; + + // Turn off animations when handling gestures they + // will only slow us down. + chart()->setAnimationOptions(QChart::NoAnimation); + } + return QChartView::viewportEvent(event); +} + +void ChartView::mousePressEvent(QMouseEvent *event) +{ + if (m_isTouching) + return; + QChartView::mousePressEvent(event); +} + +void ChartView::mouseMoveEvent(QMouseEvent *event) +{ + if (m_isTouching) + return; + QChartView::mouseMoveEvent(event); +} + +void ChartView::mouseReleaseEvent(QMouseEvent *event) +{ + if (m_isTouching) + m_isTouching = false; + + // Because we disabled animations when touch event was detected + // we must put them back on. + chart()->setAnimationOptions(QChart::SeriesAnimations); + + QChartView::mouseReleaseEvent(event); +} + +//![1] +void ChartView::keyPressEvent(QKeyEvent *event) +{ + switch (event->key()) { + case Qt::Key_Plus: + chart()->zoomIn(); + break; + case Qt::Key_Minus: + chart()->zoomOut(); + break; +//![1] + case Qt::Key_Left: + chart()->scroll(-10, 0); + break; + case Qt::Key_Right: + chart()->scroll(10, 0); + break; + case Qt::Key_Up: + chart()->scroll(0, 10); + break; + case Qt::Key_Down: + chart()->scroll(0, -10); + break; + default: + QGraphicsView::keyPressEvent(event); + break; + } +} diff --git a/examples/charts/zoomlinechart/chartview.h b/examples/charts/zoomlinechart/chartview.h new file mode 100644 index 00000000..3ad7c85e --- /dev/null +++ b/examples/charts/zoomlinechart/chartview.h @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef CHARTVIEW_H +#define CHARTVIEW_H + +#include +#include + +QT_CHARTS_USE_NAMESPACE + +//![1] +class ChartView : public QChartView +//![1] +{ +public: + ChartView(QChart *chart, QWidget *parent = 0); + +//![2] +protected: + bool viewportEvent(QEvent *event); + void mousePressEvent(QMouseEvent *event); + void mouseMoveEvent(QMouseEvent *event); + void mouseReleaseEvent(QMouseEvent *event); + void keyPressEvent(QKeyEvent *event); +//![2] + +private: + bool m_isTouching; +}; + +#endif diff --git a/examples/charts/zoomlinechart/main.cpp b/examples/charts/zoomlinechart/main.cpp new file mode 100644 index 00000000..7dd5865a --- /dev/null +++ b/examples/charts/zoomlinechart/main.cpp @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "chart.h" +#include "chartview.h" +#include +#include +#include +#include +#include + +QT_CHARTS_USE_NAMESPACE + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + +//![1] + QLineSeries *series = new QLineSeries(); + for (int i = 0; i < 500; i++) { + QPointF p((qreal) i, qSin(M_PI / 50 * i) * 100); + p.ry() += qrand() % 20; + *series << p; + } +//![1] + + Chart *chart = new Chart(); + chart->addSeries(series); + chart->setTitle("Zoom in/out example"); + chart->setAnimationOptions(QChart::SeriesAnimations); + chart->legend()->hide(); + chart->createDefaultAxes(); + + ChartView *chartView = new ChartView(chart); + chartView->setRenderHint(QPainter::Antialiasing); + + QMainWindow window; + window.setCentralWidget(chartView); + window.resize(400, 300); + window.grabGesture(Qt::PanGesture); + window.grabGesture(Qt::PinchGesture); + window.show(); + + return a.exec(); +} diff --git a/examples/charts/zoomlinechart/zoomlinechart.pro b/examples/charts/zoomlinechart/zoomlinechart.pro new file mode 100644 index 00000000..c98161b2 --- /dev/null +++ b/examples/charts/zoomlinechart/zoomlinechart.pro @@ -0,0 +1,7 @@ +!include( ../examples.pri ) { + error( "Couldn't find the examples.pri file!" ) +} +TARGET = zoomlinechart +HEADERS += chart.h chartview.h + +SOURCES += main.cpp chart.cpp chartview.cpp diff --git a/examples/customchart/customchart.pro b/examples/customchart/customchart.pro deleted file mode 100644 index 5f3f7382..00000000 --- a/examples/customchart/customchart.pro +++ /dev/null @@ -1,6 +0,0 @@ -!include( ../examples.pri ) { - error( "Couldn't find the examples.pri file!" ) -} - -TARGET = customchart -SOURCES += main.cpp diff --git a/examples/customchart/main.cpp b/examples/customchart/main.cpp deleted file mode 100644 index 8cd02711..00000000 --- a/examples/customchart/main.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include - -QTCOMMERCIALCHART_USE_NAMESPACE - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - -//![1] - QLineSeries *series = new QLineSeries(); - *series << QPointF(0, 6) << QPointF(9, 4) << QPointF(15, 20) << QPointF(25, 12) << QPointF(29, 26); - QChart *chart = new QChart(); - chart->legend()->hide(); - chart->addSeries(series); -//![1] - -//![2] - // Customize series - QPen pen(QRgb(0xfdb157)); - pen.setWidth(5); - series->setPen(pen); - - // Customize chart title - QFont font; - font.setPixelSize(18); - chart->setTitleFont(font); - chart->setTitleBrush(QBrush(Qt::white)); - chart->setTitle("Customchart example"); - - // Customize chart background - QLinearGradient backgroundGradient; - backgroundGradient.setStart(QPointF(0, 0)); - backgroundGradient.setFinalStop(QPointF(0, 1)); - backgroundGradient.setColorAt(0.0, QRgb(0xd2d0d1)); - backgroundGradient.setColorAt(1.0, QRgb(0x4c4547)); - backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode); - chart->setBackgroundBrush(backgroundGradient); - - // Customize plot area background - QLinearGradient plotAreaGradient; - plotAreaGradient.setStart(QPointF(0, 1)); - plotAreaGradient.setFinalStop(QPointF(1, 0)); - plotAreaGradient.setColorAt(0.0, QRgb(0x555555)); - plotAreaGradient.setColorAt(1.0, QRgb(0x55aa55)); - plotAreaGradient.setCoordinateMode(QGradient::ObjectBoundingMode); - chart->setPlotAreaBackgroundBrush(plotAreaGradient); - chart->setPlotAreaBackgroundVisible(true); -//![2] - -//![3] - QCategoryAxis *axisX = new QCategoryAxis(); - QCategoryAxis *axisY = new QCategoryAxis(); - - // Customize axis label font - QFont labelsFont; - labelsFont.setPixelSize(12); - axisX->setLabelsFont(labelsFont); - axisY->setLabelsFont(labelsFont); - - // Customize axis colors - QPen axisPen(QRgb(0xd18952)); - axisPen.setWidth(2); - axisX->setLinePen(axisPen); - axisY->setLinePen(axisPen); - - // Customize axis label colors - QBrush axisBrush(Qt::white); - axisX->setLabelsBrush(axisBrush); - axisY->setLabelsBrush(axisBrush); - - // Customize grid lines and shades - axisX->setGridLineVisible(false); - axisY->setGridLineVisible(false); - axisY->setShadesPen(Qt::NoPen); - axisY->setShadesBrush(QBrush(QColor(0x99, 0xcc, 0xcc, 0x55))); - axisY->setShadesVisible(true); -//![3] - -//![4] - axisX->append("low", 10); - axisX->append("optimal", 20); - axisX->append("high", 30); - axisX->setRange(0, 30); - - axisY->append("slow", 10); - axisY->append("med", 20); - axisY->append("fast", 30); - axisY->setRange(0, 30); - - chart->setAxisX(axisX, series); - chart->setAxisY(axisY, series); -//![4] - -//![5] - QChartView *chartView = new QChartView(chart); - chartView->setRenderHint(QPainter::Antialiasing); -//![5] - -//![6] - QMainWindow window; - window.setCentralWidget(chartView); - window.resize(400, 300); - window.show(); -//![6] - - return a.exec(); -} diff --git a/examples/datetimeaxis/datetimeaxis.pro b/examples/datetimeaxis/datetimeaxis.pro deleted file mode 100644 index 0ec9d715..00000000 --- a/examples/datetimeaxis/datetimeaxis.pro +++ /dev/null @@ -1,8 +0,0 @@ -!include( ../examples.pri ) { - error( "Couldn't find the examples.pri file!" ) -} -TARGET = datetimeaxis -SOURCES += main.cpp - -RESOURCES += \ - sundata.qrc diff --git a/examples/datetimeaxis/main.cpp b/examples/datetimeaxis/main.cpp deleted file mode 100644 index 1427276b..00000000 --- a/examples/datetimeaxis/main.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -QTCOMMERCIALCHART_USE_NAMESPACE - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - qsrand(QTime(0, 0, 0).secsTo(QTime::currentTime())); - - //![1] - QLineSeries *series = new QLineSeries(); - //![1] - - //![2] - // data from http://www.swpc.noaa.gov/ftpdir/weekly/RecentIndices.txt - // http://www.swpc.noaa.gov/ftpdir/weekly/README - // http://www.weather.gov/disclaimer - QFile sunSpots(":sun"); - if (!sunSpots.open(QIODevice::ReadOnly | QIODevice::Text)) { - return 1; - } - - QTextStream stream(&sunSpots); - while (!stream.atEnd()) { - QString line = stream.readLine(); - if (line.startsWith("#") || line.startsWith(":")) - continue; - QStringList values = line.split(" ", QString::SkipEmptyParts); - QDateTime momentInTime; - momentInTime.setDate(QDate(values[0].toInt(), values[1].toInt() , 15)); - series->append(momentInTime.toMSecsSinceEpoch(), values[2].toDouble()); - } - sunSpots.close(); - //![2] - - //![3] - QChart *chart = new QChart(); - chart->addSeries(series); - chart->legend()->hide(); - chart->setTitle("Sunspots count (by Space Weather Prediction Center)"); - //![3] - - //![4] - QDateTimeAxis *axisX = new QDateTimeAxis; - axisX->setTickCount(10); - axisX->setFormat("MMM yyyy"); - axisX->setTitleText("Date"); - chart->addAxis(axisX, Qt::AlignBottom); - series->attachAxis(axisX); - - QValueAxis *axisY = new QValueAxis; - axisY->setLabelFormat("%i"); - axisY->setTitleText("Sunspots count"); - chart->addAxis(axisY, Qt::AlignLeft); - series->attachAxis(axisY); - //![4] - - //![5] - QChartView *chartView = new QChartView(chart); - chartView->setRenderHint(QPainter::Antialiasing); - //![5] - - //![6] - QMainWindow window; - window.setCentralWidget(chartView); - window.resize(820, 600); - window.show(); - //![6] - - return a.exec(); -} diff --git a/examples/datetimeaxis/sun_spots.txt b/examples/datetimeaxis/sun_spots.txt deleted file mode 100644 index 91ef5982..00000000 --- a/examples/datetimeaxis/sun_spots.txt +++ /dev/null @@ -1,284 +0,0 @@ -:Recent_Solar_Indices: RecentIndices.txt -:Created: 2012 Aug 06 0759 UTC -# Prepared by the U.S. Dept. of Commerce, NOAA, Space Weather Prediction Center (SWPC). -# Please send comments and suggestions to swpc.webmaster@noaa.gov -# -# Source SWO: SWPC Space Weather Operations (SWO). -# Source RI: S.I.D.C. Brussels International Sunspot Number. -# Source 10.7cm radio flux values (sfu): Penticton, B.C., Canada. -# -# Source Ap: GeoForschungsZentrum, Postdam, Germany -# Prior to January 1997, Institut fur Geophysik, Gottingen, Germany -# Source Ap for final month is NOAA/SWPC estimated Ap. -# -# Data not yet available or not calculable: -1.0 -# -# Values for most recent 6 months are considered preliminary. -# Final values from National Geophysical Data Center www.ngdc.noaa.gov -# -# Recent Solar Indices -# of Observed Monthly Mean Values -# -# -----------Sunspot Numbers--------- ----Radio Flux--- ---Geomagnetic--- -# ---Observed---- Ratio --Smoothed- Observed Smoothed Observed Smoothed -# YR MO SWO RI RI/SW SWO RI 10.7cm 10.7cm Ap Ap -#------------------------------------------------------------------------------- -1991 01 213.5 136.9 0.64 220.5 147.6 229.4 205.5 8 17.4 -1991 02 270.2 167.5 0.62 221.5 147.6 243.0 206.3 10 18.4 -1991 03 227.9 141.9 0.62 220.7 146.6 230.0 205.9 27 19.1 -1991 04 215.9 140.0 0.65 220.7 146.5 198.8 206.8 17 20.0 -1991 05 182.5 121.3 0.66 219.6 145.5 190.3 207.1 18 21.7 -1991 06 231.8 169.7 0.73 218.9 145.2 206.8 207.4 44 23.0 -1991 07 245.7 173.7 0.71 219.5 146.3 212.0 207.7 27 23.6 -1991 08 251.5 176.3 0.70 218.3 146.6 210.3 206.8 30 24.7 -1991 09 185.8 125.3 0.67 214.2 144.9 180.6 203.9 20 25.0 -1991 10 220.1 144.1 0.65 208.4 141.7 201.3 199.7 31 24.3 -1991 11 169.0 108.2 0.64 202.2 138.1 172.0 195.4 33 24.1 -1991 12 217.7 144.4 0.66 193.7 131.7 223.9 188.9 15 23.0 -1992 01 217.9 150.0 0.69 183.3 123.7 217.6 181.8 14 21.1 -1992 02 238.2 161.1 0.68 171.8 115.4 232.1 174.8 31 19.8 -1992 03 160.5 106.7 0.66 161.6 108.2 171.3 168.5 14 19.4 -1992 04 144.0 99.8 0.69 154.3 103.3 158.5 162.9 11 18.9 -1992 05 106.3 73.8 0.69 148.9 100.3 125.4 158.9 21 17.5 -1992 06 104.7 65.2 0.62 143.3 97.1 116.7 154.3 15 16.6 -1992 07 121.4 85.7 0.71 134.3 90.7 132.2 146.7 10 16.6 -1992 08 99.5 64.5 0.65 124.4 84.0 122.1 138.9 15 16.1 -1992 09 93.8 63.9 0.68 117.5 79.5 116.8 133.8 25 15.9 -1992 10 136.2 88.7 0.65 113.4 76.4 131.7 130.5 15 16.7 -1992 11 124.3 91.8 0.74 110.4 74.4 145.2 128.2 14 16.6 -1992 12 127.4 82.6 0.65 107.7 73.2 139.1 127.4 13 16.1 -1993 01 92.1 59.3 0.64 104.5 71.4 121.0 125.7 17 16.0 -1993 02 126.1 91.0 0.72 101.2 69.3 142.6 123.1 16 15.9 -1993 03 107.4 69.8 0.65 97.0 66.6 136.4 120.7 24 15.3 -1993 04 98.6 62.2 0.63 91.9 63.6 115.9 118.1 19 14.9 -1993 05 79.1 61.3 0.77 86.2 59.9 112.4 114.8 12 14.9 -1993 06 68.5 49.8 0.73 81.0 56.1 109.3 111.3 12 15.0 -1993 07 81.6 57.9 0.71 78.7 54.7 99.0 109.6 10 14.9 -1993 08 59.4 42.2 0.71 75.7 52.3 93.7 107.6 12 15.4 -1993 09 33.5 22.4 0.67 70.7 48.4 87.0 103.9 15 16.0 -1993 10 73.5 56.4 0.77 65.5 44.9 100.3 100.4 14 16.4 -1993 11 51.0 35.6 0.70 60.8 41.2 95.9 97.5 15 17.4 -1993 12 75.9 48.9 0.64 57.9 38.4 104.8 94.8 14 18.1 -1994 01 86.4 57.8 0.67 55.6 36.6 115.0 92.7 15 18.2 -1994 02 60.5 35.5 0.59 53.5 34.8 99.6 91.2 30 18.1 -1994 03 52.4 31.7 0.60 52.9 34.1 90.4 90.2 24 17.8 -1994 04 29.3 16.1 0.55 53.0 33.7 79.1 89.3 29 18.0 -1994 05 35.4 17.8 0.50 51.9 32.5 79.9 88.1 26 18.3 -1994 06 42.6 28.0 0.66 49.6 30.8 77.3 86.4 14 18.2 -1994 07 52.7 35.1 0.67 46.1 28.5 80.5 83.9 11 18.1 -1994 08 38.4 22.5 0.59 43.8 26.8 76.1 82.0 8 17.5 -1994 09 40.5 25.7 0.63 43.4 26.6 79.0 81.2 12 16.5 -1994 10 67.1 44.0 0.66 43.2 26.5 87.7 80.9 22 15.5 -1994 11 33.0 18.0 0.55 42.5 26.2 80.9 80.6 14 14.7 -1994 12 38.7 26.2 0.68 41.4 25.6 77.4 80.4 13 14.2 -1995 01 39.8 24.2 0.61 39.6 24.2 82.7 80.1 14 14.0 -1995 02 51.3 29.9 0.58 37.8 23.0 85.6 79.7 15 13.9 -1995 03 51.9 31.1 0.60 36.3 22.1 85.1 79.3 15 14.0 -1995 04 23.6 14.0 0.59 33.8 20.6 77.7 78.6 16 13.8 -1995 05 24.6 14.5 0.59 31.6 19.2 75.5 77.9 18 13.3 -1995 06 27.8 15.6 0.56 29.9 18.2 75.7 77.4 11 12.9 -1995 07 23.8 14.5 0.61 28.1 17.0 73.9 76.9 8 12.5 -1995 08 25.1 14.3 0.57 25.4 15.4 73.8 76.0 9 12.1 -1995 09 16.5 11.8 0.72 22.0 13.4 72.0 74.8 13 11.8 -1995 10 31.6 21.1 0.67 19.7 12.1 77.9 73.8 16 11.4 -1995 11 15.7 9.0 0.57 18.5 11.3 74.2 73.2 9 10.7 -1995 12 16.2 10.0 0.62 17.6 10.8 72.6 72.8 9 10.0 -1996 01 17.6 11.5 0.65 16.8 10.4 74.5 72.4 9 9.7 -1996 02 9.1 4.4 0.48 16.2 10.1 71.5 72.2 10 9.7 -1996 03 12.1 9.2 0.76 15.4 9.7 70.7 72.1 11 9.8 -1996 04 8.5 4.8 0.56 13.6 8.4 69.3 71.6 11 9.7 -1996 05 11.8 5.5 0.47 12.9 8.0 70.1 71.4 7 9.5 -1996 06 18.8 11.8 0.63 13.5 8.5 69.6 71.8 5 9.4 -1996 07 13.2 8.2 0.62 13.4 8.4 71.2 72.0 7 9.3 -1996 08 20.5 14.4 0.70 13.1 8.3 72.4 72.1 9 9.4 -1996 09 2.9 1.6 0.55 13.3 8.4 69.4 72.3 15 9.3 -1996 10 2.3 0.9 0.39 14.0 8.8 69.2 72.6 13 9.1 -1996 11 26.7 17.9 0.67 15.4 9.8 78.7 73.0 8 9.1 -1996 12 21.1 13.3 0.63 16.2 10.4 77.8 73.3 7 9.3 -1997 01 9.0 5.7 0.63 16.5 10.5 74.0 73.4 9 9.3 -1997 02 11.3 7.6 0.67 17.4 11.0 73.8 73.7 11 9.2 -1997 03 14.4 8.7 0.60 20.4 13.5 73.5 75.1 8 8.9 -1997 04 24.5 15.5 0.63 24.0 16.5 74.5 76.8 10 8.5 -1997 05 28.6 18.5 0.65 26.4 18.4 74.6 78.4 8 8.5 -1997 06 22.1 12.7 0.57 29.0 20.4 71.7 80.1 7 8.5 -1997 07 17.0 10.4 0.61 32.4 22.7 71.1 81.8 6 8.4 -1997 08 36.7 24.4 0.66 35.9 25.1 79.0 83.4 7 8.2 -1997 09 58.2 51.3 0.88 40.5 28.4 96.2 85.7 10 8.3 -1997 10 33.6 23.8 0.71 45.4 31.9 84.9 88.6 10 8.5 -1997 11 53.5 39.0 0.73 49.3 35.0 99.5 91.3 11 8.9 -1997 12 57.9 41.2 0.71 54.2 39.0 98.8 94.2 4 9.5 -1998 01 51.8 31.9 0.62 60.6 43.8 93.4 97.5 8 9.8 -1998 02 54.4 40.3 0.74 67.4 49.0 93.4 101.7 8 10.5 -1998 03 81.8 54.8 0.67 73.3 53.5 109.1 105.8 13 11.0 -1998 04 73.6 53.4 0.73 77.7 56.6 108.3 108.9 10 11.3 -1998 05 74.3 56.3 0.76 81.4 59.4 106.7 112.0 18 11.6 -1998 06 93.6 70.7 0.76 85.9 62.5 108.4 115.8 10 12.0 -1998 07 98.3 66.6 0.68 90.3 65.5 114.0 120.0 11 12.3 -1998 08 118.6 92.2 0.78 93.7 67.8 136.0 124.1 18 12.5 -1998 09 119.0 92.9 0.78 96.1 69.5 138.3 126.8 13 12.7 -1998 10 77.0 55.5 0.72 97.7 70.5 117.3 127.9 13 12.8 -1998 11 99.5 74.0 0.74 101.3 73.0 140.2 130.0 16 12.5 -1998 12 120.8 81.9 0.68 108.8 77.9 150.1 134.3 8 12.0 -1999 01 94.3 62.0 0.66 116.5 82.6 142.6 139.0 10 11.8 -1999 02 93.4 66.3 0.71 120.2 84.6 142.0 142.6 12 11.6 -1999 03 100.5 68.8 0.68 120.5 83.8 126.3 144.0 14 11.8 -1999 04 92.9 63.7 0.69 123.8 85.5 117.2 145.8 12 12.3 -1999 05 140.5 106.4 0.76 131.7 90.5 148.6 149.9 8 12.4 -1999 06 208.3 137.7 0.66 136.0 93.1 169.8 152.9 7 12.4 -1999 07 169.2 113.5 0.67 138.0 94.3 165.6 154.4 10 12.6 -1999 08 136.1 93.7 0.69 142.8 97.5 170.8 156.3 15 12.9 -1999 09 107.4 71.5 0.67 150.0 102.3 135.7 161.0 19 12.9 -1999 10 167.7 116.7 0.70 158.5 107.8 164.8 167.2 19 12.8 -1999 11 199.3 133.2 0.67 164.7 111.0 191.5 171.5 14 13.2 -1999 12 123.5 84.6 0.69 165.9 111.1 169.8 173.4 10 13.8 -2000 01 140.8 90.1 0.64 168.0 112.9 158.1 175.5 13 14.6 -2000 02 161.9 112.9 0.70 172.1 116.8 173.2 176.8 16 15.1 -2000 03 203.6 138.5 0.68 175.4 119.9 208.2 178.4 9 15.1 -2000 04 193.4 125.5 0.65 176.3 120.8 184.2 180.5 15 15.0 -2000 05 188.8 121.6 0.64 173.1 119.0 184.5 180.0 15 15.1 -2000 06 190.3 124.9 0.66 172.0 118.7 179.8 179.7 15 15.1 -2000 07 236.7 170.1 0.72 173.0 119.8 204.7 180.2 21 14.8 -2000 08 166.6 130.5 0.78 171.8 118.6 163.1 179.4 16 14.2 -2000 09 157.9 109.7 0.69 169.0 116.3 182.1 177.1 18 14.3 -2000 10 138.9 99.4 0.72 166.2 114.5 167.7 175.5 18 15.0 -2000 11 149.9 106.8 0.71 162.7 112.7 178.8 173.8 17 15.1 -2000 12 146.4 104.4 0.71 160.8 112.0 173.6 172.0 7 14.7 -2001 01 142.7 95.6 0.67 156.3 108.7 166.6 168.7 8 14.0 -2001 02 131.0 80.6 0.62 151.4 104.0 146.7 165.6 7 13.3 -2001 03 166.7 113.5 0.68 154.0 104.8 177.7 167.8 20 12.9 -2001 04 163.6 107.7 0.66 159.4 107.5 178.1 171.6 22 12.8 -2001 05 135.1 96.6 0.72 163.1 108.6 147.9 174.7 10 12.8 -2001 06 196.7 134.0 0.68 167.2 109.8 173.7 178.7 10 12.8 -2001 07 124.6 81.8 0.66 172.1 111.7 131.3 183.8 9 12.9 -2001 08 159.4 106.4 0.67 176.7 113.6 163.1 188.8 11 13.0 -2001 09 229.1 150.7 0.66 178.8 114.1 233.8 191.3 13 12.8 -2001 10 197.4 125.5 0.64 179.5 114.0 208.1 191.9 20 12.1 -2001 11 178.6 106.5 0.60 183.7 115.5 212.7 193.7 16 12.0 -2001 12 217.5 132.2 0.61 184.5 114.6 235.6 193.9 9 12.0 -2002 01 189.0 114.1 0.60 184.8 113.5 227.3 194.6 8 11.9 -2002 02 194.5 107.4 0.55 188.6 114.6 205.0 197.2 10 12.1 -2002 03 153.1 98.4 0.64 188.9 113.3 180.3 195.7 10 12.3 -2002 04 194.9 120.7 0.62 186.2 110.5 189.8 191.5 17 12.5 -2002 05 204.1 120.8 0.59 183.6 108.8 178.4 188.0 12 12.7 -2002 06 146.0 88.3 0.60 179.9 106.2 148.7 182.9 7 12.9 -2002 07 183.5 99.6 0.54 175.4 102.7 173.5 176.2 11 13.3 -2002 08 191.0 116.4 0.61 169.2 98.7 183.9 169.3 14 13.8 -2002 09 206.4 109.6 0.53 163.4 94.6 175.8 164.0 13 14.5 -2002 10 153.9 97.5 0.63 158.8 90.5 167.0 159.3 25 15.1 -2002 11 159.8 95.5 0.60 150.9 85.2 168.7 154.1 17 15.8 -2002 12 147.9 80.8 0.55 145.0 82.0 157.2 150.7 13 17.1 -2003 01 149.3 79.7 0.53 141.7 80.8 144.0 148.0 13 18.2 -2003 02 87.0 46.0 0.53 136.4 78.3 124.5 143.5 17 18.9 -2003 03 119.7 61.1 0.51 128.1 74.0 132.2 138.3 21 19.5 -2003 04 119.7 60.0 0.50 121.5 70.1 126.3 135.0 20 20.1 -2003 05 89.6 54.6 0.61 118.3 67.6 116.2 133.1 26 21.0 -2003 06 118.4 77.4 0.65 113.6 65.0 129.3 130.2 24 21.5 -2003 07 132.8 83.3 0.63 106.9 61.8 127.7 127.2 19 22.0 -2003 08 114.3 72.7 0.64 102.8 60.0 122.1 125.2 23 22.3 -2003 09 82.6 48.7 0.59 100.7 59.5 112.2 123.7 18 21.8 -2003 10 118.9 65.5 0.55 96.6 58.2 151.3 121.8 35 21.1 -2003 11 118.9 67.3 0.57 93.6 56.7 140.8 120.1 28 20.0 -2003 12 75.4 46.5 0.62 91.4 54.8 115.0 118.0 16 18.6 -2004 01 62.3 37.3 0.60 87.9 52.0 114.1 116.3 22 18.1 -2004 02 75.6 45.8 0.61 84.2 49.3 107.0 115.5 13 17.7 -2004 03 81.0 49.1 0.61 80.9 47.1 112.0 114.6 14 16.7 -2004 04 59.3 39.3 0.66 77.9 45.5 101.2 112.4 11 15.2 -2004 05 77.3 41.5 0.54 74.1 43.8 99.8 109.3 8 14.0 -2004 06 78.9 43.2 0.55 70.4 41.6 97.4 107.4 8 13.6 -2004 07 87.8 51.1 0.58 68.3 40.2 118.5 106.1 23 13.5 -2004 08 69.5 40.9 0.59 66.6 39.2 111.0 105.2 9 13.5 -2004 09 50.0 27.7 0.55 63.7 37.5 103.0 103.8 9 13.3 -2004 10 77.9 48.0 0.62 61.3 35.9 105.9 102.3 8 13.3 -2004 11 70.5 43.5 0.62 60.0 35.3 113.7 101.6 25 13.7 -2004 12 34.7 17.9 0.52 58.8 35.2 95.0 101.5 11 14.3 -2005 01 52.0 31.3 0.60 57.3 34.6 102.2 100.4 24 14.1 -2005 02 45.4 29.2 0.64 56.4 33.9 97.2 98.6 11 14.0 -2005 03 41.0 24.5 0.60 55.8 33.5 89.9 97.3 12 14.6 -2005 04 41.5 24.2 0.58 52.6 31.6 86.0 95.5 11 15.1 -2005 05 65.4 42.7 0.65 48.3 28.9 99.5 93.2 19 14.4 -2005 06 59.8 39.3 0.66 47.9 28.8 93.7 91.9 12 13.6 -2005 07 71.0 40.1 0.56 48.1 29.1 96.5 90.9 14 12.8 -2005 08 65.6 36.4 0.55 45.4 27.4 90.5 89.2 14 11.8 -2005 09 39.2 21.9 0.56 42.9 25.8 91.1 87.8 20 11.4 -2005 10 13.0 8.7 0.67 42.6 25.5 76.6 87.3 8 11.3 -2005 11 32.2 18.0 0.56 42.1 24.9 86.2 86.7 8 10.8 -2005 12 62.6 41.1 0.66 40.1 23.0 90.7 85.2 9 10.0 -2006 01 28.0 15.3 0.55 37.2 20.8 83.4 83.6 6 9.5 -2006 02 5.3 4.9 0.92 33.4 18.6 76.5 82.3 6 9.0 -2006 03 21.3 10.6 0.50 31.0 17.4 75.5 81.2 8 8.3 -2006 04 55.2 30.2 0.55 30.6 17.1 89.0 80.6 11 7.8 -2006 05 39.6 22.3 0.56 30.7 17.3 80.9 80.5 7 7.9 -2006 06 37.7 13.9 0.37 28.9 16.3 76.5 80.2 7 8.2 -2006 07 22.6 12.2 0.54 27.2 15.2 75.8 80.0 6 8.6 -2006 08 22.8 12.9 0.57 27.6 15.6 79.4 80.1 9 8.8 -2006 09 25.2 14.4 0.57 27.7 15.5 77.8 80.0 8 8.8 -2006 10 15.7 10.5 0.67 25.2 14.2 74.3 79.1 9 8.8 -2006 11 31.5 21.4 0.68 22.3 12.6 86.3 78.2 9 8.7 -2006 12 22.2 13.6 0.61 20.7 12.1 84.5 77.8 15 8.7 -2007 01 26.6 16.8 0.63 19.7 11.9 83.5 77.5 10 8.7 -2007 02 17.2 10.7 0.62 18.9 11.5 77.7 76.9 7 8.6 -2007 03 9.7 4.5 0.46 17.5 10.7 72.2 76.0 8 8.5 -2007 04 6.9 3.4 0.49 16.0 9.8 72.4 75.3 9 8.5 -2007 05 19.4 11.7 0.60 14.2 8.6 74.4 74.3 8 8.3 -2007 06 20.0 12.1 0.61 12.8 7.6 73.7 73.3 6 7.9 -2007 07 15.6 9.7 0.62 11.6 6.9 71.6 72.7 7 7.4 -2007 08 9.9 6.0 0.61 10.2 6.0 69.1 72.1 6 7.5 -2007 09 4.8 2.4 0.50 9.9 5.9 67.0 71.8 9 7.8 -2007 10 1.3 0.9 0.69 10.0 6.0 67.5 71.8 7 7.9 -2007 11 2.5 1.7 0.68 9.4 5.7 69.6 71.4 7 7.8 -2007 12 16.2 10.1 0.62 8.1 4.9 78.5 70.8 6 7.8 -2008 01 5.1 3.3 0.65 6.9 4.2 74.3 70.3 8 7.8 -2008 02 3.8 2.1 0.55 5.9 3.6 71.1 69.9 11 7.6 -2008 03 15.9 9.3 0.58 5.3 3.3 72.9 69.8 11 7.5 -2008 04 4.9 2.9 0.59 5.3 3.4 70.2 69.8 9 7.3 -2008 05 5.7 3.2 0.56 5.7 3.5 68.4 69.8 6 7.2 -2008 06 4.2 3.4 0.81 5.2 3.3 65.9 69.4 7 7.0 -2008 07 1.0 0.8 0.80 4.5 2.8 65.7 68.8 5 6.8 -2008 08 0.0 0.5 -1.00 4.4 2.7 66.3 68.6 5 6.3 -2008 09 1.5 1.1 0.73 3.7 2.3 67.1 68.4 6 5.8 -2008 10 5.2 2.9 0.56 2.9 1.8 68.3 68.2 7 5.4 -2008 11 6.8 4.1 0.60 2.7 1.7 68.6 68.3 4 5.1 -2008 12 1.3 0.8 0.62 2.7 1.7 69.2 68.5 4 4.9 -2009 01 2.8 1.3 0.46 3.0 1.8 69.8 68.7 4 4.7 -2009 02 2.5 1.4 0.56 3.1 1.9 70.0 68.8 5 4.7 -2009 03 0.7 0.7 1.00 3.4 2.0 69.2 69.0 5 4.6 -2009 04 1.2 0.8 1.00 3.7 2.2 69.7 69.3 4 4.3 -2009 05 3.9 2.9 0.74 3.8 2.3 70.5 69.7 4 4.1 -2009 06 6.6 2.9 0.39 4.4 2.7 68.6 70.2 4 4.0 -2009 07 5.0 3.2 0.70 5.8 3.6 68.2 71.0 4 3.9 -2009 08 0.3 0.0 0.00 7.7 4.8 67.4 72.1 5 3.8 -2009 09 6.6 4.3 0.64 9.9 6.2 70.5 73.3 4 3.8 -2009 10 7.0 4.8 0.66 11.3 7.1 72.3 74.1 3 4.1 -2009 11 7.7 4.1 0.55 12.4 7.6 73.6 74.5 3 4.5 -2009 12 15.7 10.8 0.68 13.6 8.3 76.8 74.9 2 4.8 -2010 01 21.3 13.2 0.62 14.8 9.3 81.1 75.5 3 5.0 -2010 02 31.0 18.8 0.60 16.7 10.6 84.7 76.5 5 5.1 -2010 03 24.7 15.4 0.62 19.1 12.3 83.3 77.5 5 5.3 -2010 04 11.2 8.0 0.71 21.4 14.0 75.9 78.3 10 5.5 -2010 05 19.9 8.7 0.44 23.8 15.5 73.8 79.0 8 5.7 -2010 06 17.9 13.6 0.75 25.2 16.4 72.6 79.7 7 5.8 -2010 07 23.1 16.1 0.70 25.9 16.7 79.9 80.1 5 6.0 -2010 08 28.2 19.6 0.70 27.3 17.4 79.7 80.7 8 6.2 -2010 09 35.6 25.2 0.71 30.6 19.6 81.1 82.4 5 6.3 -2010 10 35.0 23.5 0.67 35.9 23.2 81.6 85.3 6 6.4 -2010 11 36.1 21.5 0.60 40.5 26.5 82.5 87.7 5 6.4 -2010 12 22.0 14.4 0.66 43.8 28.8 84.3 89.6 4 6.5 -2011 01 32.1 18.8 0.59 47.2 30.9 83.7 91.2 6 6.7 -2011 02 53.2 29.6 0.55 50.6 33.4 94.5 92.7 6 6.8 -2011 03 81.0 55.8 0.69 55.2 36.9 115.3 95.8 7 7.2 -2011 04 81.7 54.4 0.67 61.5 41.8 112.6 100.4 9 7.5 -2011 05 61.4 41.5 0.68 69.0 47.6 95.9 105.6 9 7.5 -2011 06 55.5 37.0 0.67 76.5 53.2 95.8 110.9 8 7.4 -2011 07 67.0 43.8 0.66 82.5 57.2 94.2 115.4 9 7.3 -2011 08 66.1 50.6 0.77 84.9 59.0 101.7 117.9 8 7.4 -2011 09 106.4 78.0 0.73 84.6 59.5 134.5 118.4 13 7.7 -2011 10 116.8 88.0 0.75 84.6 59.9 137.2 118.4 7 8.0 -2011 11 133.1 96.7 0.73 86.3 61.1 153.1 119.5 3 8.0 -2011 12 106.3 73.0 0.69 89.2 63.4 141.2 121.6 3 8.0 -2012 01 91.3 58.3 0.64 92.0 65.5 133.1 124.4 6 8.3 -2012 02 50.1 32.9 0.66 -1.0 -1.0 106.7 -1.0 7 -1.0 -2012 03 77.9 64.3 0.82 -1.0 -1.0 115.1 -1.0 14 -1.0 -2012 04 84.4 55.2 0.65 -1.0 -1.0 113.1 -1.0 9 -1.0 -2012 05 99.5 69.0 0.69 -1.0 -1.0 121.5 -1.0 8 -1.0 -2012 06 88.6 64.5 0.73 -1.0 -1.0 120.5 -1.0 10 -1.0 -2012 07 99.6 66.5 0.67 -1.0 -1.0 135.6 -1.0 13 -1.0 diff --git a/examples/datetimeaxis/sundata.qrc b/examples/datetimeaxis/sundata.qrc deleted file mode 100644 index 318be590..00000000 --- a/examples/datetimeaxis/sundata.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - sun_spots.txt - - diff --git a/examples/donutbreakdown/donutbreakdown.pro b/examples/donutbreakdown/donutbreakdown.pro deleted file mode 100644 index fecef7b8..00000000 --- a/examples/donutbreakdown/donutbreakdown.pro +++ /dev/null @@ -1,12 +0,0 @@ -!include( ../examples.pri ) { - error( "Couldn't find the examples.pri file!" ) -} - -TARGET = donutbreakdown -SOURCES += main.cpp\ - donutbreakdownchart.cpp \ - mainslice.cpp - -HEADERS += \ - donutbreakdownchart.h \ - mainslice.h diff --git a/examples/donutbreakdown/donutbreakdownchart.cpp b/examples/donutbreakdown/donutbreakdownchart.cpp deleted file mode 100644 index 4886aa0a..00000000 --- a/examples/donutbreakdown/donutbreakdownchart.cpp +++ /dev/null @@ -1,110 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "donutbreakdownchart.h" -#include "mainslice.h" -#include -#include - -QTCOMMERCIALCHART_USE_NAMESPACE - -//![1] -DonutBreakdownChart::DonutBreakdownChart(QGraphicsItem *parent, Qt::WindowFlags wFlags) - : QChart(QChart::ChartTypeCartesian, parent, wFlags) -{ - // create the series for main center pie - m_mainSeries = new QPieSeries(); - m_mainSeries->setPieSize(0.7); - QChart::addSeries(m_mainSeries); -} -//![1] - -//![2] -void DonutBreakdownChart::addBreakdownSeries(QPieSeries *breakdownSeries, QColor color) -{ - QFont font("Arial", 8); - - // add breakdown series as a slice to center pie - MainSlice *mainSlice = new MainSlice(breakdownSeries); - mainSlice->setName(breakdownSeries->name()); - mainSlice->setValue(breakdownSeries->sum()); - m_mainSeries->append(mainSlice); - - // customize the slice - mainSlice->setBrush(color); - mainSlice->setLabelVisible(); - mainSlice->setLabelColor(Qt::white); - mainSlice->setLabelPosition(QPieSlice::LabelInsideHorizontal); - mainSlice->setLabelFont(font); - - // position and customize the breakdown series - breakdownSeries->setPieSize(0.8); - breakdownSeries->setHoleSize(0.7); - breakdownSeries->setLabelsVisible(); - foreach (QPieSlice *slice, breakdownSeries->slices()) { - color = color.lighter(115); - slice->setBrush(color); - slice->setLabelFont(font); - } - - // add the series to the chart - QChart::addSeries(breakdownSeries); - - // recalculate breakdown donut segments - recalculateAngles(); - - // update customize legend markers - updateLegendMarkers(); -} -//![2] - -//![3] -void DonutBreakdownChart::recalculateAngles() -{ - qreal angle = 0; - foreach (QPieSlice *slice, m_mainSeries->slices()) { - QPieSeries *breakdownSeries = qobject_cast(slice)->breakdownSeries(); - breakdownSeries->setPieStartAngle(angle); - angle += slice->percentage() * 360.0; // full pie is 360.0 - breakdownSeries->setPieEndAngle(angle); - } -} -//![3] - -//![4] -void DonutBreakdownChart::updateLegendMarkers() -{ - // go through all markers - foreach (QAbstractSeries *series, QChart::series()) { - foreach (QLegendMarker *marker, legend()->markers(series)) { - QPieLegendMarker *pieMarker = qobject_cast(marker); - if (series == m_mainSeries) { - // hide markers from main series - pieMarker->setVisible(false); - } else { - // modify markers from breakdown series - pieMarker->setLabel(QString("%1 %2%") - .arg(pieMarker->slice()->label()) - .arg(pieMarker->slice()->percentage() * 100, 0, 'f', 2)); - pieMarker->setFont(QFont("Arial", 8)); - } - } - } -} -//![4] diff --git a/examples/donutbreakdown/donutbreakdownchart.h b/examples/donutbreakdown/donutbreakdownchart.h deleted file mode 100644 index ecf75d80..00000000 --- a/examples/donutbreakdown/donutbreakdownchart.h +++ /dev/null @@ -1,42 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef DONUTBREAKDOWNCHART_H -#define DONUTBREAKDOWNCHART_H - -#include -#include - -QTCOMMERCIALCHART_USE_NAMESPACE - -class DonutBreakdownChart : public QChart -{ -public: - DonutBreakdownChart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0); - void addBreakdownSeries(QPieSeries *series, QColor color); - -private: - void recalculateAngles(); - void updateLegendMarkers(); - -private: - QPieSeries *m_mainSeries; -}; - -#endif // DONUTBREAKDOWNCHART_H diff --git a/examples/donutbreakdown/main.cpp b/examples/donutbreakdown/main.cpp deleted file mode 100644 index bb19f4ee..00000000 --- a/examples/donutbreakdown/main.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include "donutbreakdownchart.h" - -QTCOMMERCIALCHART_USE_NAMESPACE - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - - //![1] - // Graph is based on data of 'Total consumption of energy increased by 10 per cent in 2010' - // Statistics Finland, 13 December 2011 - // http://www.stat.fi/til/ekul/2010/ekul_2010_2011-12-13_tie_001_en.html - - QPieSeries *series1 = new QPieSeries(); - series1->setName("Fossil fuels"); - series1->append("Oil", 353295); - series1->append("Coal", 188500); - series1->append("Natural gas", 148680); - series1->append("Peat", 94545); - - QPieSeries *series2 = new QPieSeries(); - series2->setName("Renewables"); - series2->append("Wood fuels", 319663); - series2->append("Hydro power", 45875); - series2->append("Wind power", 1060); - - QPieSeries *series3 = new QPieSeries(); - series3->setName("Others"); - series3->append("Nuclear energy", 238789); - series3->append("Import energy", 37802); - series3->append("Other", 32441); - //![1] - - //![2] - DonutBreakdownChart *donutBreakdown = new DonutBreakdownChart(); - donutBreakdown->setAnimationOptions(QChart::AllAnimations); - donutBreakdown->setTitle("Total consumption of energy in Finland 2010"); - donutBreakdown->legend()->setAlignment(Qt::AlignRight); - donutBreakdown->addBreakdownSeries(series1, Qt::red); - donutBreakdown->addBreakdownSeries(series2, Qt::darkGreen); - donutBreakdown->addBreakdownSeries(series3, Qt::darkBlue); - //![2] - - //![3] - QMainWindow window; - QChartView *chartView = new QChartView(donutBreakdown); - chartView->setRenderHint(QPainter::Antialiasing); - window.setCentralWidget(chartView); - window.resize(800, 500); - window.show(); - //![3] - - return a.exec(); -} diff --git a/examples/donutbreakdown/mainslice.cpp b/examples/donutbreakdown/mainslice.cpp deleted file mode 100644 index b907df19..00000000 --- a/examples/donutbreakdown/mainslice.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "mainslice.h" - -QTCOMMERCIALCHART_USE_NAMESPACE - -//![1] -MainSlice::MainSlice(QPieSeries *breakdownSeries, QObject *parent) - : QPieSlice(parent), - m_breakdownSeries(breakdownSeries) -{ - connect(this, SIGNAL(percentageChanged()), this, SLOT(updateLabel())); -} -//![1] - -QPieSeries *MainSlice::breakdownSeries() const -{ - return m_breakdownSeries; -} - -void MainSlice::setName(QString name) -{ - m_name = name; -} - -QString MainSlice::name() const -{ - return m_name; -} - -//![2] -void MainSlice::updateLabel() -{ - this->setLabel(QString("%1 %2%").arg(m_name).arg(percentage() * 100, 0, 'f', 2)); -} -//![2] - -#include "moc_mainslice.cpp" - diff --git a/examples/donutbreakdown/mainslice.h b/examples/donutbreakdown/mainslice.h deleted file mode 100644 index 3d99e570..00000000 --- a/examples/donutbreakdown/mainslice.h +++ /dev/null @@ -1,48 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef MAINSLICE_H -#define MAINSLICE_H - -#include -#include - -QTCOMMERCIALCHART_USE_NAMESPACE - -class MainSlice : public QPieSlice -{ - Q_OBJECT -public: - MainSlice(QPieSeries *breakdownSeries, QObject *parent = 0); - - QPieSeries *breakdownSeries() const; - - void setName(QString name); - QString name() const; - -public Q_SLOTS: - void updateLabel(); - -private: - QPieSeries *m_breakdownSeries; - QString m_name; -}; - -#endif // MAINSLICE_H diff --git a/examples/donutchart/donutchart.pro b/examples/donutchart/donutchart.pro deleted file mode 100644 index 72d4ea4d..00000000 --- a/examples/donutchart/donutchart.pro +++ /dev/null @@ -1,5 +0,0 @@ -!include( ../examples.pri ) { - error( "Couldn't find the examples.pri file!" ) -} -TARGET = donutchart -SOURCES += main.cpp diff --git a/examples/donutchart/main.cpp b/examples/donutchart/main.cpp deleted file mode 100644 index b47839c8..00000000 --- a/examples/donutchart/main.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include -QTCOMMERCIALCHART_USE_NAMESPACE - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - -//![1] - QPieSeries *series = new QPieSeries(); - series->setHoleSize(0.35); - series->append("Protein 4.2%", 4.2); - QPieSlice *slice = series->append("Fat 15.6%", 15.6); - slice->setExploded(); - slice->setLabelVisible(); - series->append("Other 23.8%", 23.8); - series->append("Carbs 56.4%", 56.4); -//![1] - -//![2] - QChartView *chartView = new QChartView(); - chartView->setRenderHint(QPainter::Antialiasing); - chartView->chart()->setTitle("Donut with a lemon glaze (100g)"); - chartView->chart()->addSeries(series); - chartView->chart()->legend()->setAlignment(Qt::AlignBottom); - chartView->chart()->setTheme(QChart::ChartThemeBlueCerulean); - chartView->chart()->legend()->setFont(QFont("Arial", 7)); -//![2] - -//![3] - QMainWindow window; - window.setCentralWidget(chartView); - window.resize(400, 300); - window.show(); -//![3] - - return a.exec(); -} diff --git a/examples/examples.pri b/examples/examples.pri deleted file mode 100644 index ea89d8b8..00000000 --- a/examples/examples.pri +++ /dev/null @@ -1,33 +0,0 @@ -!include( ../config.pri ) { - error( "Couldn't find the config.pri file!" ) -} - -DESTDIR = $$CHART_BUILD_BIN_DIR -!ios { -OBJECTS_DIR = $$CHART_BUILD_DIR/examples/$$TARGET -MOC_DIR = $$CHART_BUILD_DIR/examples/$$TARGET -UI_DIR = $$CHART_BUILD_DIR/examples/$$TARGET -RCC_DIR = $$CHART_BUILD_DIR/examples/$$TARGET -} -TEMPLATE = app -QT += core gui -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -# staticlib config causes problems when building executables -staticlib: CONFIG-=staticlib - -android { - # Workaround to fix android deployment, which seems to always look for target in - # OUT_PWD instead of DESTDIR. - COPY_PARAMETERS = "$$CHART_BUILD_BIN_DIR/lib$${TARGET}.so $$OUT_PWD/lib$${TARGET}.so" - contains(QMAKE_HOST.os, Windows): COPY_PARAMETERS = $$replace(COPY_PARAMETERS, "/","\\") - QMAKE_POST_LINK += $$QMAKE_COPY $$COPY_PARAMETERS - - contains(TARGET, qml.*) { - charts_qmldir.files = $$CHART_BUILD_QML_PLUGIN_DIR/qmldir - charts_qmldir.path = /assets/imports/QtCommercial/Chart - charts_qmlplugin.files = $$CHART_BUILD_QML_PLUGIN_DIR/libqtcommercialchartqml.so - charts_qmlplugin.path = /libs/$$ANDROID_TARGET_ARCH - INSTALLS += charts_qmldir charts_qmlplugin - } -} diff --git a/examples/examples.pro b/examples/examples.pro index 9985e63b..fadcde2f 100644 --- a/examples/examples.pro +++ b/examples/examples.pro @@ -1,45 +1,2 @@ -CURRENTLY_BUILDING_COMPONENTS = "examples" -!include( ../config.pri ) { - error( "Couldn't find the config.pri file!" ) -} - TEMPLATE = subdirs -SUBDIRS += \ - areachart \ - customchart \ - linechart \ - percentbarchart \ - piechart \ - piechartdrilldown \ - scatterchart \ - scatterinteractions \ - splinechart \ - stackedbarchart \ - stackedbarchartdrilldown \ - zoomlinechart \ - modeldata \ - barchart \ - boxplotchart \ - legend \ - barmodelmapper \ - lineandbar \ - horizontalbarchart \ - horizontalstackedbarchart \ - horizontalpercentbarchart \ - donutbreakdown \ - temperaturerecords \ - donutchart \ - multiaxis \ - legendmarkers \ - logvalueaxis \ - polarchart - -!contains(QT_VERSION, ^5\\..*\\..*$)|qtHaveModule(declarative) { - SUBDIRS += qmlboxplot \ - qmlpiechart -} - -!linux-arm*: { -SUBDIRS += \ - datetimeaxis -} +SUBDIRS += charts diff --git a/examples/horizontalbarchart/horizontalbarchart.pro b/examples/horizontalbarchart/horizontalbarchart.pro deleted file mode 100644 index 61ec088e..00000000 --- a/examples/horizontalbarchart/horizontalbarchart.pro +++ /dev/null @@ -1,6 +0,0 @@ -!include( ../examples.pri ) { - error( "Couldn't find the examples.pri file!" ) -} - -TARGET = horizontalbarchart -SOURCES += main.cpp diff --git a/examples/horizontalbarchart/main.cpp b/examples/horizontalbarchart/main.cpp deleted file mode 100644 index 206f8a12..00000000 --- a/examples/horizontalbarchart/main.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -QTCOMMERCIALCHART_USE_NAMESPACE - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - -//![1] - QBarSet *set0 = new QBarSet("Jane"); - QBarSet *set1 = new QBarSet("John"); - QBarSet *set2 = new QBarSet("Axel"); - QBarSet *set3 = new QBarSet("Mary"); - QBarSet *set4 = new QBarSet("Samantha"); - - *set0 << 1 << 2 << 3 << 4 << 5 << 6; - *set1 << 5 << 0 << 0 << 4 << 0 << 7; - *set2 << 3 << 5 << 8 << 13 << 8 << 5; - *set3 << 5 << 6 << 7 << 3 << 4 << 5; - *set4 << 9 << 7 << 5 << 3 << 1 << 2; -//![1] - -//![2] - QHorizontalBarSeries *series = new QHorizontalBarSeries(); - series->append(set0); - series->append(set1); - 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->setAnimationOptions(QChart::SeriesAnimations); -//![3] - -//![4] - QStringList categories; - categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; - QBarCategoryAxis *axisY = new QBarCategoryAxis(); - axisY->append(categories); - chart->setAxisY(axisY, series); - QValueAxis *axisX = new QValueAxis(); - chart->setAxisX(axisX, series); - axisX->applyNiceNumbers(); -//![4] - -//![5] - chart->legend()->setVisible(true); - chart->legend()->setAlignment(Qt::AlignBottom); -//![5] - -//![6] - QChartView *chartView = new QChartView(chart); - chartView->setRenderHint(QPainter::Antialiasing); -//![6] - -//![7] - QMainWindow window; - window.setCentralWidget(chartView); - window.resize(420, 300); - window.show(); -//![7] - - return a.exec(); -} diff --git a/examples/horizontalpercentbarchart/horizontalpercentbarchart.pro b/examples/horizontalpercentbarchart/horizontalpercentbarchart.pro deleted file mode 100644 index d6168695..00000000 --- a/examples/horizontalpercentbarchart/horizontalpercentbarchart.pro +++ /dev/null @@ -1,6 +0,0 @@ -!include( ../examples.pri ) { - error( "Couldn't find the examples.pri file!" ) -} - -TARGET = horizontalpercentbarchart -SOURCES += main.cpp diff --git a/examples/horizontalpercentbarchart/main.cpp b/examples/horizontalpercentbarchart/main.cpp deleted file mode 100644 index 29def46e..00000000 --- a/examples/horizontalpercentbarchart/main.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include - -QTCOMMERCIALCHART_USE_NAMESPACE - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - -//![1] - QBarSet *set0 = new QBarSet("Jane"); - QBarSet *set1 = new QBarSet("John"); - QBarSet *set2 = new QBarSet("Axel"); - QBarSet *set3 = new QBarSet("Mary"); - QBarSet *set4 = new QBarSet("Samantha"); - - *set0 << 1 << 2 << 3 << 4 << 5 << 6; - *set1 << 5 << 0 << 0 << 4 << 0 << 7; - *set2 << 3 << 5 << 8 << 13 << 8 << 5; - *set3 << 5 << 6 << 7 << 3 << 4 << 5; - *set4 << 9 << 7 << 5 << 3 << 1 << 2; -//![1] - -//![2] - QHorizontalPercentBarSeries *series = new QHorizontalPercentBarSeries(); - series->append(set0); - series->append(set1); - series->append(set2); - series->append(set3); - series->append(set4); - -//![2] - -//![3] - QChart *chart = new QChart(); - chart->addSeries(series); - chart->setTitle("Simple horizontal percent barchart example"); - chart->setAnimationOptions(QChart::SeriesAnimations); -//![3] - -//![4] - QStringList categories; - categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; - QBarCategoryAxis *axis = new QBarCategoryAxis(); - axis->append(categories); - chart->createDefaultAxes(); - chart->setAxisY(axis, series); -//![4] - -//![5] - chart->legend()->setVisible(true); - chart->legend()->setAlignment(Qt::AlignBottom); -//![5] - -//![6] - QChartView *chartView = new QChartView(chart); - chartView->setRenderHint(QPainter::Antialiasing); -//![6] - -//![7] - QMainWindow window; - window.setCentralWidget(chartView); - window.resize(420, 300); - window.show(); -//![7] - - return a.exec(); -} diff --git a/examples/horizontalstackedbarchart/horizontalstackedbarchart.pro b/examples/horizontalstackedbarchart/horizontalstackedbarchart.pro deleted file mode 100644 index 5c08d212..00000000 --- a/examples/horizontalstackedbarchart/horizontalstackedbarchart.pro +++ /dev/null @@ -1,6 +0,0 @@ -!include( ../examples.pri ) { - error( "Couldn't find the examples.pri file!" ) -} - -TARGET = horizontalstackedbarchart -SOURCES += main.cpp diff --git a/examples/horizontalstackedbarchart/main.cpp b/examples/horizontalstackedbarchart/main.cpp deleted file mode 100644 index 8ce6c372..00000000 --- a/examples/horizontalstackedbarchart/main.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include - -QTCOMMERCIALCHART_USE_NAMESPACE - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - -//![1] - QBarSet *set0 = new QBarSet("Jane"); - QBarSet *set1 = new QBarSet("John"); - QBarSet *set2 = new QBarSet("Axel"); - QBarSet *set3 = new QBarSet("Mary"); - QBarSet *set4 = new QBarSet("Samantha"); - - *set0 << 1 << 2 << 3 << 4 << 5 << 6; - *set1 << 5 << 0 << 0 << 4 << 0 << 7; - *set2 << 3 << 5 << 8 << 13 << 8 << 5; - *set3 << 5 << 6 << 7 << 3 << 4 << 5; - *set4 << 9 << 7 << 5 << 3 << 1 << 2; -//![1] - -//![2] - QHorizontalStackedBarSeries *series = new QHorizontalStackedBarSeries(); - series->append(set0); - series->append(set1); - series->append(set2); - series->append(set3); - series->append(set4); - -//![2] - -//![3] - QChart *chart = new QChart(); - chart->addSeries(series); - chart->setTitle("Simple horizontal stacked barchart example"); - chart->setAnimationOptions(QChart::SeriesAnimations); -//![3] - -//![4] - QStringList categories; - categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; - QBarCategoryAxis *axis = new QBarCategoryAxis(); - axis->append(categories); - chart->createDefaultAxes(); - chart->setAxisY(axis, series); -//![4] - -//![5] - chart->legend()->setVisible(true); - chart->legend()->setAlignment(Qt::AlignBottom); -//![5] - -//![6] - QChartView *chartView = new QChartView(chart); - chartView->setRenderHint(QPainter::Antialiasing); -//![6] - -//![7] - QMainWindow window; - window.setCentralWidget(chartView); - window.resize(420, 300); - window.show(); -//![7] - - return a.exec(); -} diff --git a/examples/legend/legend.pro b/examples/legend/legend.pro deleted file mode 100644 index 5e22fb2a..00000000 --- a/examples/legend/legend.pro +++ /dev/null @@ -1,10 +0,0 @@ -!include( ../examples.pri ) { - error( "Couldn't find the examples.pri file!" ) -} - -TARGET = legend -SOURCES += main.cpp \ - mainwidget.cpp - -HEADERS += \ - mainwidget.h diff --git a/examples/legend/main.cpp b/examples/legend/main.cpp deleted file mode 100644 index 2fac3cd3..00000000 --- a/examples/legend/main.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "mainwidget.h" - -#include -#include - -QTCOMMERCIALCHART_USE_NAMESPACE - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - - MainWidget w; - w.resize(720, 480); - w.show(); - - return a.exec(); -} diff --git a/examples/legend/mainwidget.cpp b/examples/legend/mainwidget.cpp deleted file mode 100644 index 8cf3fe53..00000000 --- a/examples/legend/mainwidget.cpp +++ /dev/null @@ -1,247 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "mainwidget.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -QTCOMMERCIALCHART_USE_NAMESPACE - -MainWidget::MainWidget(QWidget *parent) : - QWidget(parent) -{ - // Create buttons for ui - m_buttonLayout = new QGridLayout(); - QPushButton *detachLegendButton = new QPushButton("Toggle attached"); - connect(detachLegendButton, SIGNAL(clicked()), this, SLOT(toggleAttached())); - m_buttonLayout->addWidget(detachLegendButton, 0, 0); - - QPushButton *addSetButton = new QPushButton("add barset"); - connect(addSetButton, SIGNAL(clicked()), this, SLOT(addBarset())); - m_buttonLayout->addWidget(addSetButton, 2, 0); - QPushButton *removeBarsetButton = new QPushButton("remove barset"); - connect(removeBarsetButton, SIGNAL(clicked()), this, SLOT(removeBarset())); - m_buttonLayout->addWidget(removeBarsetButton, 3, 0); - - QPushButton *alignButton = new QPushButton("Align (Bottom)"); - connect(alignButton, SIGNAL(clicked()), this, SLOT(setLegendAlignment())); - m_buttonLayout->addWidget(alignButton, 4, 0); - - QPushButton *boldButton = new QPushButton("Toggle bold"); - connect(boldButton, SIGNAL(clicked()), this, SLOT(toggleBold())); - m_buttonLayout->addWidget(boldButton, 8, 0); - - QPushButton *italicButton = new QPushButton("Toggle italic"); - connect(italicButton, SIGNAL(clicked()), this, SLOT(toggleItalic())); - m_buttonLayout->addWidget(italicButton, 9, 0); - - m_legendPosX = new QDoubleSpinBox(); - m_legendPosY = new QDoubleSpinBox(); - m_legendWidth = new QDoubleSpinBox(); - m_legendHeight = new QDoubleSpinBox(); - - connect(m_legendPosX, SIGNAL(valueChanged(double)), this, SLOT(updateLegendLayout())); - connect(m_legendPosY, SIGNAL(valueChanged(double)), this, SLOT(updateLegendLayout())); - connect(m_legendWidth, SIGNAL(valueChanged(double)), this, SLOT(updateLegendLayout())); - connect(m_legendHeight, SIGNAL(valueChanged(double)), this, SLOT(updateLegendLayout())); - - QFormLayout *legendLayout = new QFormLayout(); - legendLayout->addRow("HPos", m_legendPosX); - legendLayout->addRow("VPos", m_legendPosY); - legendLayout->addRow("Width", m_legendWidth); - legendLayout->addRow("Height", m_legendHeight); - m_legendSettings = new QGroupBox("Detached legend"); - m_legendSettings->setLayout(legendLayout); - m_buttonLayout->addWidget(m_legendSettings); - m_legendSettings->setVisible(false); - - // Create chart view with the chart - m_chart = new QChart(); - m_chartView = new QChartView(m_chart, this); - - // Create spinbox to modify font size - m_fontSize = new QDoubleSpinBox(); - m_fontSize->setValue(m_chart->legend()->font().pointSizeF()); - connect(m_fontSize, SIGNAL(valueChanged(double)), this, SLOT(fontSizeChanged())); - - QFormLayout *fontLayout = new QFormLayout(); - fontLayout->addRow("Legend font size", m_fontSize); - - // Create layout for grid and detached legend - m_mainLayout = new QGridLayout(); - m_mainLayout->addLayout(m_buttonLayout, 0, 0); - m_mainLayout->addLayout(fontLayout, 1, 0); - m_mainLayout->addWidget(m_chartView, 0, 1, 3, 1); - setLayout(m_mainLayout); - - createSeries(); -} - -void MainWidget::createSeries() -{ - m_series = new QBarSeries(); - addBarset(); - addBarset(); - addBarset(); - addBarset(); - - m_chart->addSeries(m_series); - m_chart->setTitle("Legend detach example"); - m_chart->createDefaultAxes(); -//![1] - m_chart->legend()->setVisible(true); - m_chart->legend()->setAlignment(Qt::AlignBottom); -//![1] - - m_chartView->setRenderHint(QPainter::Antialiasing); -} - -void MainWidget::showLegendSpinbox() -{ - m_legendSettings->setVisible(true); - QRectF chartViewRect = m_chartView->rect(); - - m_legendPosX->setMinimum(0); - m_legendPosX->setMaximum(chartViewRect.width()); - m_legendPosX->setValue(150); - - m_legendPosY->setMinimum(0); - m_legendPosY->setMaximum(chartViewRect.height()); - m_legendPosY->setValue(150); - - m_legendWidth->setMinimum(0); - m_legendWidth->setMaximum(chartViewRect.width()); - m_legendWidth->setValue(150); - - m_legendHeight->setMinimum(0); - m_legendHeight->setMaximum(chartViewRect.height()); - m_legendHeight->setValue(75); -} - -void MainWidget::hideLegendSpinbox() -{ - m_legendSettings->setVisible(false); -} - - -void MainWidget::toggleAttached() -{ - QLegend *legend = m_chart->legend(); - if (legend->isAttachedToChart()) { - //![2] - legend->detachFromChart(); - m_chart->legend()->setBackgroundVisible(true); - m_chart->legend()->setBrush(QBrush(QColor(128, 128, 128, 128))); - m_chart->legend()->setPen(QPen(QColor(192, 192, 192, 192))); - //![2] - showLegendSpinbox(); - updateLegendLayout(); - } else { - //![3] - legend->attachToChart(); - legend->setBackgroundVisible(false); - //![3] - hideLegendSpinbox(); - } - update(); -} - -void MainWidget::addBarset() -{ - QBarSet *barSet = new QBarSet(QString("set ") + QString::number(m_series->count())); - qreal delta = m_series->count() * 0.1; - *barSet << 1 + delta << 2 + delta << 3 + delta << 4 + delta; - m_series->append(barSet); -} - -void MainWidget::removeBarset() -{ - QList sets = m_series->barSets(); - if (sets.count() > 0) { - m_series->remove(sets.at(sets.count() - 1)); - } -} - -void MainWidget::setLegendAlignment() -{ - QPushButton *button = qobject_cast(sender()); - - switch (m_chart->legend()->alignment()) { - case Qt::AlignTop: - m_chart->legend()->setAlignment(Qt::AlignLeft); - if (button) - button->setText("Align (Left)"); - break; - case Qt::AlignLeft: - m_chart->legend()->setAlignment(Qt::AlignBottom); - if (button) - button->setText("Align (Bottom)"); - break; - case Qt::AlignBottom: - m_chart->legend()->setAlignment(Qt::AlignRight); - if (button) - button->setText("Align (Right)"); - break; - default: - if (button) - button->setText("Align (Top)"); - m_chart->legend()->setAlignment(Qt::AlignTop); - break; - } -} - -void MainWidget::toggleBold() -{ - QFont font = m_chart->legend()->font(); - font.setBold(!font.bold()); - m_chart->legend()->setFont(font); -} - -void MainWidget::toggleItalic() -{ - QFont font = m_chart->legend()->font(); - font.setItalic(!font.italic()); - m_chart->legend()->setFont(font); -} - -void MainWidget::fontSizeChanged() -{ - QFont font = m_chart->legend()->font(); - font.setPointSizeF(m_fontSize->value()); - m_chart->legend()->setFont(font); -} - -void MainWidget::updateLegendLayout() -{ -//![4] - m_chart->legend()->setGeometry(QRectF(m_legendPosX->value(), - m_legendPosY->value(), - m_legendWidth->value(), - m_legendHeight->value())); - m_chart->legend()->update(); -//![4] -} diff --git a/examples/legend/mainwidget.h b/examples/legend/mainwidget.h deleted file mode 100644 index 99c98e0c..00000000 --- a/examples/legend/mainwidget.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef MAINWIDGET_H -#define MAINWIDGET_H - -#include "qchartglobal.h" -#include "qchart.h" -#include "qchartview.h" -#include -#include -#include -#include -#include -#include -#include - -QTCOMMERCIALCHART_USE_NAMESPACE - -class MainWidget : public QWidget -{ - Q_OBJECT -public: - explicit MainWidget(QWidget *parent = 0); - void createSeries(); - void showLegendSpinbox(); - void hideLegendSpinbox(); - -public Q_SLOTS: - void toggleAttached(); - void addBarset(); - void removeBarset(); - - void setLegendAlignment(); - - void toggleBold(); - void toggleItalic(); - void fontSizeChanged(); - - void updateLegendLayout(); - -private: - QChart *m_chart; - QBarSeries *m_series; - - QChartView *m_chartView; - QGridLayout *m_mainLayout; - QGridLayout *m_buttonLayout; - QGridLayout *m_fontLayout; - - QDoubleSpinBox *m_fontSize; - - // For detached layout - QGroupBox *m_legendSettings; - QDoubleSpinBox *m_legendPosX; - QDoubleSpinBox *m_legendPosY; - QDoubleSpinBox *m_legendWidth; - QDoubleSpinBox *m_legendHeight; -}; - -#endif // MAINWIDGET_H diff --git a/examples/legendmarkers/legendmarkers.pro b/examples/legendmarkers/legendmarkers.pro deleted file mode 100644 index f79bdba4..00000000 --- a/examples/legendmarkers/legendmarkers.pro +++ /dev/null @@ -1,10 +0,0 @@ -!include( ../examples.pri ) { - error( "Couldn't find the examples.pri file!" ) -} - -TARGET = legendmarkers -SOURCES += main.cpp \ - mainwidget.cpp - -HEADERS += \ - mainwidget.h diff --git a/examples/legendmarkers/main.cpp b/examples/legendmarkers/main.cpp deleted file mode 100644 index f627e496..00000000 --- a/examples/legendmarkers/main.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "mainwidget.h" - -#include -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - - MainWidget w; - w.resize(720, 480); - w.show(); - - return a.exec(); -} diff --git a/examples/legendmarkers/mainwidget.cpp b/examples/legendmarkers/mainwidget.cpp deleted file mode 100644 index 2a20f882..00000000 --- a/examples/legendmarkers/mainwidget.cpp +++ /dev/null @@ -1,177 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "mainwidget.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -QTCOMMERCIALCHART_USE_NAMESPACE - -MainWidget::MainWidget(QWidget *parent) : - QWidget(parent) -{ - // Create chart view with the chart - m_chart = new QChart(); - m_chartView = new QChartView(m_chart, this); - - // Create layout for grid and detached legend - m_mainLayout = new QGridLayout(); - m_mainLayout->addWidget(m_chartView, 0, 1, 3, 1); - setLayout(m_mainLayout); - - // Add few series - addSeries(); - addSeries(); - addSeries(); - addSeries(); - - connectMarkers(); - - // Set the title and show legend - m_chart->setTitle("Legendmarker example (click on legend)"); - m_chart->legend()->setVisible(true); - m_chart->legend()->setAlignment(Qt::AlignBottom); - - m_chartView->setRenderHint(QPainter::Antialiasing); -} - -void MainWidget::addSeries() -{ - QLineSeries *series = new QLineSeries(); - m_series.append(series); - - series->setName(QString("line " + QString::number(m_series.count()))); - - // Make some sine wave for data - QList data; - int offset = m_chart->series().count(); - for (int i = 0; i < 360; i++) { - qreal x = offset * 20 + i; - data.append(QPointF(i, qSin(2.0 * 3.141592 * x / 360.0))); - } - - series->append(data); - m_chart->addSeries(series); - - if (m_series.count() == 1) { - m_chart->createDefaultAxes(); - } -} - -void MainWidget::removeSeries() -{ - // Remove last series from chart - if (m_series.count() > 0) { - QLineSeries *series = m_series.last(); - m_chart->removeSeries(series); - m_series.removeLast(); - delete series; - } -} - -void MainWidget::connectMarkers() -{ -//![1] - // Connect all markers to handler - foreach (QLegendMarker* marker, m_chart->legend()->markers()) { - // Disconnect possible existing connection to avoid multiple connections - QObject::disconnect(marker, SIGNAL(clicked()), this, SLOT(handleMarkerClicked())); - QObject::connect(marker, SIGNAL(clicked()), this, SLOT(handleMarkerClicked())); - } -//![1] -} - -void MainWidget::disconnectMarkers() -{ -//![2] - foreach (QLegendMarker* marker, m_chart->legend()->markers()) { - QObject::disconnect(marker, SIGNAL(clicked()), this, SLOT(handleMarkerClicked())); - } -//![2] -} - -void MainWidget::handleMarkerClicked() -{ -//![3] - QLegendMarker* marker = qobject_cast (sender()); - Q_ASSERT(marker); -//![3] - -//![4] - switch (marker->type()) -//![4] - { - case QLegendMarker::LegendMarkerTypeXY: - { -//![5] - // Toggle visibility of series - marker->series()->setVisible(!marker->series()->isVisible()); - - // Turn legend marker back to visible, since hiding series also hides the marker - // and we don't want it to happen now. - marker->setVisible(true); -//![5] - -//![6] - // Dim the marker, if series is not visible - qreal alpha = 1.0; - - if (!marker->series()->isVisible()) { - alpha = 0.5; - } - - QColor color; - QBrush brush = marker->labelBrush(); - color = brush.color(); - color.setAlphaF(alpha); - brush.setColor(color); - marker->setLabelBrush(brush); - - brush = marker->brush(); - color = brush.color(); - color.setAlphaF(alpha); - brush.setColor(color); - marker->setBrush(brush); - - QPen pen = marker->pen(); - color = pen.color(); - color.setAlphaF(alpha); - pen.setColor(color); - marker->setPen(pen); - -//![6] - break; - } - default: - { - qDebug() << "Unknown marker type"; - break; - } - } -} diff --git a/examples/legendmarkers/mainwidget.h b/examples/legendmarkers/mainwidget.h deleted file mode 100644 index 3c01f7b3..00000000 --- a/examples/legendmarkers/mainwidget.h +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef MAINWIDGET_H -#define MAINWIDGET_H - -#include "qchartglobal.h" -#include "qchart.h" -#include "qchartview.h" -#include -#include -#include -#include -#include -#include -#include - -QTCOMMERCIALCHART_USE_NAMESPACE - -class MainWidget : public QWidget -{ - Q_OBJECT -public: - explicit MainWidget(QWidget *parent = 0); - -public slots: - void addSeries(); - void removeSeries(); - void connectMarkers(); - void disconnectMarkers(); - - void handleMarkerClicked(); - -private: - - QChart *m_chart; - QList m_series; - - QChartView *m_chartView; - QGridLayout *m_mainLayout; - QGridLayout *m_fontLayout; - -}; - -#endif // MAINWIDGET_H diff --git a/examples/lineandbar/lineandbar.pro b/examples/lineandbar/lineandbar.pro deleted file mode 100644 index dd94abd5..00000000 --- a/examples/lineandbar/lineandbar.pro +++ /dev/null @@ -1,6 +0,0 @@ -!include( ../examples.pri ) { - error( "Couldn't find the examples.pri file!" ) -} - -TARGET = lineandbar -SOURCES += main.cpp diff --git a/examples/lineandbar/main.cpp b/examples/lineandbar/main.cpp deleted file mode 100644 index f4b46e91..00000000 --- a/examples/lineandbar/main.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -QTCOMMERCIALCHART_USE_NAMESPACE - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - -//![1] - QBarSet *set0 = new QBarSet("Jane"); - QBarSet *set1 = new QBarSet("John"); - QBarSet *set2 = new QBarSet("Axel"); - QBarSet *set3 = new QBarSet("Mary"); - QBarSet *set4 = new QBarSet("Sam"); - - *set0 << 1 << 2 << 3 << 4 << 5 << 6; - *set1 << 5 << 0 << 0 << 4 << 0 << 7; - *set2 << 3 << 5 << 8 << 13 << 8 << 5; - *set3 << 5 << 6 << 7 << 3 << 4 << 5; - *set4 << 9 << 7 << 5 << 3 << 1 << 2; -//![1] - -//![2] - QBarSeries *barseries = new QBarSeries(); - barseries->append(set0); - barseries->append(set1); - barseries->append(set2); - barseries->append(set3); - barseries->append(set4); -//![2] - -//![8] - QLineSeries *lineseries = new QLineSeries(); - lineseries->setName("trend"); - lineseries->append(QPoint(0, 4)); - lineseries->append(QPoint(1, 15)); - lineseries->append(QPoint(2, 20)); - lineseries->append(QPoint(3, 4)); - lineseries->append(QPoint(4, 12)); - lineseries->append(QPoint(5, 17)); -//![8] - -//![3] - QChart *chart = new QChart(); - chart->addSeries(barseries); - chart->addSeries(lineseries); - chart->setTitle("Line and barchart example"); -//![3] - -//![4] - QStringList categories; - categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; - QBarCategoryAxis *axisX = new QBarCategoryAxis(); - axisX->append(categories); - chart->setAxisX(axisX, lineseries); - chart->setAxisX(axisX, barseries); - axisX->setRange(QString("Jan"), QString("Jun")); - - QValueAxis *axisY = new QValueAxis(); - chart->setAxisY(axisY, lineseries); - chart->setAxisY(axisY, barseries); - axisY->setRange(0, 20); -//![4] - -//![5] - chart->legend()->setVisible(true); - chart->legend()->setAlignment(Qt::AlignBottom); -//![5] - -//![6] - QChartView *chartView = new QChartView(chart); - chartView->setRenderHint(QPainter::Antialiasing); -//![6] - -//![7] - QMainWindow window; - window.setCentralWidget(chartView); - window.resize(440, 300); - window.show(); -//![7] - - return a.exec(); -} diff --git a/examples/linechart/linechart.pro b/examples/linechart/linechart.pro deleted file mode 100644 index d3eb640a..00000000 --- a/examples/linechart/linechart.pro +++ /dev/null @@ -1,5 +0,0 @@ -!include( ../examples.pri ) { - error( "Couldn't find the examples.pri file!" ) -} -TARGET = linechart -SOURCES += main.cpp diff --git a/examples/linechart/main.cpp b/examples/linechart/main.cpp deleted file mode 100644 index d47d69f7..00000000 --- a/examples/linechart/main.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include - -QTCOMMERCIALCHART_USE_NAMESPACE - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - -//![1] - QLineSeries *series = new QLineSeries(); -//![1] - -//![2] - series->append(0, 6); - series->append(2, 4); - series->append(3, 8); - series->append(7, 4); - series->append(10, 5); - *series << QPointF(11, 1) << QPointF(13, 3) << QPointF(17, 6) << QPointF(18, 3) << QPointF(20, 2); -//![2] - -//![3] - QChart *chart = new QChart(); - chart->legend()->hide(); - chart->addSeries(series); - chart->createDefaultAxes(); - chart->setTitle("Simple line chart example"); -//![3] - -//![4] - QChartView *chartView = new QChartView(chart); - chartView->setRenderHint(QPainter::Antialiasing); -//![4] - - -//![5] - QMainWindow window; - window.setCentralWidget(chartView); - window.resize(400, 300); - window.show(); -//![5] - - return a.exec(); -} diff --git a/examples/logvalueaxis/logvalueaxis.pro b/examples/logvalueaxis/logvalueaxis.pro deleted file mode 100644 index ede43079..00000000 --- a/examples/logvalueaxis/logvalueaxis.pro +++ /dev/null @@ -1,5 +0,0 @@ -!include( ../examples.pri ) { - error( "Couldn't find the examples.pri file!" ) -} -TARGET = logvalueaxis -SOURCES += main.cpp diff --git a/examples/logvalueaxis/main.cpp b/examples/logvalueaxis/main.cpp deleted file mode 100644 index e1f09f09..00000000 --- a/examples/logvalueaxis/main.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include - -QTCOMMERCIALCHART_USE_NAMESPACE - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - - //![1] - QLineSeries *series = new QLineSeries(); - *series << QPointF(1, 1) << QPointF(2, 73) << QPointF(3, 268) << QPointF(4, 17) << QPointF(5, 4325) << QPointF(6, 723); - //![1] - - //![2] - QChart *chart = new QChart(); - chart->addSeries(series); - chart->legend()->hide(); - chart->setTitle("Logarithmic axis example"); - //![2] - - //![3] - QValueAxis *axisX = new QValueAxis; - axisX->setTitleText("Data point"); - axisX->setTickCount(6); - axisX->setLabelFormat("%i"); - chart->addAxis(axisX, Qt::AlignBottom); - series->attachAxis(axisX); - - QLogValueAxis *axisY = new QLogValueAxis; - axisY->setLabelFormat("%g"); - axisY->setTitleText("Values"); - axisY->setBase(8); - chart->addAxis(axisY, Qt::AlignLeft); - series->attachAxis(axisY); - //![3] - - //![4] - QChartView *chartView = new QChartView(chart); - chartView->setRenderHint(QPainter::Antialiasing); - //![4] - - //![5] - QMainWindow window; - window.setCentralWidget(chartView); - window.resize(400, 300); - window.show(); - //![5] - - return a.exec(); -} diff --git a/examples/modeldata/customtablemodel.cpp b/examples/modeldata/customtablemodel.cpp deleted file mode 100644 index 2bec3c98..00000000 --- a/examples/modeldata/customtablemodel.cpp +++ /dev/null @@ -1,110 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "customtablemodel.h" -#include -#include -#include -#include - -CustomTableModel::CustomTableModel(QObject *parent) : - QAbstractTableModel(parent) -{ - qsrand(QTime(0, 0, 0).secsTo(QTime::currentTime())); - - m_columnCount = 4; - m_rowCount = 15; - - // m_data - for (int i = 0; i < m_rowCount; i++) { - QVector* dataVec = new QVector(m_columnCount); - for (int k = 0; k < dataVec->size(); k++) { - if (k % 2 == 0) - dataVec->replace(k, i * 50 + qrand() % 20); - else - dataVec->replace(k, qrand() % 100); - } - m_data.append(dataVec); - } -} - -int CustomTableModel::rowCount(const QModelIndex &parent) const -{ - Q_UNUSED(parent) - return m_data.count(); -} - -int CustomTableModel::columnCount(const QModelIndex &parent) const -{ - Q_UNUSED(parent) - return m_columnCount; -} - -QVariant CustomTableModel::headerData(int section, Qt::Orientation orientation, int role) const -{ - if (role != Qt::DisplayRole) - return QVariant(); - - if (orientation == Qt::Horizontal) { - if (section % 2 == 0) - return "x"; - else - return "y"; - } else { - return QString("%1").arg(section + 1); - } -} - -QVariant CustomTableModel::data(const QModelIndex &index, int role) const -{ - if (role == Qt::DisplayRole) { - return m_data[index.row()]->at(index.column()); - } else if (role == Qt::EditRole) { - return m_data[index.row()]->at(index.column()); - } else if (role == Qt::BackgroundRole) { - foreach (QRect rect, m_mapping) { - if (rect.contains(index.column(), index.row())) - return QColor(m_mapping.key(rect)); - } - // cell not mapped return white color - return QColor(Qt::white); - } - return QVariant(); -} - -bool CustomTableModel::setData(const QModelIndex &index, const QVariant &value, int role) -{ - if (index.isValid() && role == Qt::EditRole) { - m_data[index.row()]->replace(index.column(), value.toDouble()); - emit dataChanged(index, index); - return true; - } - return false; -} - -Qt::ItemFlags CustomTableModel::flags(const QModelIndex &index) const -{ - return QAbstractItemModel::flags(index) | Qt::ItemIsEditable; -} - -void CustomTableModel::addMapping(QString color, QRect area) -{ - m_mapping.insertMulti(color, area); -} diff --git a/examples/modeldata/customtablemodel.h b/examples/modeldata/customtablemodel.h deleted file mode 100644 index 755f4c7d..00000000 --- a/examples/modeldata/customtablemodel.h +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef CUSTOMTABLEMODEL_H -#define CUSTOMTABLEMODEL_H - -#include -#include -#include - -class CustomTableModel : public QAbstractTableModel -{ - Q_OBJECT -public: - explicit CustomTableModel(QObject *parent = 0); - - int rowCount(const QModelIndex &parent = QModelIndex()) const; - int columnCount(const QModelIndex &parent = QModelIndex()) const; - QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; - bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); - Qt::ItemFlags flags(const QModelIndex &index) const; - - void addMapping(QString color, QRect area); - void clearMapping() { m_mapping.clear(); } - -private: - QList * > m_data; - QHash m_mapping; - int m_columnCount; - int m_rowCount; -}; - -#endif // CUSTOMTABLEMODEL_H diff --git a/examples/modeldata/main.cpp b/examples/modeldata/main.cpp deleted file mode 100644 index bf0b384b..00000000 --- a/examples/modeldata/main.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include "tablewidget.h" - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - TableWidget w; - w.show(); - return a.exec(); -} diff --git a/examples/modeldata/modeldata.pro b/examples/modeldata/modeldata.pro deleted file mode 100644 index 7c302bd9..00000000 --- a/examples/modeldata/modeldata.pro +++ /dev/null @@ -1,16 +0,0 @@ -!include( ../examples.pri ) { - error( "Couldn't find the examples.pri file!" ) -} - -QT += core gui - -TARGET = modeldata -TEMPLATE = app - - -SOURCES += main.cpp\ - tablewidget.cpp \ - customtablemodel.cpp - -HEADERS += tablewidget.h \ - customtablemodel.h diff --git a/examples/modeldata/tablewidget.cpp b/examples/modeldata/tablewidget.cpp deleted file mode 100644 index abfa7bf5..00000000 --- a/examples/modeldata/tablewidget.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "tablewidget.h" -#include "customtablemodel.h" -#include -#include -#include -#include -#include -#include -#include - -QTCOMMERCIALCHART_USE_NAMESPACE - -TableWidget::TableWidget(QWidget *parent) - : QWidget(parent) -{ - // create simple model for storing data - // user's table data model - //! [1] - CustomTableModel *model = new CustomTableModel; - //! [1] - - //! [2] - // create table view and add model to it - QTableView *tableView = new QTableView; - tableView->setModel(model); -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) - tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); - tableView->verticalHeader()->setSectionResizeMode(QHeaderView::Stretch); -#else - tableView->horizontalHeader()->setResizeMode(QHeaderView::Stretch); - tableView->verticalHeader()->setResizeMode(QHeaderView::Stretch); -#endif - //! [2] - - //! [3] - QChart *chart = new QChart; - chart->setAnimationOptions(QChart::AllAnimations); - //! [3] - - // series 1 - //! [4] - QLineSeries *series = new QLineSeries; - series->setName("Line 1"); - QVXYModelMapper *mapper = new QVXYModelMapper(this); - mapper->setXColumn(0); - mapper->setYColumn(1); - mapper->setSeries(series); - mapper->setModel(model); - chart->addSeries(series); - //! [4] - - //! [5] - // for storing color hex from the series - QString seriesColorHex = "#000000"; - - // get the color of the series and use it for showing the mapped area - seriesColorHex = "#" + QString::number(series->pen().color().rgb(), 16).right(6).toUpper(); - model->addMapping(seriesColorHex, QRect(0, 0, 2, model->rowCount())); - //! [5] - - - // series 2 - //! [6] - series = new QLineSeries; - series->setName("Line 2"); - - mapper = new QVXYModelMapper(this); - mapper->setXColumn(2); - mapper->setYColumn(3); - mapper->setSeries(series); - mapper->setModel(model); - chart->addSeries(series); - //! [6] - - //! [7] - // get the color of the series and use it for showing the mapped area - seriesColorHex = "#" + QString::number(series->pen().color().rgb(), 16).right(6).toUpper(); - model->addMapping(seriesColorHex, QRect(2, 0, 2, model->rowCount())); - //! [7] - - //! [8] - chart->createDefaultAxes(); - QChartView *chartView = new QChartView(chart); - chartView->setRenderHint(QPainter::Antialiasing); - chartView->setMinimumSize(640, 480); - //! [8] - - //! [9] - // create main layout - QGridLayout *mainLayout = new QGridLayout; - mainLayout->addWidget(tableView, 1, 0); - mainLayout->addWidget(chartView, 1, 1); - mainLayout->setColumnStretch(1, 1); - mainLayout->setColumnStretch(0, 0); - setLayout(mainLayout); - //! [9] -} diff --git a/examples/modeldata/tablewidget.h b/examples/modeldata/tablewidget.h deleted file mode 100644 index 3846cc11..00000000 --- a/examples/modeldata/tablewidget.h +++ /dev/null @@ -1,34 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef TABLEWIDGET_H -#define TABLEWIDGET_H - -#include - -class TableWidget : public QWidget -{ - Q_OBJECT - -public: - TableWidget(QWidget *parent = 0); -}; - -#endif // TABLEWIDGET_H diff --git a/examples/multiaxis/main.cpp b/examples/multiaxis/main.cpp deleted file mode 100644 index 37c905d8..00000000 --- a/examples/multiaxis/main.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include - -QTCOMMERCIALCHART_USE_NAMESPACE - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - - //![1] - QChart *chart = new QChart(); - chart->legend()->hide(); - chart->setTitle("Multiaxis chart example"); - //![1] - - //![2] - QValueAxis *axisX = new QValueAxis; - axisX->setTickCount(10); - chart->addAxis(axisX, Qt::AlignBottom); - //![2] - - //![3] - QSplineSeries *series = new QSplineSeries; - *series << QPointF(1, 5) << QPointF(3.5, 18) << QPointF(4.8, 7.5) << QPointF(10, 2.5); - chart->addSeries(series); - - QValueAxis *axisY = new QValueAxis; - axisY->setLinePenColor(series->pen().color()); - - chart->addAxis(axisY, Qt::AlignLeft); - series->attachAxis(axisX); - series->attachAxis(axisY); - //![3] - - //![4] - series = new QSplineSeries; - *series << QPointF(1, 0.5) << QPointF(1.5, 4.5) << QPointF(2.4, 2.5) << QPointF(4.3, 12.5) - << QPointF(5.2, 3.5) << QPointF(7.4, 16.5) << QPointF(8.3, 7.5) << QPointF(10, 17); - chart->addSeries(series); - - QCategoryAxis *axisY3 = new QCategoryAxis; - axisY3->append("Low", 5); - axisY3->append("Medium", 12); - axisY3->append("High", 17); - axisY3->setLinePenColor(series->pen().color()); - axisY3->setGridLinePen((series->pen())); - - chart->addAxis(axisY3, Qt::AlignRight); - series->attachAxis(axisX); - series->attachAxis(axisY3); - //![4] - - //![5] - QChartView *chartView = new QChartView(chart); - chartView->setRenderHint(QPainter::Antialiasing); - //![5] - - //![6] - QMainWindow window; - window.setCentralWidget(chartView); - window.resize(800, 600); - window.show(); - //![6] - - return a.exec(); -} - diff --git a/examples/multiaxis/multiaxis.pro b/examples/multiaxis/multiaxis.pro deleted file mode 100644 index 33de57cb..00000000 --- a/examples/multiaxis/multiaxis.pro +++ /dev/null @@ -1,5 +0,0 @@ -!include( ../examples.pri ) { - error( "Couldn't find the examples.pri file!" ) -} -TARGET = multiaxis -SOURCES += main.cpp diff --git a/examples/percentbarchart/main.cpp b/examples/percentbarchart/main.cpp deleted file mode 100644 index 649b29ba..00000000 --- a/examples/percentbarchart/main.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include - -QTCOMMERCIALCHART_USE_NAMESPACE - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - -//![1] - QBarSet *set0 = new QBarSet("Jane"); - QBarSet *set1 = new QBarSet("John"); - QBarSet *set2 = new QBarSet("Axel"); - QBarSet *set3 = new QBarSet("Mary"); - QBarSet *set4 = new QBarSet("Samantha"); - - *set0 << 1 << 2 << 3 << 4 << 5 << 6; - *set1 << 5 << 0 << 0 << 4 << 0 << 7; - *set2 << 3 << 5 << 8 << 13 << 8 << 5; - *set3 << 5 << 6 << 7 << 3 << 4 << 5; - *set4 << 9 << 7 << 5 << 3 << 1 << 2; -//![1] - -//![2] - QPercentBarSeries *series = new QPercentBarSeries(); - series->append(set0); - series->append(set1); - series->append(set2); - series->append(set3); - series->append(set4); -//![2] - -//![3] - QChart *chart = new QChart(); - chart->addSeries(series); - chart->setTitle("Simple percentbarchart example"); - chart->setAnimationOptions(QChart::SeriesAnimations); -//![3] - -//![4] - QStringList categories; - categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; - QBarCategoryAxis *axis = new QBarCategoryAxis(); - axis->append(categories); - chart->createDefaultAxes(); - chart->setAxisX(axis, series); -//![4] - -//![5] - chart->legend()->setVisible(true); - chart->legend()->setAlignment(Qt::AlignBottom); -//![5] - -//![6] - QChartView *chartView = new QChartView(chart); - chartView->setRenderHint(QPainter::Antialiasing); -//![6] - -//![7] - QMainWindow window; - window.setCentralWidget(chartView); - window.resize(420, 300); - window.show(); -//![7] - - return a.exec(); -} - diff --git a/examples/percentbarchart/percentbarchart.pro b/examples/percentbarchart/percentbarchart.pro deleted file mode 100644 index 983159d1..00000000 --- a/examples/percentbarchart/percentbarchart.pro +++ /dev/null @@ -1,6 +0,0 @@ -!include( ../examples.pri ) { - error( "Couldn't find the examples.pri file!" ) -} - -TARGET = percentbarchart -SOURCES += main.cpp diff --git a/examples/piechart/main.cpp b/examples/piechart/main.cpp deleted file mode 100644 index 79a088e0..00000000 --- a/examples/piechart/main.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include - -QTCOMMERCIALCHART_USE_NAMESPACE - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - -//![1] - QPieSeries *series = new QPieSeries(); - series->append("Jane", 1); - series->append("Joe", 2); - series->append("Andy", 3); - series->append("Barbara", 4); - series->append("Axel", 5); -//![1] - -//![2] - QPieSlice *slice = series->slices().at(1); - slice->setExploded(); - slice->setLabelVisible(); - slice->setPen(QPen(Qt::darkGreen, 2)); - slice->setBrush(Qt::green); -//![2] - -//![3] - QChart *chart = new QChart(); - chart->addSeries(series); - chart->setTitle("Simple piechart example"); - chart->legend()->hide(); -//![3] - -//![4] - QChartView *chartView = new QChartView(chart); - chartView->setRenderHint(QPainter::Antialiasing); -//![4] - -//![5] - QMainWindow window; - window.setCentralWidget(chartView); - window.resize(400, 300); - window.show(); -//![5] - - return a.exec(); -} diff --git a/examples/piechart/piechart.pro b/examples/piechart/piechart.pro deleted file mode 100644 index 7bd48514..00000000 --- a/examples/piechart/piechart.pro +++ /dev/null @@ -1,5 +0,0 @@ -!include( ../examples.pri ) { - error( "Couldn't find the examples.pri file!" ) -} -TARGET = piechart -SOURCES += main.cpp diff --git a/examples/piechartdrilldown/drilldownchart.cpp b/examples/piechartdrilldown/drilldownchart.cpp deleted file mode 100644 index 71cd1a06..00000000 --- a/examples/piechartdrilldown/drilldownchart.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "drilldownchart.h" -#include "drilldownslice.h" - -QTCOMMERCIALCHART_USE_NAMESPACE - -DrilldownChart::DrilldownChart(QGraphicsItem *parent, Qt::WindowFlags wFlags) - : QChart(QChart::ChartTypeCartesian, parent, wFlags), - m_currentSeries(0) -{ - -} - -DrilldownChart::~DrilldownChart() -{ - -} - -void DrilldownChart::changeSeries(QAbstractSeries *series) -{ - // NOTE: if the series is owned by the chart it will be deleted - // here the "window" owns the series... - if (m_currentSeries) - removeSeries(m_currentSeries); - m_currentSeries = series; - addSeries(series); - setTitle(series->name()); -} - -void DrilldownChart::handleSliceClicked(QPieSlice *slice) -{ - DrilldownSlice *drilldownSlice = static_cast(slice); - changeSeries(drilldownSlice->drilldownSeries()); -} - -#include "moc_drilldownchart.cpp" diff --git a/examples/piechartdrilldown/drilldownchart.h b/examples/piechartdrilldown/drilldownchart.h deleted file mode 100644 index 7e14083f..00000000 --- a/examples/piechartdrilldown/drilldownchart.h +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef DRILLDOWNCHART_H -#define DRILLDOWNCHART_H - -#include - -QTCOMMERCIALCHART_BEGIN_NAMESPACE -class QAbstractSeries; -class QPieSlice; -QTCOMMERCIALCHART_END_NAMESPACE - -QTCOMMERCIALCHART_USE_NAMESPACE - -class DrilldownChart : public QChart -{ - Q_OBJECT -public: - explicit DrilldownChart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0); - ~DrilldownChart(); - void changeSeries(QAbstractSeries *series); - -public Q_SLOTS: - void handleSliceClicked(QPieSlice *slice); - -private: - QAbstractSeries *m_currentSeries; -}; - -#endif // DRILLDOWNCHART_H diff --git a/examples/piechartdrilldown/drilldownslice.cpp b/examples/piechartdrilldown/drilldownslice.cpp deleted file mode 100644 index a2f8a6cc..00000000 --- a/examples/piechartdrilldown/drilldownslice.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "drilldownslice.h" - -QTCOMMERCIALCHART_USE_NAMESPACE - -DrilldownSlice::DrilldownSlice(qreal value, QString prefix, QAbstractSeries *drilldownSeries) - : m_drilldownSeries(drilldownSeries), - m_prefix(prefix) -{ - setValue(value); - updateLabel(); - setLabelFont(QFont("Arial", 8)); - connect(this, SIGNAL(percentageChanged()), this, SLOT(updateLabel())); - connect(this, SIGNAL(hovered(bool)), this, SLOT(showHighlight(bool))); -} - -DrilldownSlice::~DrilldownSlice() -{ - -} - -QAbstractSeries *DrilldownSlice::drilldownSeries() const -{ - return m_drilldownSeries; -} - -void DrilldownSlice::updateLabel() -{ - QString label = m_prefix; - label += " $"; - label += QString::number(this->value()); - label += ", "; - label += QString::number(this->percentage() * 100, 'f', 1); - label += "%"; - setLabel(label); -} - -void DrilldownSlice::showHighlight(bool show) -{ - setLabelVisible(show); - setExploded(show); -} - -#include "moc_drilldownslice.cpp" diff --git a/examples/piechartdrilldown/drilldownslice.h b/examples/piechartdrilldown/drilldownslice.h deleted file mode 100644 index ce9aae55..00000000 --- a/examples/piechartdrilldown/drilldownslice.h +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef DRILLDOWNSLICE_H -#define DRILLDOWNSLICE_H - -#include - -QTCOMMERCIALCHART_BEGIN_NAMESPACE -class QAbstractSeries; -QTCOMMERCIALCHART_END_NAMESPACE - -QTCOMMERCIALCHART_USE_NAMESPACE - -class DrilldownSlice : public QPieSlice -{ - Q_OBJECT - -public: - DrilldownSlice(qreal value, QString prefix, QAbstractSeries *drilldownSeries); - virtual ~DrilldownSlice(); - QAbstractSeries *drilldownSeries() const; - -public Q_SLOTS: - void updateLabel(); - void showHighlight(bool show); - -private: - QAbstractSeries *m_drilldownSeries; - QString m_prefix; -}; - -#endif // DRILLDOWNSLICE_H diff --git a/examples/piechartdrilldown/main.cpp b/examples/piechartdrilldown/main.cpp deleted file mode 100644 index 2fee9b87..00000000 --- a/examples/piechartdrilldown/main.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "drilldownchart.h" -#include "drilldownslice.h" -#include -#include -#include -#include -#include -#include - -QTCOMMERCIALCHART_USE_NAMESPACE - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - - qsrand(QTime(0, 0, 0).secsTo(QTime::currentTime())); - - QMainWindow window; - - DrilldownChart *chart = new DrilldownChart(); - chart->setTheme(QChart::ChartThemeLight); - chart->setAnimationOptions(QChart::AllAnimations); - chart->legend()->setVisible(true); - chart->legend()->setAlignment(Qt::AlignRight); - - QPieSeries *yearSeries = new QPieSeries(&window); - yearSeries->setName("Sales by year - All"); - - QList months; - months << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun" << "Jul" << "Aug" << "Sep" << "Oct" << "Nov" << "Dec"; - QList names; - names << "Jane" << "John" << "Axel" << "Mary" << "Susan" << "Bob"; - - foreach (QString name, names) { - QPieSeries *series = new QPieSeries(&window); - series->setName("Sales by month - " + name); - - foreach (QString month, months) - *series << new DrilldownSlice(qrand() % 1000, month, yearSeries); - - QObject::connect(series, SIGNAL(clicked(QPieSlice*)), chart, SLOT(handleSliceClicked(QPieSlice*))); - - *yearSeries << new DrilldownSlice(series->sum(), name, series); - } - - QObject::connect(yearSeries, SIGNAL(clicked(QPieSlice*)), chart, SLOT(handleSliceClicked(QPieSlice*))); - - chart->changeSeries(yearSeries); - - QChartView *chartView = new QChartView(chart); - chartView->setRenderHint(QPainter::Antialiasing); - window.setCentralWidget(chartView); - window.resize(800, 500); - window.show(); - - return a.exec(); -} diff --git a/examples/piechartdrilldown/piechartdrilldown.pro b/examples/piechartdrilldown/piechartdrilldown.pro deleted file mode 100644 index 0f9626c9..00000000 --- a/examples/piechartdrilldown/piechartdrilldown.pro +++ /dev/null @@ -1,11 +0,0 @@ -!include( ../examples.pri ) { - error( "Couldn't find the examples.pri file!" ) -} -TARGET = piechartdrilldown -SOURCES += main.cpp \ - drilldownslice.cpp \ - drilldownchart.cpp - -HEADERS += \ - drilldownchart.h \ - drilldownslice.h diff --git a/examples/polarchart/chartview.cpp b/examples/polarchart/chartview.cpp deleted file mode 100644 index 311a2ab4..00000000 --- a/examples/polarchart/chartview.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "chartview.h" -#include -#include -#include -#include - -QTCOMMERCIALCHART_USE_NAMESPACE - -ChartView::ChartView(QWidget *parent) - : QChartView(parent) -{ -} - -//![1] -void ChartView::keyPressEvent(QKeyEvent *event) -{ - switch (event->key()) { - case Qt::Key_Plus: - chart()->zoomIn(); - break; - case Qt::Key_Minus: - chart()->zoomOut(); - break; - case Qt::Key_Left: - chart()->scroll(-1.0, 0); - break; - case Qt::Key_Right: - chart()->scroll(1.0, 0); - break; - case Qt::Key_Up: - chart()->scroll(0, 1.0); - break; - case Qt::Key_Down: - chart()->scroll(0, -1.0); - break; - case Qt::Key_Space: - switchChartType(); - break; - default: - QGraphicsView::keyPressEvent(event); - break; - } -} -//![1] - -//![2] -void ChartView::switchChartType() -{ - QChart *newChart; - QChart *oldChart = chart(); - - if (oldChart->chartType() == QChart::ChartTypeCartesian) - newChart = new QPolarChart(); - else - newChart = new QChart(); - - // Move series and axes from old chart to new one - QList seriesList = oldChart->series(); - QList axisList = oldChart->axes(); - QList > axisRanges; - - foreach (QAbstractAxis *axis, axisList) { - QValueAxis *valueAxis = static_cast(axis); - axisRanges.append(QPair(valueAxis->min(), valueAxis->max())); - } - - foreach (QAbstractSeries *series, seriesList) - oldChart->removeSeries(series); - - foreach (QAbstractAxis *axis, axisList) { - oldChart->removeAxis(axis); - newChart->addAxis(axis, axis->alignment()); - } - - foreach (QAbstractSeries *series, seriesList) { - newChart->addSeries(series); - foreach (QAbstractAxis *axis, axisList) - series->attachAxis(axis); - } - - int count = 0; - foreach (QAbstractAxis *axis, axisList) { - axis->setRange(axisRanges[count].first, axisRanges[count].second); - count++; - } - - newChart->setTitle(oldChart->title()); - setChart(newChart); - delete oldChart; -} -//![2] diff --git a/examples/polarchart/chartview.h b/examples/polarchart/chartview.h deleted file mode 100644 index d968358b..00000000 --- a/examples/polarchart/chartview.h +++ /dev/null @@ -1,41 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef CHARTVIEW_H -#define CHARTVIEW_H - -#include -#include - -QTCOMMERCIALCHART_USE_NAMESPACE - -class ChartView : public QChartView -{ -public: - ChartView(QWidget *parent = 0); - -protected: - void keyPressEvent(QKeyEvent *event); - -private: - void switchChartType(); -}; - -#endif diff --git a/examples/polarchart/main.cpp b/examples/polarchart/main.cpp deleted file mode 100644 index f4516ac4..00000000 --- a/examples/polarchart/main.cpp +++ /dev/null @@ -1,137 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "chartview.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -QTCOMMERCIALCHART_USE_NAMESPACE - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - - const qreal angularMin = -100; - const qreal angularMax = 100; - - const qreal radialMin = -100; - const qreal radialMax = 100; - - QScatterSeries *series1 = new QScatterSeries(); - series1->setName("scatter"); - for (int i = angularMin; i <= angularMax; i += 10) - series1->append(i, (i / radialMax) * radialMax + 8.0); - - QSplineSeries *series2 = new QSplineSeries(); - series2->setName("spline"); - for (int i = angularMin; i <= angularMax; i += 10) - series2->append(i, (i / radialMax) * radialMax); - - QLineSeries *series3 = new QLineSeries(); - series3->setName("star outer"); - qreal ad = (angularMax - angularMin) / 8; - qreal rd = (radialMax - radialMin) / 3 * 1.3; - series3->append(angularMin, radialMax); - series3->append(angularMin + ad*1, radialMin + rd); - series3->append(angularMin + ad*2, radialMax); - series3->append(angularMin + ad*3, radialMin + rd); - series3->append(angularMin + ad*4, radialMax); - series3->append(angularMin + ad*5, radialMin + rd); - series3->append(angularMin + ad*6, radialMax); - series3->append(angularMin + ad*7, radialMin + rd); - series3->append(angularMin + ad*8, radialMax); - - QLineSeries *series4 = new QLineSeries(); - series4->setName("star inner"); - ad = (angularMax - angularMin) / 8; - rd = (radialMax - radialMin) / 3; - series4->append(angularMin, radialMax); - series4->append(angularMin + ad*1, radialMin + rd); - series4->append(angularMin + ad*2, radialMax); - series4->append(angularMin + ad*3, radialMin + rd); - series4->append(angularMin + ad*4, radialMax); - series4->append(angularMin + ad*5, radialMin + rd); - series4->append(angularMin + ad*6, radialMax); - series4->append(angularMin + ad*7, radialMin + rd); - series4->append(angularMin + ad*8, radialMax); - - QAreaSeries *series5 = new QAreaSeries(); - series5->setName("star area"); - series5->setUpperSeries(series3); - series5->setLowerSeries(series4); - series5->setOpacity(0.5); - - //![1] - QPolarChart *chart = new QPolarChart(); - //![1] - chart->addSeries(series1); - chart->addSeries(series2); - chart->addSeries(series3); - chart->addSeries(series4); - chart->addSeries(series5); - - chart->setTitle("Use arrow keys to scroll, +/- to zoom, and space to switch chart type."); - - //![2] - QValueAxis *angularAxis = new QValueAxis(); - angularAxis->setTickCount(9); // First and last ticks are co-located on 0/360 angle. - angularAxis->setLabelFormat("%.1f"); - angularAxis->setShadesVisible(true); - angularAxis->setShadesBrush(QBrush(QColor(249, 249, 255))); - chart->addAxis(angularAxis, QPolarChart::PolarOrientationAngular); - - QValueAxis *radialAxis = new QValueAxis(); - radialAxis->setTickCount(9); - radialAxis->setLabelFormat("%d"); - chart->addAxis(radialAxis, QPolarChart::PolarOrientationRadial); - //![2] - - series1->attachAxis(radialAxis); - series1->attachAxis(angularAxis); - series2->attachAxis(radialAxis); - series2->attachAxis(angularAxis); - series3->attachAxis(radialAxis); - series3->attachAxis(angularAxis); - series4->attachAxis(radialAxis); - series4->attachAxis(angularAxis); - series5->attachAxis(radialAxis); - series5->attachAxis(angularAxis); - - radialAxis->setRange(radialMin, radialMax); - angularAxis->setRange(angularMin, angularMax); - - ChartView *chartView = new ChartView(); - chartView->setChart(chart); - chartView->setRenderHint(QPainter::Antialiasing); - - QMainWindow window; - window.setCentralWidget(chartView); - window.resize(800, 600); - window.show(); - - return a.exec(); -} diff --git a/examples/polarchart/polarchart.pro b/examples/polarchart/polarchart.pro deleted file mode 100644 index 8759c1ce..00000000 --- a/examples/polarchart/polarchart.pro +++ /dev/null @@ -1,6 +0,0 @@ -!include( ../examples.pri ) { - error( "Couldn't find the examples.pri file!" ) -} -TARGET = polarchart -SOURCES += main.cpp chartview.cpp -HEADERS += chartview.h diff --git a/examples/qmlboxplot/main.cpp b/examples/qmlboxplot/main.cpp deleted file mode 100644 index 0ba758b4..00000000 --- a/examples/qmlboxplot/main.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include "qmlapplicationviewer.h" - -Q_DECL_EXPORT int main(int argc, char *argv[]) -{ - QScopedPointer app(createApplication(argc, argv)); - QScopedPointer viewer(QmlApplicationViewer::create()); -#ifdef Q_OS_ANDROID - viewer->addImportPath(QString::fromLatin1("assets:/imports")); - viewer->engine()->addPluginPath(QString::fromLatin1("%1/../%2").arg(QDir::homePath(), QString::fromLatin1("lib"))); -#else - viewer->addImportPath(QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), QString::fromLatin1("imports"))); -#endif - - // // viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); - viewer->setSource(QUrl("qrc:/qml/qmlboxplot/main.qml")); - viewer->setRenderHint(QPainter::Antialiasing, true); - viewer->showExpanded(); - - return app->exec(); -} diff --git a/examples/qmlboxplot/qml/qmlboxplot/main.qml b/examples/qmlboxplot/qml/qmlboxplot/main.qml deleted file mode 100644 index 11d927a6..00000000 --- a/examples/qmlboxplot/qml/qmlboxplot/main.qml +++ /dev/null @@ -1,40 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 -import QtCommercial.Chart 1.3 - -ChartView { - title: "Box Plot series" - width: 400 - height: 300 - theme: ChartView.ChartThemeBrownSand - legend.alignment: Qt.AlignBottom - - BoxPlotSeries { - id: plotSeries - name: "Income" - BoxSet { label: "Jan"; values: [3, 4, 5.1, 6.2, 8.5] } - BoxSet { label: "Feb"; values: [5, 6, 7.5, 8.6, 11.8] } - BoxSet { label: "Mar"; values: [3.2, 5, 5.7, 8, 9.2] } - BoxSet { label: "Apr"; values: [3.8, 5, 6.4, 7, 8] } - BoxSet { label: "May"; values: [4, 5, 5.2, 6, 7] } - } -} diff --git a/examples/qmlboxplot/qmlapplicationviewer/qmlapplicationviewer.cpp b/examples/qmlboxplot/qmlapplicationviewer/qmlapplicationviewer.cpp deleted file mode 100644 index cb227056..00000000 --- a/examples/qmlboxplot/qmlapplicationviewer/qmlapplicationviewer.cpp +++ /dev/null @@ -1,177 +0,0 @@ -// checksum 0xaa72 version 0x90018 -/* - This file was generated by the Qt Quick Application wizard of Qt Creator. - QmlApplicationViewer is a convenience class containing mobile device specific - code such as screen orientation handling. Also QML paths and debugging are - handled here. - It is recommended not to modify this file, since newer versions of Qt Creator - may offer an updated version of it. -*/ - -#include "qmlapplicationviewer.h" - -#include -#include -#include -#include -#include -#include - -#include // MEEGO_EDITION_HARMATTAN - -#ifdef HARMATTAN_BOOSTER -#include -#endif - -#if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 - -#include - -#if !defined(NO_JSDEBUGGER) -#include -#endif -#if !defined(NO_QMLOBSERVER) -#include -#endif - -// Enable debugging before any QDeclarativeEngine is created -struct QmlJsDebuggingEnabler -{ - QmlJsDebuggingEnabler() - { - QDeclarativeDebugHelper::enableDebugging(); - } -}; - -// Execute code in constructor before first QDeclarativeEngine is instantiated -static QmlJsDebuggingEnabler enableDebuggingHelper; - -#endif // QMLJSDEBUGGER - -class QmlApplicationViewerPrivate -{ - QString mainQmlFile; - friend class QmlApplicationViewer; - static QString adjustPath(const QString &path); -}; - -QString QmlApplicationViewerPrivate::adjustPath(const QString &path) -{ -#ifdef Q_OS_MAC - if (!QDir::isAbsolutePath(path)) - return QString::fromLatin1("%1/../Resources/%2") - .arg(QCoreApplication::applicationDirPath(), path); -#elif defined(Q_OS_BLACKBERRY) - if (!QDir::isAbsolutePath(path)) - return QString::fromLatin1("app/native/%1").arg(path); -#elif !defined(Q_OS_ANDROID) - QString pathInInstallDir = - QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); - if (QFileInfo(pathInInstallDir).exists()) - return pathInInstallDir; - pathInInstallDir = - QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); - if (QFileInfo(pathInInstallDir).exists()) - return pathInInstallDir; -#endif - return path; -} - -QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) - : QDeclarativeView(parent) - , d(new QmlApplicationViewerPrivate()) -{ - connect(engine(), SIGNAL(quit()), SLOT(close())); - setResizeMode(QDeclarativeView::SizeRootObjectToView); - - // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in -#if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 -#if !defined(NO_JSDEBUGGER) - new QmlJSDebugger::JSDebuggerAgent(engine()); -#endif -#if !defined(NO_QMLOBSERVER) - new QmlJSDebugger::QDeclarativeViewObserver(this, this); -#endif -#endif -} - -QmlApplicationViewer::~QmlApplicationViewer() -{ - delete d; -} - -QmlApplicationViewer *QmlApplicationViewer::create() -{ - return new QmlApplicationViewer(); -} - -void QmlApplicationViewer::setMainQmlFile(const QString &file) -{ - d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); -#ifdef Q_OS_ANDROID - setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); -#else - setSource(QUrl::fromLocalFile(d->mainQmlFile)); -#endif -} - -void QmlApplicationViewer::addImportPath(const QString &path) -{ - engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); -} - -void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) -{ -#if QT_VERSION < 0x050000 - Qt::WidgetAttribute attribute; - switch (orientation) { -#if QT_VERSION < 0x040702 - // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes - case ScreenOrientationLockPortrait: - attribute = static_cast(128); - break; - case ScreenOrientationLockLandscape: - attribute = static_cast(129); - break; - default: - case ScreenOrientationAuto: - attribute = static_cast(130); - break; -#else // QT_VERSION < 0x040702 - case ScreenOrientationLockPortrait: - attribute = Qt::WA_LockPortraitOrientation; - break; - case ScreenOrientationLockLandscape: - attribute = Qt::WA_LockLandscapeOrientation; - break; - default: - case ScreenOrientationAuto: - attribute = Qt::WA_AutoOrientation; - break; -#endif // QT_VERSION < 0x040702 - }; - setAttribute(attribute, true); -#else // QT_VERSION < 0x050000 - Q_UNUSED(orientation) -#endif // QT_VERSION < 0x050000 -} - -void QmlApplicationViewer::showExpanded() -{ -#if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) - showFullScreen(); -#elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) - showMaximized(); -#else - show(); -#endif -} - -QApplication *createApplication(int &argc, char **argv) -{ -#ifdef HARMATTAN_BOOSTER - return MDeclarativeCache::qApplication(argc, argv); -#else - return new QApplication(argc, argv); -#endif -} diff --git a/examples/qmlboxplot/qmlapplicationviewer/qmlapplicationviewer.h b/examples/qmlboxplot/qmlapplicationviewer/qmlapplicationviewer.h deleted file mode 100644 index adcb232f..00000000 --- a/examples/qmlboxplot/qmlapplicationviewer/qmlapplicationviewer.h +++ /dev/null @@ -1,46 +0,0 @@ -// checksum 0xc67a version 0x90018 -/* - This file was generated by the Qt Quick Application wizard of Qt Creator. - QmlApplicationViewer is a convenience class containing mobile device specific - code such as screen orientation handling. Also QML paths and debugging are - handled here. - It is recommended not to modify this file, since newer versions of Qt Creator - may offer an updated version of it. -*/ - -#ifndef QMLAPPLICATIONVIEWER_H -#define QMLAPPLICATIONVIEWER_H - -#include - -class QmlApplicationViewer : public QDeclarativeView -{ - Q_OBJECT - -public: - enum ScreenOrientation { - ScreenOrientationLockPortrait, - ScreenOrientationLockLandscape, - ScreenOrientationAuto - }; - - explicit QmlApplicationViewer(QWidget *parent = 0); - virtual ~QmlApplicationViewer(); - - static QmlApplicationViewer *create(); - - void setMainQmlFile(const QString &file); - void addImportPath(const QString &path); - - // Note that this will only have an effect on Fremantle. - void setOrientation(ScreenOrientation orientation); - - void showExpanded(); - -private: - class QmlApplicationViewerPrivate *d; -}; - -QApplication *createApplication(int &argc, char **argv); - -#endif // QMLAPPLICATIONVIEWER_H diff --git a/examples/qmlboxplot/qmlapplicationviewer/qmlapplicationviewer.pri b/examples/qmlboxplot/qmlapplicationviewer/qmlapplicationviewer.pri deleted file mode 100644 index 567c6dc6..00000000 --- a/examples/qmlboxplot/qmlapplicationviewer/qmlapplicationviewer.pri +++ /dev/null @@ -1,13 +0,0 @@ -QT += declarative - -SOURCES += $$PWD/qmlapplicationviewer.cpp -HEADERS += $$PWD/qmlapplicationviewer.h -INCLUDEPATH += $$PWD - -# Include JS debugger library if QMLJSDEBUGGER_PATH is set -!isEmpty(QMLJSDEBUGGER_PATH) { - include($$QMLJSDEBUGGER_PATH/qmljsdebugger-lib.pri) -} else { - DEFINES -= QMLJSDEBUGGER -} - diff --git a/examples/qmlboxplot/qmlboxplot.pro b/examples/qmlboxplot/qmlboxplot.pro deleted file mode 100644 index 194aef38..00000000 --- a/examples/qmlboxplot/qmlboxplot.pro +++ /dev/null @@ -1,11 +0,0 @@ -!include( ../examples.pri ) { - error( "Couldn't find the examples.pri file!" ) -} - -RESOURCES += resources.qrc -SOURCES += main.cpp - -include(qmlapplicationviewer/qmlapplicationviewer.pri) - -OTHER_FILES += \ - qml/qmlboxplot/main.qml diff --git a/examples/qmlboxplot/resources.qrc b/examples/qmlboxplot/resources.qrc deleted file mode 100644 index 49a98f16..00000000 --- a/examples/qmlboxplot/resources.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - qml/qmlboxplot/main.qml - - diff --git a/examples/qmlpiechart/main.cpp b/examples/qmlpiechart/main.cpp deleted file mode 100644 index b12a10b2..00000000 --- a/examples/qmlpiechart/main.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include "qmlapplicationviewer.h" - -Q_DECL_EXPORT int main(int argc, char *argv[]) -{ - QScopedPointer app(createApplication(argc, argv)); - QScopedPointer viewer(QmlApplicationViewer::create()); -#ifdef Q_OS_ANDROID - viewer->addImportPath(QString::fromLatin1("assets:/imports")); - viewer->engine()->addPluginPath(QString::fromLatin1("%1/../%2").arg(QDir::homePath(), QString::fromLatin1("lib"))); -#else - viewer->addImportPath(QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), QString::fromLatin1("imports"))); -#endif - - // // viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); - viewer->setSource(QUrl("qrc:/qml/qmlpiechart/main.qml")); - viewer->setRenderHint(QPainter::Antialiasing, true); - viewer->showExpanded(); - - return app->exec(); -} diff --git a/examples/qmlpiechart/qml/qmlpiechart/main.qml b/examples/qmlpiechart/qml/qmlpiechart/main.qml deleted file mode 100644 index 77f4472e..00000000 --- a/examples/qmlpiechart/qml/qmlpiechart/main.qml +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![1] -import QtQuick 1.0 -import QtCommercial.Chart 1.1 - -ChartView { - width: 400 - height: 300 - theme: ChartView.ChartThemeBrownSand - -//![1] -//![2] - PieSeries { - id: pieSeries - PieSlice { label: "eaten"; value: 94.9 } - PieSlice { label: "not yet eaten"; value: 5.1 } - } -//![2] - - Component.onCompleted: { - if (false) { - //![4] - pieSeries.append("don't care", 1.1); - //![4] - - //![5] - pieSeries.at(0).exploded = true; - //![5] - } - } - -//![3] -} -//![3] diff --git a/examples/qmlpiechart/qmlapplicationviewer/qmlapplicationviewer.cpp b/examples/qmlpiechart/qmlapplicationviewer/qmlapplicationviewer.cpp deleted file mode 100644 index cb227056..00000000 --- a/examples/qmlpiechart/qmlapplicationviewer/qmlapplicationviewer.cpp +++ /dev/null @@ -1,177 +0,0 @@ -// checksum 0xaa72 version 0x90018 -/* - This file was generated by the Qt Quick Application wizard of Qt Creator. - QmlApplicationViewer is a convenience class containing mobile device specific - code such as screen orientation handling. Also QML paths and debugging are - handled here. - It is recommended not to modify this file, since newer versions of Qt Creator - may offer an updated version of it. -*/ - -#include "qmlapplicationviewer.h" - -#include -#include -#include -#include -#include -#include - -#include // MEEGO_EDITION_HARMATTAN - -#ifdef HARMATTAN_BOOSTER -#include -#endif - -#if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 - -#include - -#if !defined(NO_JSDEBUGGER) -#include -#endif -#if !defined(NO_QMLOBSERVER) -#include -#endif - -// Enable debugging before any QDeclarativeEngine is created -struct QmlJsDebuggingEnabler -{ - QmlJsDebuggingEnabler() - { - QDeclarativeDebugHelper::enableDebugging(); - } -}; - -// Execute code in constructor before first QDeclarativeEngine is instantiated -static QmlJsDebuggingEnabler enableDebuggingHelper; - -#endif // QMLJSDEBUGGER - -class QmlApplicationViewerPrivate -{ - QString mainQmlFile; - friend class QmlApplicationViewer; - static QString adjustPath(const QString &path); -}; - -QString QmlApplicationViewerPrivate::adjustPath(const QString &path) -{ -#ifdef Q_OS_MAC - if (!QDir::isAbsolutePath(path)) - return QString::fromLatin1("%1/../Resources/%2") - .arg(QCoreApplication::applicationDirPath(), path); -#elif defined(Q_OS_BLACKBERRY) - if (!QDir::isAbsolutePath(path)) - return QString::fromLatin1("app/native/%1").arg(path); -#elif !defined(Q_OS_ANDROID) - QString pathInInstallDir = - QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); - if (QFileInfo(pathInInstallDir).exists()) - return pathInInstallDir; - pathInInstallDir = - QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); - if (QFileInfo(pathInInstallDir).exists()) - return pathInInstallDir; -#endif - return path; -} - -QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) - : QDeclarativeView(parent) - , d(new QmlApplicationViewerPrivate()) -{ - connect(engine(), SIGNAL(quit()), SLOT(close())); - setResizeMode(QDeclarativeView::SizeRootObjectToView); - - // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in -#if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 -#if !defined(NO_JSDEBUGGER) - new QmlJSDebugger::JSDebuggerAgent(engine()); -#endif -#if !defined(NO_QMLOBSERVER) - new QmlJSDebugger::QDeclarativeViewObserver(this, this); -#endif -#endif -} - -QmlApplicationViewer::~QmlApplicationViewer() -{ - delete d; -} - -QmlApplicationViewer *QmlApplicationViewer::create() -{ - return new QmlApplicationViewer(); -} - -void QmlApplicationViewer::setMainQmlFile(const QString &file) -{ - d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); -#ifdef Q_OS_ANDROID - setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); -#else - setSource(QUrl::fromLocalFile(d->mainQmlFile)); -#endif -} - -void QmlApplicationViewer::addImportPath(const QString &path) -{ - engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); -} - -void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) -{ -#if QT_VERSION < 0x050000 - Qt::WidgetAttribute attribute; - switch (orientation) { -#if QT_VERSION < 0x040702 - // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes - case ScreenOrientationLockPortrait: - attribute = static_cast(128); - break; - case ScreenOrientationLockLandscape: - attribute = static_cast(129); - break; - default: - case ScreenOrientationAuto: - attribute = static_cast(130); - break; -#else // QT_VERSION < 0x040702 - case ScreenOrientationLockPortrait: - attribute = Qt::WA_LockPortraitOrientation; - break; - case ScreenOrientationLockLandscape: - attribute = Qt::WA_LockLandscapeOrientation; - break; - default: - case ScreenOrientationAuto: - attribute = Qt::WA_AutoOrientation; - break; -#endif // QT_VERSION < 0x040702 - }; - setAttribute(attribute, true); -#else // QT_VERSION < 0x050000 - Q_UNUSED(orientation) -#endif // QT_VERSION < 0x050000 -} - -void QmlApplicationViewer::showExpanded() -{ -#if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) - showFullScreen(); -#elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX) - showMaximized(); -#else - show(); -#endif -} - -QApplication *createApplication(int &argc, char **argv) -{ -#ifdef HARMATTAN_BOOSTER - return MDeclarativeCache::qApplication(argc, argv); -#else - return new QApplication(argc, argv); -#endif -} diff --git a/examples/qmlpiechart/qmlapplicationviewer/qmlapplicationviewer.h b/examples/qmlpiechart/qmlapplicationviewer/qmlapplicationviewer.h deleted file mode 100644 index adcb232f..00000000 --- a/examples/qmlpiechart/qmlapplicationviewer/qmlapplicationviewer.h +++ /dev/null @@ -1,46 +0,0 @@ -// checksum 0xc67a version 0x90018 -/* - This file was generated by the Qt Quick Application wizard of Qt Creator. - QmlApplicationViewer is a convenience class containing mobile device specific - code such as screen orientation handling. Also QML paths and debugging are - handled here. - It is recommended not to modify this file, since newer versions of Qt Creator - may offer an updated version of it. -*/ - -#ifndef QMLAPPLICATIONVIEWER_H -#define QMLAPPLICATIONVIEWER_H - -#include - -class QmlApplicationViewer : public QDeclarativeView -{ - Q_OBJECT - -public: - enum ScreenOrientation { - ScreenOrientationLockPortrait, - ScreenOrientationLockLandscape, - ScreenOrientationAuto - }; - - explicit QmlApplicationViewer(QWidget *parent = 0); - virtual ~QmlApplicationViewer(); - - static QmlApplicationViewer *create(); - - void setMainQmlFile(const QString &file); - void addImportPath(const QString &path); - - // Note that this will only have an effect on Fremantle. - void setOrientation(ScreenOrientation orientation); - - void showExpanded(); - -private: - class QmlApplicationViewerPrivate *d; -}; - -QApplication *createApplication(int &argc, char **argv); - -#endif // QMLAPPLICATIONVIEWER_H diff --git a/examples/qmlpiechart/qmlapplicationviewer/qmlapplicationviewer.pri b/examples/qmlpiechart/qmlapplicationviewer/qmlapplicationviewer.pri deleted file mode 100644 index 567c6dc6..00000000 --- a/examples/qmlpiechart/qmlapplicationviewer/qmlapplicationviewer.pri +++ /dev/null @@ -1,13 +0,0 @@ -QT += declarative - -SOURCES += $$PWD/qmlapplicationviewer.cpp -HEADERS += $$PWD/qmlapplicationviewer.h -INCLUDEPATH += $$PWD - -# Include JS debugger library if QMLJSDEBUGGER_PATH is set -!isEmpty(QMLJSDEBUGGER_PATH) { - include($$QMLJSDEBUGGER_PATH/qmljsdebugger-lib.pri) -} else { - DEFINES -= QMLJSDEBUGGER -} - diff --git a/examples/qmlpiechart/qmlpiechart.pro b/examples/qmlpiechart/qmlpiechart.pro deleted file mode 100644 index b771d8dd..00000000 --- a/examples/qmlpiechart/qmlpiechart.pro +++ /dev/null @@ -1,9 +0,0 @@ -!include( ../examples.pri ) { - error( "Couldn't find the examples.pri file!" ) -} - -RESOURCES += resources.qrc -SOURCES += main.cpp -OTHER_FILES += qml/qmlpiechart/* - -include(qmlapplicationviewer/qmlapplicationviewer.pri) diff --git a/examples/qmlpiechart/qmlpiechart.svg b/examples/qmlpiechart/qmlpiechart.svg deleted file mode 100644 index 566acfad..00000000 --- a/examples/qmlpiechart/qmlpiechart.svg +++ /dev/null @@ -1,93 +0,0 @@ - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - diff --git a/examples/qmlpiechart/resources.qrc b/examples/qmlpiechart/resources.qrc deleted file mode 100644 index 2501bcc8..00000000 --- a/examples/qmlpiechart/resources.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - qml/qmlpiechart/main.qml - - diff --git a/examples/scatterchart/chartview.cpp b/examples/scatterchart/chartview.cpp deleted file mode 100644 index 345be195..00000000 --- a/examples/scatterchart/chartview.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "chartview.h" -#include -#include -#include -#include -#include - -const float Pi = 3.14159f; - -ChartView::ChartView(QWidget *parent) : - QChartView(new QChart(), parent) -{ - //![1] - QScatterSeries *series0 = new QScatterSeries(); - series0->setName("scatter1"); - series0->setMarkerShape(QScatterSeries::MarkerShapeCircle); - series0->setMarkerSize(15.0); - - QScatterSeries *series1 = new QScatterSeries(); - series1->setName("scatter2"); - series1->setMarkerShape(QScatterSeries::MarkerShapeRectangle); - series1->setMarkerSize(20.0); - - QScatterSeries *series2 = new QScatterSeries(); - series2->setName("scatter3"); - series2->setMarkerShape(QScatterSeries::MarkerShapeRectangle); - series2->setMarkerSize(30.0); - //![1] - - //![2] - series0->append(0, 6); - series0->append(2, 4); - series0->append(3, 8); - series0->append(7, 4); - series0->append(10, 5); - - *series1 << QPointF(1, 1) << QPointF(3, 3) << QPointF(7, 6) << QPointF(8, 3) << QPointF(10, 2); - *series2 << QPointF(1, 5) << QPointF(4, 6) << QPointF(6, 3) << QPointF(9, 5); - //![2] - - //![3] - QPainterPath starPath; - starPath.moveTo(30, 15); - for (int i = 1; i < 5; ++i) { - starPath.lineTo(15 + 15 * qCos(0.8 * i * Pi), - 15 + 15 * qSin(0.8 * i * Pi)); - } - starPath.closeSubpath(); - - QImage star(30, 30, QImage::Format_ARGB32); - star.fill(Qt::transparent); - - QPainter painter(&star); - painter.setRenderHint(QPainter::Antialiasing); - painter.setPen(QRgb(0xf6a625)); - painter.setBrush(painter.pen().color()); - painter.drawPath(starPath); - - series2->setBrush(star); - //![3] - - //![4] - setRenderHint(QPainter::Antialiasing); - chart()->addSeries(series0); - chart()->addSeries(series1); - chart()->addSeries(series2); - - chart()->setTitle("Simple scatterchart example"); - chart()->createDefaultAxes(); - chart()->setDropShadowEnabled(false); - //![4] - - //![5] - QList markers = chart()->legend()->markers(series2); - for (int i = 0; i < markers.count(); i++) - markers.at(i)->setBrush(painter.pen().color()); - //![5] -} diff --git a/examples/scatterchart/chartview.h b/examples/scatterchart/chartview.h deleted file mode 100644 index 699100ff..00000000 --- a/examples/scatterchart/chartview.h +++ /dev/null @@ -1,35 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef CHARTVIEW_H -#define CHARTVIEW_H - -#include - -QTCOMMERCIALCHART_USE_NAMESPACE - -class ChartView : public QChartView -{ - Q_OBJECT -public: - explicit ChartView(QWidget *parent = 0); -}; - -#endif // CHARTVIEW_H diff --git a/examples/scatterchart/main.cpp b/examples/scatterchart/main.cpp deleted file mode 100644 index 43d5e4c6..00000000 --- a/examples/scatterchart/main.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include "chartview.h" - -QTCOMMERCIALCHART_USE_NAMESPACE - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - -//![4] - ChartView *chartView = new ChartView(); - QMainWindow window; - window.setCentralWidget(chartView); - window.resize(400, 300); - window.show(); -//![4] - - return a.exec(); -} diff --git a/examples/scatterchart/scatterchart.pro b/examples/scatterchart/scatterchart.pro deleted file mode 100644 index 8170d6f4..00000000 --- a/examples/scatterchart/scatterchart.pro +++ /dev/null @@ -1,9 +0,0 @@ -!include( ../examples.pri ) { - error( "Couldn't find the examples.pri file!" ) -} -TARGET = scatterchart -SOURCES += main.cpp \ - chartview.cpp - -HEADERS += \ - chartview.h diff --git a/examples/scatterinteractions/chartview.cpp b/examples/scatterinteractions/chartview.cpp deleted file mode 100644 index e7ccd5c4..00000000 --- a/examples/scatterinteractions/chartview.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "chartview.h" -#include -#include - -QTCOMMERCIALCHART_USE_NAMESPACE - -ChartView::ChartView(QWidget *parent) - : QChartView(new QChart(), parent), - m_scatter(0), - m_scatter2(0) -{ - setRenderHint(QPainter::Antialiasing); - - chart()->setTitle("Click to interact with scatter points"); - - m_scatter = new QScatterSeries(); - m_scatter->setName("scatter1"); - for (qreal x(0.5); x <= 4.0; x += 0.5) { - for (qreal y(0.5); y <= 4.0; y += 0.5) { - *m_scatter << QPointF(x, y); - } - } - m_scatter2 = new QScatterSeries(); - m_scatter2->setName("scatter2"); - - chart()->addSeries(m_scatter2); - chart()->addSeries(m_scatter); - chart()->createDefaultAxes(); - chart()->axisX()->setRange(0, 4.5); - chart()->axisY()->setRange(0, 4.5); - - connect(m_scatter, SIGNAL(clicked(QPointF)), this, SLOT(handleClickedPoint(QPointF))); -} - -ChartView::~ChartView() -{ -} - -void ChartView::handleClickedPoint(const QPointF &point) -{ - QPointF clickedPoint = point; - // Find the closest point from series 1 - QPointF closest(INT_MAX, INT_MAX); - qreal distance(INT_MAX); - foreach (QPointF currentPoint, m_scatter->points()) { - qreal currentDistance = qSqrt((currentPoint.x() - clickedPoint.x()) - * (currentPoint.x() - clickedPoint.x()) - + (currentPoint.y() - clickedPoint.y()) - * (currentPoint.y() - clickedPoint.y())); - if (currentDistance < distance) { - distance = currentDistance; - closest = currentPoint; - } - } - - // Remove the closes point from series 1 and append it to series 2 - m_scatter->remove(closest); - m_scatter2->append(closest); -} diff --git a/examples/scatterinteractions/chartview.h b/examples/scatterinteractions/chartview.h deleted file mode 100644 index d84ec6f5..00000000 --- a/examples/scatterinteractions/chartview.h +++ /dev/null @@ -1,46 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef CHARTVIEW_H -#define CHARTVIEW_H - -#include -#include -#include - -QTCOMMERCIALCHART_USE_NAMESPACE - -class ChartView : public QChartView -{ - Q_OBJECT - -public: - ChartView(QWidget *parent = 0); - ~ChartView(); - -private Q_SLOTS: - void handleClickedPoint(const QPointF &point); - -private: - QScatterSeries *m_scatter; - QScatterSeries *m_scatter2; -}; - -#endif // CHARTVIEW_H diff --git a/examples/scatterinteractions/main.cpp b/examples/scatterinteractions/main.cpp deleted file mode 100644 index fb5dd8fc..00000000 --- a/examples/scatterinteractions/main.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include "chartview.h" - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - QMainWindow window; - ChartView chartView(&window); - window.setCentralWidget(&chartView); - window.resize(400, 300); - window.show(); - - return a.exec(); -} diff --git a/examples/scatterinteractions/scatterinteractions.pro b/examples/scatterinteractions/scatterinteractions.pro deleted file mode 100644 index 596fe020..00000000 --- a/examples/scatterinteractions/scatterinteractions.pro +++ /dev/null @@ -1,9 +0,0 @@ -!include( ../examples.pri ) { - error( "Couldn't find the examples.pri file!" ) -} - -TARGET = scatterinteractions -SOURCES += main.cpp \ - chartview.cpp -HEADERS += \ - chartview.h diff --git a/examples/splinechart/main.cpp b/examples/splinechart/main.cpp deleted file mode 100644 index bb4c28d6..00000000 --- a/examples/splinechart/main.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include - -QTCOMMERCIALCHART_USE_NAMESPACE - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - - //![1] - QSplineSeries *series = new QSplineSeries(); - series->setName("spline"); - //![1] - - //![2] - series->append(0, 6); - series->append(2, 4); - series->append(3, 8); - series->append(7, 4); - series->append(10, 5); - *series << QPointF(11, 1) << QPointF(13, 3) << QPointF(17, 6) << QPointF(18, 3) << QPointF(20, 2); - //![2] - - //![3] - QChart *chart = new QChart(); - chart->legend()->hide(); - chart->addSeries(series); - chart->setTitle("Simple spline chart example"); - chart->createDefaultAxes(); - chart->axisY()->setRange(0, 10); - //![3] - - //![4] - QChartView *chartView = new QChartView(chart); - chartView->setRenderHint(QPainter::Antialiasing); - //![4] - - //![5] - QMainWindow window; - window.setCentralWidget(chartView); - window.resize(400, 300); - window.show(); - //![5] - - return a.exec(); -} diff --git a/examples/splinechart/splinechart.pro b/examples/splinechart/splinechart.pro deleted file mode 100644 index b2624f53..00000000 --- a/examples/splinechart/splinechart.pro +++ /dev/null @@ -1,5 +0,0 @@ -!include( ../examples.pri ) { - error( "Couldn't find the examples.pri file!" ) -} -TARGET = splinechart -SOURCES += main.cpp diff --git a/examples/stackedbarchart/main.cpp b/examples/stackedbarchart/main.cpp deleted file mode 100644 index 3e83c39b..00000000 --- a/examples/stackedbarchart/main.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include - -QTCOMMERCIALCHART_USE_NAMESPACE - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - -//![1] - QBarSet *set0 = new QBarSet("Jane"); - QBarSet *set1 = new QBarSet("John"); - QBarSet *set2 = new QBarSet("Axel"); - QBarSet *set3 = new QBarSet("Mary"); - QBarSet *set4 = new QBarSet("Samantha"); - - *set0 << 1 << 2 << 3 << 4 << 5 << 6; - *set1 << 5 << 0 << 0 << 4 << 0 << 7; - *set2 << 3 << 5 << 8 << 13 << 8 << 5; - *set3 << 5 << 6 << 7 << 3 << 4 << 5; - *set4 << 9 << 7 << 5 << 3 << 1 << 2; -//![1] - -//![2] - QStackedBarSeries *series = new QStackedBarSeries(); - series->append(set0); - series->append(set1); - series->append(set2); - series->append(set3); - series->append(set4); -//![2] - -//![3] - QChart *chart = new QChart(); - chart->addSeries(series); - chart->setTitle("Simple stackedbarchart example"); - chart->setAnimationOptions(QChart::SeriesAnimations); -//![3] - -//![4] - QStringList categories; - categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; - QBarCategoryAxis *axis = new QBarCategoryAxis(); - axis->append(categories); - chart->createDefaultAxes(); - chart->setAxisX(axis, series); -//![4] - -//![5] - chart->legend()->setVisible(true); - chart->legend()->setAlignment(Qt::AlignBottom); -//![5] - -//![6] - QChartView *chartView = new QChartView(chart); - chartView->setRenderHint(QPainter::Antialiasing); -//![6] - -//![7] - QMainWindow window; - window.setCentralWidget(chartView); - window.resize(420, 300); - window.show(); -//![7] - - return a.exec(); -} - diff --git a/examples/stackedbarchart/stackedbarchart.pro b/examples/stackedbarchart/stackedbarchart.pro deleted file mode 100644 index f6a77b6a..00000000 --- a/examples/stackedbarchart/stackedbarchart.pro +++ /dev/null @@ -1,5 +0,0 @@ -!include( ../examples.pri ) { - error( "Couldn't find the examples.pri file!" ) -} -TARGET = stackedbarchart -SOURCES += main.cpp diff --git a/examples/stackedbarchartdrilldown/drilldownchart.cpp b/examples/stackedbarchartdrilldown/drilldownchart.cpp deleted file mode 100644 index 1dd3df57..00000000 --- a/examples/stackedbarchartdrilldown/drilldownchart.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "drilldownchart.h" -#include - -QTCOMMERCIALCHART_USE_NAMESPACE - -DrilldownChart::DrilldownChart(QGraphicsItem *parent, Qt::WindowFlags wFlags) - : QChart(QChart::ChartTypeCartesian, parent, wFlags), - m_currentSeries(0) -{ -} - -void DrilldownChart::changeSeries(DrilldownBarSeries *series) -{ - if (m_currentSeries) { - removeSeries(m_currentSeries); - } - - m_currentSeries = series; - - // Reset axis - QBarCategoryAxis *axis = new QBarCategoryAxis(); - axis->append(m_currentSeries->categories()); - - addSeries(series); - - createDefaultAxes(); - setAxisX(axis, series); - axisY()->setTitleText("Crops"); - - setTitle(series->name()); -} - -void DrilldownChart::handleClicked(int index, QBarSet *barset) -{ - Q_UNUSED(barset) - DrilldownBarSeries *series = static_cast(sender()); - changeSeries(series->drilldownSeries(index)); -} - -#include "moc_drilldownchart.cpp" diff --git a/examples/stackedbarchartdrilldown/drilldownchart.h b/examples/stackedbarchartdrilldown/drilldownchart.h deleted file mode 100644 index 1eb7ead0..00000000 --- a/examples/stackedbarchartdrilldown/drilldownchart.h +++ /dev/null @@ -1,46 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef DRILLDOWNCHART_H -#define DRILLDOWNCHART_H - -#include -#include "drilldownseries.h" - -QTCOMMERCIALCHART_USE_NAMESPACE - -//! [1] -class DrilldownChart : public QChart -{ - Q_OBJECT -public: - explicit DrilldownChart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0); - - void changeSeries(DrilldownBarSeries *series); - -public Q_SLOTS: - void handleClicked(int index, QBarSet *barset); - -private: - DrilldownBarSeries *m_currentSeries; -}; -//! [1] - -#endif // DRILLDOWNCHART_H diff --git a/examples/stackedbarchartdrilldown/drilldownseries.cpp b/examples/stackedbarchartdrilldown/drilldownseries.cpp deleted file mode 100644 index 2f3c2fb3..00000000 --- a/examples/stackedbarchartdrilldown/drilldownseries.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "drilldownseries.h" - -QTCOMMERCIALCHART_USE_NAMESPACE - -DrilldownBarSeries::DrilldownBarSeries(QStringList categories, QObject *parent) - : QStackedBarSeries(parent) -{ - m_categories = categories; -} - -void DrilldownBarSeries::mapDrilldownSeries(int index, DrilldownBarSeries *drilldownSeries) -{ - m_DrilldownSeries[index] = drilldownSeries; -} - -DrilldownBarSeries *DrilldownBarSeries::drilldownSeries(int index) -{ - return m_DrilldownSeries[index]; -} - -QStringList DrilldownBarSeries::categories() -{ - return m_categories; -} - -#include "moc_drilldownseries.cpp" diff --git a/examples/stackedbarchartdrilldown/drilldownseries.h b/examples/stackedbarchartdrilldown/drilldownseries.h deleted file mode 100644 index a9c86ad5..00000000 --- a/examples/stackedbarchartdrilldown/drilldownseries.h +++ /dev/null @@ -1,48 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef DRILLDOWNSERIES_H -#define DRILLDOWNSERIES_H - -#include -#include - -QTCOMMERCIALCHART_USE_NAMESPACE - -//! [1] -class DrilldownBarSeries : public QStackedBarSeries -{ - Q_OBJECT -public: - DrilldownBarSeries(QStringList categories, QObject *parent = 0); - - void mapDrilldownSeries(int index, DrilldownBarSeries *drilldownSeries); - - DrilldownBarSeries *drilldownSeries(int index); - - QStringList categories(); - -private: - QMap m_DrilldownSeries; - QStringList m_categories; -}; -//! [1] - -#endif // DRILLDOWNSERIES_H diff --git a/examples/stackedbarchartdrilldown/main.cpp b/examples/stackedbarchartdrilldown/main.cpp deleted file mode 100644 index 2673ab32..00000000 --- a/examples/stackedbarchartdrilldown/main.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include "drilldownseries.h" -#include "drilldownchart.h" - -QTCOMMERCIALCHART_USE_NAMESPACE - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - QMainWindow window; - -//! [1] - DrilldownChart *drilldownChart = new DrilldownChart(); - drilldownChart->setTheme(QChart::ChartThemeBlueIcy); - drilldownChart->setAnimationOptions(QChart::SeriesAnimations); -//! [1] - -//! [2] - // Define categories - QStringList months; - months << "May" << "Jun" << "Jul" << "Aug" << "Sep"; - QStringList weeks; - weeks << "week 1" << "week 2" << "week 3" << "week 4"; - QStringList plants; - plants << "Habanero" << "Lemon Drop" << "Starfish" << "Aji Amarillo"; -//! [2] - -//! [3] - // Create drilldown structure - DrilldownBarSeries *seasonSeries = new DrilldownBarSeries(months, drilldownChart); - seasonSeries->setName("Crop by month - Season"); - - // Each month in season series has drilldown series for weekly data - for (int month = 0; month < months.count(); month++) { - - // Create drilldown series for every week - DrilldownBarSeries *weeklySeries = new DrilldownBarSeries(weeks, drilldownChart); - seasonSeries->mapDrilldownSeries(month, weeklySeries); - - // Drilling down from weekly data brings us back to season data. - for (int week = 0; week < weeks.count(); week++) { - weeklySeries->mapDrilldownSeries(week, seasonSeries); - weeklySeries->setName(QString("Crop by week - " + months.at(month))); - } - - // Use clicked signal to implement drilldown - QObject::connect(weeklySeries, SIGNAL(clicked(int,QBarSet*)), drilldownChart, SLOT(handleClicked(int,QBarSet*))); - } - - // Enable drilldown from season series using clicked signal - QObject::connect(seasonSeries, SIGNAL(clicked(int,QBarSet*)), drilldownChart, SLOT(handleClicked(int,QBarSet*))); -//! [3] - -//! [4] - // Fill monthly and weekly series with data - foreach (QString plant, plants) { - QBarSet *monthlyCrop = new QBarSet(plant); - for (int month = 0; month < months.count(); month++) { - QBarSet *weeklyCrop = new QBarSet(plant); - for (int week = 0; week < weeks.count(); week++) - *weeklyCrop << (qrand() % 20); - // Get the drilldown series from season series and add crop to it. - seasonSeries->drilldownSeries(month)->append(weeklyCrop); - *monthlyCrop << weeklyCrop->sum(); - } - seasonSeries->append(monthlyCrop); - } -//! [4] - -//! [5] - // Show season series in initial view - drilldownChart->changeSeries(seasonSeries); - drilldownChart->setTitle(seasonSeries->name()); -//! [5] - -//! [6] - drilldownChart->axisX()->setGridLineVisible(false); - drilldownChart->legend()->setVisible(true); - drilldownChart->legend()->setAlignment(Qt::AlignBottom); -//! [6] - - QChartView *chartView = new QChartView(drilldownChart); - window.setCentralWidget(chartView); - window.resize(480, 300); - window.show(); - - return a.exec(); -} - diff --git a/examples/stackedbarchartdrilldown/stackedbarchartdrilldown.pro b/examples/stackedbarchartdrilldown/stackedbarchartdrilldown.pro deleted file mode 100644 index c10066f4..00000000 --- a/examples/stackedbarchartdrilldown/stackedbarchartdrilldown.pro +++ /dev/null @@ -1,6 +0,0 @@ -!include( ../examples.pri ) { - error( "Couldn't find the examples.pri file!" ) -} -TARGET = stackedbarchartdrilldown -SOURCES += main.cpp drilldownseries.cpp drilldownchart.cpp -HEADERS += drilldownseries.h drilldownchart.h diff --git a/examples/temperaturerecords/main.cpp b/examples/temperaturerecords/main.cpp deleted file mode 100644 index 97ddfde5..00000000 --- a/examples/temperaturerecords/main.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include - -QTCOMMERCIALCHART_USE_NAMESPACE - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - -//![1] - QBarSet *low = new QBarSet("Min"); - QBarSet *high = new QBarSet("Max"); - - *low << -52 << -50 << -45.3 << -37.0 << -25.6 << -8.0 << -6.0 << -11.8 << -19.7 << -32.8 << -43.0 << -48.0; - *high << 11.9 << 12.8 << 18.5 << 26.5 << 32.0 << 34.8 << 38.2 << 34.8 << 29.8 << 20.4 << 15.1 << 11.8; -//![1] - -//![2] - QStackedBarSeries *series = new QStackedBarSeries(); - series->append(low); - series->append(high); -//![2] - -//![3] - QChart *chart = new QChart(); - chart->addSeries(series); - chart->setTitle("Temperature records in celcius"); - chart->setAnimationOptions(QChart::SeriesAnimations); -//![3] - -//![4] - QStringList categories; - categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun" << "Jul" << "Aug" << "Sep" << "Oct" << "Nov" << "Dec"; - - QBarCategoryAxis *axis = new QBarCategoryAxis(); - axis->append(categories); - axis->setTitleText("Month"); - chart->createDefaultAxes(); - chart->setAxisX(axis, series); - chart->axisY(series)->setRange(-52, 52); - chart->axisY(series)->setTitleText("Temperature [°C]"); -//![4] - -//![5] - chart->legend()->setVisible(true); - chart->legend()->setAlignment(Qt::AlignBottom); -//![5] - -//![6] - QChartView *chartView = new QChartView(chart); - chartView->setRenderHint(QPainter::Antialiasing); -//![6] - -//![7] - QMainWindow window; - window.setCentralWidget(chartView); - window.resize(600, 300); - window.show(); -//![7] - - return a.exec(); -} diff --git a/examples/temperaturerecords/temperaturerecords.pro b/examples/temperaturerecords/temperaturerecords.pro deleted file mode 100644 index e2eb6be3..00000000 --- a/examples/temperaturerecords/temperaturerecords.pro +++ /dev/null @@ -1,6 +0,0 @@ -!include( ../examples.pri ) { - error( "Couldn't find the examples.pri file!" ) -} - -TARGET = temperaturerecords -SOURCES += main.cpp diff --git a/examples/zoomlinechart/chart.cpp b/examples/zoomlinechart/chart.cpp deleted file mode 100644 index 890c6c03..00000000 --- a/examples/zoomlinechart/chart.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "chart.h" -#include -#include -#include - -Chart::Chart(QGraphicsItem *parent, Qt::WindowFlags wFlags) - : QChart(QChart::ChartTypeCartesian, parent, wFlags) -{ - // Seems that QGraphicsView (QChartView) does not grab gestures. - // They can only be grabbed here in the QGraphicsWidget (QChart). - grabGesture(Qt::PanGesture); - grabGesture(Qt::PinchGesture); -} - -Chart::~Chart() -{ - -} - -//![1] -bool Chart::sceneEvent(QEvent *event) -{ - if (event->type() == QEvent::Gesture) - return gestureEvent(static_cast(event)); - return QChart::event(event); -} - -bool Chart::gestureEvent(QGestureEvent *event) -{ - if (QGesture *gesture = event->gesture(Qt::PanGesture)) { - QPanGesture *pan = static_cast(gesture); - QChart::scroll(-(pan->delta().x()), pan->delta().y()); - } - - if (QGesture *gesture = event->gesture(Qt::PinchGesture)) { - QPinchGesture *pinch = static_cast(gesture); - if (pinch->changeFlags() & QPinchGesture::ScaleFactorChanged) - QChart::zoom(pinch->scaleFactor()); - } - - return true; -} -//![1] diff --git a/examples/zoomlinechart/chart.h b/examples/zoomlinechart/chart.h deleted file mode 100644 index 4dea7c79..00000000 --- a/examples/zoomlinechart/chart.h +++ /dev/null @@ -1,48 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef CHART_H -#define CHART_H - -#include - -class QGestureEvent; - -QTCOMMERCIALCHART_USE_NAMESPACE - -//![1] -class Chart : public QChart -//![1] -{ -public: - explicit Chart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0); - ~Chart(); - -protected: - bool sceneEvent(QEvent *event); - -private: - bool gestureEvent(QGestureEvent *event); - -private: - -}; - -#endif // CHART_H diff --git a/examples/zoomlinechart/chartview.cpp b/examples/zoomlinechart/chartview.cpp deleted file mode 100644 index 64369c62..00000000 --- a/examples/zoomlinechart/chartview.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "chartview.h" -#include - -ChartView::ChartView(QChart *chart, QWidget *parent) : - QChartView(chart, parent), - m_isTouching(false) -{ - setRubberBand(QChartView::RectangleRubberBand); -} - -bool ChartView::viewportEvent(QEvent *event) -{ - if (event->type() == QEvent::TouchBegin) { - // By default touch events are converted to mouse events. So - // after this event we will get a mouse event also but we want - // to handle touch events as gestures only. So we need this safeguard - // to block mouse events that are actually generated from touch. - m_isTouching = true; - - // Turn off animations when handling gestures they - // will only slow us down. - chart()->setAnimationOptions(QChart::NoAnimation); - } - return QChartView::viewportEvent(event); -} - -void ChartView::mousePressEvent(QMouseEvent *event) -{ - if (m_isTouching) - return; - QChartView::mousePressEvent(event); -} - -void ChartView::mouseMoveEvent(QMouseEvent *event) -{ - if (m_isTouching) - return; - QChartView::mouseMoveEvent(event); -} - -void ChartView::mouseReleaseEvent(QMouseEvent *event) -{ - if (m_isTouching) - m_isTouching = false; - - // Because we disabled animations when touch event was detected - // we must put them back on. - chart()->setAnimationOptions(QChart::SeriesAnimations); - - QChartView::mouseReleaseEvent(event); -} - -//![1] -void ChartView::keyPressEvent(QKeyEvent *event) -{ - switch (event->key()) { - case Qt::Key_Plus: - chart()->zoomIn(); - break; - case Qt::Key_Minus: - chart()->zoomOut(); - break; -//![1] - case Qt::Key_Left: - chart()->scroll(-10, 0); - break; - case Qt::Key_Right: - chart()->scroll(10, 0); - break; - case Qt::Key_Up: - chart()->scroll(0, 10); - break; - case Qt::Key_Down: - chart()->scroll(0, -10); - break; - default: - QGraphicsView::keyPressEvent(event); - break; - } -} diff --git a/examples/zoomlinechart/chartview.h b/examples/zoomlinechart/chartview.h deleted file mode 100644 index 911a4de4..00000000 --- a/examples/zoomlinechart/chartview.h +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef CHARTVIEW_H -#define CHARTVIEW_H - -#include -#include - -QTCOMMERCIALCHART_USE_NAMESPACE - -//![1] -class ChartView : public QChartView -//![1] -{ -public: - ChartView(QChart *chart, QWidget *parent = 0); - -//![2] -protected: - bool viewportEvent(QEvent *event); - void mousePressEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); - void keyPressEvent(QKeyEvent *event); -//![2] - -private: - bool m_isTouching; -}; - -#endif diff --git a/examples/zoomlinechart/main.cpp b/examples/zoomlinechart/main.cpp deleted file mode 100644 index 5569c0c9..00000000 --- a/examples/zoomlinechart/main.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "chart.h" -#include "chartview.h" -#include -#include -#include -#include -#include - -QTCOMMERCIALCHART_USE_NAMESPACE - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - -//![1] - QLineSeries *series = new QLineSeries(); - for (int i = 0; i < 500; i++) { - QPointF p((qreal) i, qSin(M_PI / 50 * i) * 100); - p.ry() += qrand() % 20; - *series << p; - } -//![1] - - Chart *chart = new Chart(); - chart->addSeries(series); - chart->setTitle("Zoom in/out example"); - chart->setAnimationOptions(QChart::SeriesAnimations); - chart->legend()->hide(); - chart->createDefaultAxes(); - - ChartView *chartView = new ChartView(chart); - chartView->setRenderHint(QPainter::Antialiasing); - - QMainWindow window; - window.setCentralWidget(chartView); - window.resize(400, 300); - window.grabGesture(Qt::PanGesture); - window.grabGesture(Qt::PinchGesture); - window.show(); - - return a.exec(); -} diff --git a/examples/zoomlinechart/zoomlinechart.pro b/examples/zoomlinechart/zoomlinechart.pro deleted file mode 100644 index c98161b2..00000000 --- a/examples/zoomlinechart/zoomlinechart.pro +++ /dev/null @@ -1,7 +0,0 @@ -!include( ../examples.pri ) { - error( "Couldn't find the examples.pri file!" ) -} -TARGET = zoomlinechart -HEADERS += chart.h chartview.h - -SOURCES += main.cpp chart.cpp chartview.cpp -- cgit v1.2.3