Index: trunk/extensions/SemanticResultFormats/GoogleCharts/SRF_GoogleBar.php |
— | — | @@ -36,17 +36,20 @@ |
37 | 37 | $first = true; |
38 | 38 | $count = 0; // How many bars will they be? Needed to calculate the height of the image |
39 | 39 | $max = 0; // the biggest value. needed for scaling |
| 40 | + |
40 | 41 | while ( $row = $res->getNext() ) { |
41 | 42 | $name = efSRFGetNextDV( $row[0] )->getShortWikiText(); |
42 | 43 | foreach ( $row as $field ) { |
43 | | - while ( ( $object = efSRFGetNextDV( $field ) ) !== false ) { |
44 | | - if ( $object->isNumeric() ) { // use numeric sortkey |
45 | | - if ( method_exists( $object, 'getValueKey' ) ) { |
| 44 | + while ( ( $object = efSRFGetNextDV( $field ) ) !== false ) { |
| 45 | + |
| 46 | + // use numeric sortkey |
| 47 | + if ( $object->isNumeric() ) { |
| 48 | + // getDataItem was introduced in SMW 1.6, getValueKey was deprecated in the same version. |
| 49 | + if ( method_exists( $object, 'getDataItem' ) ) { |
| 50 | + $nr = $object->getDataItem()->getSortKey(); |
| 51 | + } else { |
46 | 52 | $nr = $object->getValueKey(); |
47 | 53 | } |
48 | | - else { |
49 | | - $nr = $object->getNumericValue(); |
50 | | - } |
51 | 54 | |
52 | 55 | $count++; |
53 | 56 | $max = max( $max, $nr ); |
— | — | @@ -63,9 +66,11 @@ |
64 | 67 | } |
65 | 68 | } |
66 | 69 | } |
| 70 | + |
67 | 71 | $barwidth = 20; // width of each bar |
68 | 72 | $bardistance = 4; // distance between two bars |
69 | 73 | $height = $count * ( $barwidth + $bardistance ) + 15; // calculates the height of the image |
| 74 | + |
70 | 75 | return '<img src="http://chart.apis.google.com/chart?cht=bhs&chbh=' . $barwidth . ',' . $bardistance . '&chs=' . $this->m_width . 'x' . $height . '&chds=0,' . $max . '&chd=t:' . $t . '&chxt=y&chxl=0:|' . $n . '" width="' . $this->m_width . '" height="' . $height . '" />'; |
71 | 76 | |
72 | 77 | } |
Index: trunk/extensions/SemanticResultFormats/GoogleCharts/SRF_GooglePie.php |
— | — | @@ -41,18 +41,23 @@ |
42 | 42 | // print all result rows |
43 | 43 | $first = true; |
44 | 44 | $max = 0; // the biggest value. needed for scaling |
| 45 | + |
45 | 46 | while ( $row = $res->getNext() ) { |
46 | 47 | $name = efSRFGetNextDV( $row[0] )->getShortWikiText(); |
| 48 | + |
47 | 49 | foreach ( $row as $field ) { |
48 | | - while ( ( $object = efSRFGetNextDV( $field ) ) !== false ) { |
49 | | - if ( $object->isNumeric() ) { // use numeric sortkey |
50 | | - if ( method_exists( $object, 'getValueKey' ) ) { |
| 50 | + while ( ( $object = efSRFGetNextDV( $field ) ) !== false ) { |
| 51 | + // use numeric sortkey |
| 52 | + if ( $object->isNumeric() ) { |
| 53 | + // getDataItem was introduced in SMW 1.6, getValueKey was deprecated in the same version. |
| 54 | + if ( method_exists( $object, 'getDataItem' ) ) { |
| 55 | + $nr = $object->getDataItem()->getSortKey(); |
| 56 | + } else { |
51 | 57 | $nr = $object->getValueKey(); |
52 | 58 | } |
53 | | - else { |
54 | | - $nr = $object->getNumericValue(); |
55 | | - } |
| 59 | + |
56 | 60 | $max = max( $max, $nr ); |
| 61 | + |
57 | 62 | if ( $first ) { |
58 | 63 | $first = false; |
59 | 64 | $t .= $nr; |