Yaron Koren has submitted this change and it was merged.
Change subject: Fixes for new logarithmic tag cloud display
......................................................................
Fixes for new logarithmic tag cloud display
The logarithmic display is now the only option (the LocalSettings.php
setting was removed), the display is now correct for subcategories as well
(before, it was just for filter values), and handling was fixed if there's
no difference between the lowest and highest number of values.
Change-Id: Ic6a7f38063d60b1b611a263a8e7f2a27e9f494a8
---
M SemanticDrilldown.php
M specials/SD_BrowseData.php
2 files changed, 17 insertions(+), 16 deletions(-)
Approvals:
Yaron Koren: Verified; Looks good to me, approved
jenkins-bot: Checked
diff --git a/SemanticDrilldown.php b/SemanticDrilldown.php
index 98f05a5..1b0c58b 100644
--- a/SemanticDrilldown.php
+++ b/SemanticDrilldown.php
@@ -121,8 +121,6 @@
// set these to a positive value to trigger the "tag cloud" display
$sdgFiltersSmallestFontSize = - 1;
$sdgFiltersLargestFontSize = - 1;
-// logarithmic scale?
-$sdgFiltersLogScale = 0;
// print categories list as tabs
$sdgShowCategoriesAsTabs = false;
diff --git a/specials/SD_BrowseData.php b/specials/SD_BrowseData.php
index 7eeca19..7aa980a 100644
--- a/specials/SD_BrowseData.php
+++ b/specials/SD_BrowseData.php
@@ -587,7 +587,7 @@
}
function printUnappliedFilterValues( $cur_url, $f, $filter_values ) {
- global $sdgFiltersSmallestFontSize, $sdgFiltersLargestFontSize,
$sdgFiltersLogScale;
+ global $sdgFiltersSmallestFontSize, $sdgFiltersLargestFontSize;
$results_line = "";
// set font-size values for filter "tag cloud", if the
@@ -595,10 +595,9 @@
if ( $sdgFiltersSmallestFontSize > 0 &&
$sdgFiltersLargestFontSize > 0 ) {
$lowest_num_results = min( $filter_values );
$highest_num_results = max( $filter_values );
- $scale_factor = ( $sdgFiltersLargestFontSize -
$sdgFiltersSmallestFontSize ) / ( $highest_num_results - $lowest_num_results );
- if( $sdgFiltersLogScale ){
- $scale_factor = ( $sdgFiltersLargestFontSize -
$sdgFiltersSmallestFontSize ) / ( log($highest_num_results) -
log($lowest_num_results) );
- }
+ if ( $lowest_num_results != $highest_num_results ) {
+ $scale_factor = ( $sdgFiltersLargestFontSize -
$sdgFiltersSmallestFontSize ) / ( log($highest_num_results) -
log($lowest_num_results) );
+ }
}
// now print the values
$num_printed_values = 0;
@@ -608,10 +607,11 @@
$filter_text .= " ($num_results)";
$filter_url = $cur_url . urlencode( str_replace( ' ',
'_', $f->name ) ) . '=' . urlencode( str_replace( ' ', '_', $value_str ) );
if ( $sdgFiltersSmallestFontSize > 0 &&
$sdgFiltersLargestFontSize > 0 ) {
- $font_size = round( (($num_results -
$lowest_num_results) * $scale_factor ) + $sdgFiltersSmallestFontSize );
- if( $sdgFiltersLogScale ){
- $font_size = round( ((log($num_results) -
log($lowest_num_results)) * $scale_factor ) + $sdgFiltersSmallestFontSize );
- }
+ if ( $lowest_num_results !=
$highest_num_results ) {
+ $font_size = round( ((log($num_results)
- log($lowest_num_results)) * $scale_factor ) + $sdgFiltersSmallestFontSize );
+ } else {
+ $font_size = (
$sdgFiltersSmallestFontSize + $sdgFiltersLargestFontSize ) / 2;
+ }
$results_line .= "\n
" . '<a href="' . $filter_url . '" title="' . wfMsg(
'sd_browsedata_filterbyvalue' ) . '" style="font-size: ' . $font_size . 'px">'
. $filter_text . '</a>';
} else {
$results_line .= "\n
" . '<a href="' . $filter_url . '" title="' . wfMsg(
'sd_browsedata_filterbyvalue' ) . '">' . $filter_text . '</a>';
@@ -900,10 +900,9 @@
if ( $sdgFiltersSmallestFontSize > 0 &&
$sdgFiltersLargestFontSize > 0 ) {
$lowest_num_results = min( $subcat_values );
$highest_num_results = max( $subcat_values );
- $num_results_midpoint = ( $lowest_num_results +
$highest_num_results ) / 2;
- $font_size_midpoint = (
$sdgFiltersSmallestFontSize + $sdgFiltersLargestFontSize ) / 2;
- $num_results_per_font_pixel = (
$highest_num_results + 1 - $lowest_num_results ) /
- ( $sdgFiltersLargestFontSize + 1 -
$sdgFiltersSmallestFontSize );
+ if ( $lowest_num_results !=
$highest_num_results ) {
+ $scale_factor = (
$sdgFiltersLargestFontSize - $sdgFiltersSmallestFontSize ) / (
log($highest_num_results) - log($lowest_num_results) );
+ }
}
foreach ( $subcat_values as $subcat => $num_results ) {
@@ -912,7 +911,11 @@
$filter_text = str_replace( '_', ' ',
$subcat ) . " ($num_results)";
$filter_url = $cur_url . '_subcat=' .
urlencode( $subcat );
if ( $sdgFiltersSmallestFontSize > 0 &&
$sdgFiltersLargestFontSize > 0 ) {
- $font_size = round(
$font_size_midpoint + ( ( $num_results - $num_results_midpoint ) /
$num_results_per_font_pixel ) );
+ if ( $lowest_num_results !=
$highest_num_results ) {
+ $font_size = round(
((log($num_results) - log($lowest_num_results)) * $scale_factor ) +
$sdgFiltersSmallestFontSize );
+ } else {
+ $font_size = (
$sdgFiltersSmallestFontSize + $sdgFiltersLargestFontSize ) / 2;
+ }
$results_line .= "\n
" . '<a href="' . $filter_url . '" title="' . wfMsg(
'sd_browsedata_filterbysubcategory' ) . '" style="font-size: ' . $font_size .
'px">' . $filter_text . '</a>';
} else {
$results_line .= "\n
" . '<a href="' . $filter_url . '" title="' . wfMsg(
'sd_browsedata_filterbysubcategory' ) . '">' . $filter_text . '</a>';
--
To view, visit https://gerrit.wikimedia.org/r/64925
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ic6a7f38063d60b1b611a263a8e7f2a27e9f494a8
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/SemanticDrilldown
Gerrit-Branch: master
Gerrit-Owner: Yaron Koren <[email protected]>
Gerrit-Reviewer: Yaron Koren <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits