summaryrefslogtreecommitdiffstats
path: root/examples/datavisualization/qmlbars/doc
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@digia.com>2014-05-08 14:55:13 +0300
committerMiikka Heikkinen <miikka.heikkinen@digia.com>2014-05-09 13:44:47 +0300
commit590d11726e0708e9f8fad0ec386cc5859dbe5cc8 (patch)
treec71592d440579365774a1e56be842d135a9b9b30 /examples/datavisualization/qmlbars/doc
parentbb36daafb6cb461d21c6f6dace10e23ee5fc2dde (diff)
Enable mapping single role to multiple properties for bars
Surface and scatter to follow in separate task Task-number: QTRD-3074 Change-Id: I790078446cd1b805a83da2e3760eaf27c586aaab Reviewed-by: Tomi Korpipää <tomi.korpipaa@digia.com>
Diffstat (limited to 'examples/datavisualization/qmlbars/doc')
-rw-r--r--examples/datavisualization/qmlbars/doc/src/qmlbars.qdoc17
1 files changed, 13 insertions, 4 deletions
diff --git a/examples/datavisualization/qmlbars/doc/src/qmlbars.qdoc b/examples/datavisualization/qmlbars/doc/src/qmlbars.qdoc
index d3da5e6a..f2a0f8b0 100644
--- a/examples/datavisualization/qmlbars/doc/src/qmlbars.qdoc
+++ b/examples/datavisualization/qmlbars/doc/src/qmlbars.qdoc
@@ -39,9 +39,9 @@
\snippet qmlbars/qml/qmlbars/Data.qml 0
\dots
- Each data item has four roles: year, month, income, and expenses. Years and months are natural to
- map to rows and columns of a bar chart, but we can only show either income or expenses as the
- value.
+ Each data item has three roles: timestamp, income, and expenses. The timestamp value is in
+ format: \c{<four digit year>-<two digit month>}. Years and months are natural to map to rows and
+ columns of a bar chart, but we can only show either income or expenses as the value.
Now we need to add the data to the Bars3D graph. We will create two Bar3DSeries inside it,
starting with a series for the income:
@@ -50,7 +50,16 @@
\dots
The data is attached to the \c itemModel property of the ItemModelBarDataProxy inside the
- series.
+ series. For \c valueRole we simply specify the \c income field, as it contains the value we
+ want, but getting the years and months is a bit more complicated, since they are both found
+ in the same field. To extract those values, we specify the \c timestamp field for both
+ \c rowRole and \c columnRole, and additionally specify a search pattern and a replace rule
+ for those roles to extract the correct portion of the field contents for each role.
+ The search pattern is a normal JavaScript regular expression and the replace rule specifies
+ what the field content that matches the regular expression is replaced with.
+ In this case we want to replace the entire field content with just the year or the month.
+ For more information how the replace using regular expressions works, see
+ QString::replace(const QRegExp &rx, const QString &after) function documentation.
Then we add another series for the expenses: