Index: trunk/extensions/SemanticResultFormats/jqPlot/SRF_jqPlotBar.php |
— | — | @@ -146,25 +146,33 @@ |
147 | 147 | |
148 | 148 | $numbers = array(); |
149 | 149 | $labels = array(); |
| 150 | + |
150 | 151 | // print all result rows |
151 | 152 | $count = 0; |
152 | 153 | $max_number = 0; |
153 | 154 | $min_number = 0; |
| 155 | + |
154 | 156 | while ( $row = $res->getNext() ) { |
155 | 157 | $name = efSRFGetNextDV( $row[0] )->getShortWikiText(); |
156 | 158 | $name = str_replace( "'", "\'", $name ); |
| 159 | + |
157 | 160 | foreach ( $row as $field ) { |
158 | | - while ( ( $object = efSRFGetNextDV( $field ) ) !== false ) { |
159 | | - if ( $object->isNumeric() ) { // use numeric sortkey |
160 | | - if ( method_exists( $object, 'getValueKey' ) ) { |
| 161 | + while ( ( $object = efSRFGetNextDV( $field ) ) !== false ) { |
| 162 | + // use numeric sortkey |
| 163 | + if ( $object->isNumeric() ) { |
| 164 | + // getDataItem was introduced in SMW 1.6, getValueKey was deprecated in the same version. |
| 165 | + if ( method_exists( $object, 'getDataItem' ) ) { |
| 166 | + $object->getDataItem()->getSortKey(); |
| 167 | + } else { |
161 | 168 | $nr = $object->getValueKey(); |
162 | | - } else { |
163 | | - $nr = $object->getNumericValue(); |
164 | 169 | } |
| 170 | + |
165 | 171 | $count++; |
| 172 | + |
166 | 173 | if ( $nr > $max_number ) { |
167 | 174 | $max_number = $nr; |
168 | 175 | } |
| 176 | + |
169 | 177 | if ( $nr < $min_number ) { |
170 | 178 | $min_number = $nr; |
171 | 179 | } |
— | — | @@ -179,21 +187,26 @@ |
180 | 188 | } |
181 | 189 | } |
182 | 190 | } |
| 191 | + |
183 | 192 | $barID = 'bar' . self::$m_barchartnum; |
184 | 193 | self::$m_barchartnum++; |
185 | 194 | |
186 | 195 | $labels_str = implode( ', ', $labels ); |
187 | 196 | $numbers_str = implode( ', ', $numbers ); |
188 | | - $labels_axis ="xaxis"; |
189 | | - $numbers_axis = "yaxis"; |
| 197 | + |
| 198 | + $labels_axis = 'xaxis'; |
| 199 | + $numbers_axis = 'yaxis'; |
| 200 | + |
190 | 201 | $angle_val = -40; |
191 | 202 | $barmargin = 6; |
| 203 | + |
192 | 204 | if ( $this->m_bardirection == 'horizontal' ) { |
193 | | - $labels_axis ="yaxis"; |
194 | | - $numbers_axis ="xaxis"; |
| 205 | + $labels_axis = 'yaxis'; |
| 206 | + $numbers_axis = 'xaxis'; |
195 | 207 | $angle_val = 0; |
196 | 208 | $barmargin = 8 ; |
197 | 209 | } |
| 210 | + |
198 | 211 | $barwidth = 20; // width of each bar |
199 | 212 | $bardistance = 4; // distance between two bars |
200 | 213 | |
— | — | @@ -218,6 +231,7 @@ |
219 | 232 | $multipleOf10 = pow( 10, floor( log( $max_number, 10 ) ) ); |
220 | 233 | $maxAxis = ceil( $max_number / $multipleOf10 ) * $multipleOf10; |
221 | 234 | } |
| 235 | + |
222 | 236 | if ( $min_number == 0 ) { |
223 | 237 | $negativeMultipleOf10 = 0; |
224 | 238 | $minAxis = 0; |
— | — | @@ -225,12 +239,14 @@ |
226 | 240 | $negativeMultipleOf10 = -1 * pow( 10, floor( log( -1 * $min_number, 10 ) ) ); |
227 | 241 | $minAxis = ceil( $min_number / $negativeMultipleOf10 ) * $negativeMultipleOf10; |
228 | 242 | } |
| 243 | + |
229 | 244 | $numbers_ticks = ''; |
230 | 245 | $biggerMultipleOf10 = max( $multipleOf10, -1 * $negativeMultipleOf10 ); |
231 | 246 | $lowestTick = floor( $minAxis / $biggerMultipleOf10 + .001 ); |
232 | 247 | $highestTick = ceil( $maxAxis / $biggerMultipleOf10 - .001 ); |
| 248 | + |
233 | 249 | for ( $i = $lowestTick; $i <= $highestTick; $i++ ) { |
234 | | - $numbers_ticks .= ($i * $biggerMultipleOf10) . ", "; |
| 250 | + $numbers_ticks .= ($i * $biggerMultipleOf10) . ', '; |
235 | 251 | } |
236 | 252 | |
237 | 253 | $js_bar =<<<END |
— | — | @@ -288,4 +304,5 @@ |
289 | 305 | array( 'name' => 'width', 'type' => 'int', 'description' => wfMsg( 'srf_paramdesc_chartwidth' ) ), |
290 | 306 | ); |
291 | 307 | } |
| 308 | + |
292 | 309 | } |