From a53d18bba921d7250f2fc97d1746a6bea84e4668 2012-08-24 08:28:00 From: Tero Ahola Date: 2012-08-24 08:28:00 Subject: [PATCH] Added donut to QML chart demo app --- diff --git a/demos/qmlchart/qml/qmlchart/View1.qml b/demos/qmlchart/qml/qmlchart/View1.qml index 9a0cdca..dc44adc 100644 --- a/demos/qmlchart/qml/qmlchart/View1.qml +++ b/demos/qmlchart/qml/qmlchart/View1.qml @@ -23,8 +23,7 @@ import QtCommercial.Chart 1.0 Rectangle { anchors.fill: parent - property int __explodedIndex: -1 - property variant otherSlice: 0 + property variant othersSlice: 0 //![1] ChartView { @@ -45,7 +44,7 @@ Rectangle { Component.onCompleted: { // You can also manipulate slices dynamically - otherSlice = pieSeries.append("Others", 52.0); + othersSlice = pieSeries.append("Others", 52.0); pieSeries.find("Volkswagen").exploded = true; } //![1] diff --git a/demos/qmlchart/qml/qmlchart/View12.qml b/demos/qmlchart/qml/qmlchart/View12.qml new file mode 100644 index 0000000..d78a59e --- /dev/null +++ b/demos/qmlchart/qml/qmlchart/View12.qml @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2012 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 Commercial Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial 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.0 + +Rectangle { + anchors.fill: parent + + //![1] + ChartView { + id: chart + title: "Production costs" + anchors.fill: parent + legend.visible: false + + PieSeries { + id: pieOuter + size: 0.96 + PieSlice { id: slice; label: "Alpha"; value: 19511; color: "#2D6960"; borderColor: "#163430" } + PieSlice { label: "Epsilon"; value: 11105; color: "#EFE672"; borderColor: "#3B391C" } + PieSlice { label: "Psi"; value: 9352; color: "#4C1B33"; borderColor: "#13060C" } + } + + PieSeries { + size: 0.7 + id: pieInner + + PieSlice { label: "Materials"; value: 10334; color: "#618E87"; borderColor: "#163430" } + PieSlice { label: "Employee"; value: 3066; color: "#2D6960"; borderColor: "#163430"; borderWidth: 2 } + PieSlice { label: "Logistics"; value: 6111; color: "#214E48"; borderColor: "#163430"; borderWidth: 2 } + + PieSlice { label: "Materials"; value: 7371; color: "#F7F28B"; borderColor: "#3B391C"; borderWidth: 2 } + PieSlice { label: "Employee"; value: 2443; color: "#EFE672"; borderColor: "#3B391C"; borderWidth: 2 } + PieSlice { label: "Logistics"; value: 1291; color: "#777339"; borderColor: "#3B391C"; borderWidth: 2 } + + PieSlice { label: "Materials"; value: 4022; color: "#785466"; borderColor: "#13060C"; borderWidth: 2 } + PieSlice { label: "Employee"; value: 3998; color: "#4C1B33"; borderColor: "#13060C"; borderWidth: 2 } + PieSlice { label: "Logistics"; value: 1332; color: "#260D19"; borderColor: "#13060C"; borderWidth: 2 } + } + } + //![1] + + 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 = 2; + } + for (var i = 0; i < pieInner.count; i++) { + pieInner.at(i).labelPosition = PieSlice.LabelInsideNormal; + pieInner.at(i).labelVisible = true; + pieInner.at(i).borderWidth = 2; + } + } +} diff --git a/demos/qmlchart/qml/qmlchart/main.qml b/demos/qmlchart/qml/qmlchart/main.qml index 26b1687..7ea7f20 100644 --- a/demos/qmlchart/qml/qmlchart/main.qml +++ b/demos/qmlchart/qml/qmlchart/main.qml @@ -24,7 +24,7 @@ import QtCommercial.Chart 1.0 Rectangle { width: parent.width height: parent.height - property int viewNumber: 1 + property int viewNumber: 12 Loader { id: loader @@ -74,7 +74,7 @@ Rectangle { function nextView() { var i = viewNumber + 1; - if (i > 11) + if (i > 12) viewNumber = 1; else viewNumber = i; @@ -83,7 +83,7 @@ Rectangle { function previousView() { var i = viewNumber - 1; if (i <= 0) - viewNumber = 11; + viewNumber = 12; else viewNumber = i; } diff --git a/demos/qmlchart/resources.qrc b/demos/qmlchart/resources.qrc index d717688..43b6f8a 100644 --- a/demos/qmlchart/resources.qrc +++ b/demos/qmlchart/resources.qrc @@ -13,5 +13,6 @@ qml/qmlchart/View9.qml qml/qmlchart/View10.qml qml/qmlchart/View11.qml + qml/qmlchart/View12.qml