123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- // import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
- import QtQuick 1.1
- import "../js/core.js" as Core
- Rectangle {
- id: barchart
- property alias good: bar1.height
- property alias bad: bar2.height
- //property alias total: bar3.height
- color: "#00000000"
- Rectangle{
- id:bar1
- height: 150
- width: 60
- color: "green"
- gradient: Gradient {
- GradientStop {
- position: 0.00;
- color: "#008000";
- }
- GradientStop {
- position: 1.00;
- color: "#ffffff";
- }
- }
- border.color: "black"
- anchors.right: bar2.left
- anchors.bottom: parent.verticalCenter
- }
- Text{
- anchors.horizontalCenter: bar1.horizontalCenter
- anchors.bottom: bar1.top
- anchors.bottomMargin: 5
- text: qsTr("Good")
- }
- Rectangle{
- id:bar2
- height: 90
- width: 60
- color: "red"
- gradient: Gradient {
- GradientStop {
- position: 0.00;
- color: "#ff0000";
- }
- GradientStop {
- position: 1.00;
- color: "#ffffff";
- }
- }
- border.color: "black"
- anchors.horizontalCenter: parent.horizontalCenter
- anchors.top: parent.verticalCenter
- }
- Text{
- anchors.horizontalCenter: bar2.horizontalCenter
- anchors.top: bar2.bottom
- anchors.topMargin: 5
- text: qsTr("Bad")
- }
- Rectangle{
- id:bar3
- //height: 60
- width: 60
- color: "blue"
- gradient: Gradient {
- GradientStop {
- position: 0.00;
- color: "#0000ff";
- }
- GradientStop {
- position: 1.00;
- color: "#ffffff";
- }
- }
- border.color: "blue"
- //anchors.bottom: parent.verticalCenter
- anchors.left:bar2.right
- }
- Text{
- id: karmatext
- anchors.horizontalCenter: bar3.horizontalCenter
- text: qsTr("Karma")
- }
- function getKarma(){
- var maxvalue=100
- chart.bad=-1*Core.getBadKarma();
- chart.good=Core.getGoodKarma();
- if (chart.good>chart.bad){
- chart.bad=chart.bad*maxvalue/chart.good
- chart.good=maxvalue
- bar3.height=(bar1.height-bar2.height)
- bar3.y=bar1.y+bar2.height
- karmatext.anchors.bottom=bar3.top
- karmatext.anchors.bottomMargin=5
- }else{
- chart.good=chart.good*maxvalue/chart.bad
- chart.bad=maxvalue
- bar3.height=(bar2.height-bar1.height)
- bar3.y=bar2.y
- karmatext.anchors.top=bar3.bottom
- karmatext.anchors.topMargin=5
- }
- }
- }
|