diff options
author | Thomas Steur <thomas.steur@gmail.com> | 2016-08-29 07:01:46 +0300 |
---|---|---|
committer | Thomas Steur <thomas.steur@gmail.com> | 2016-08-29 07:01:46 +0300 |
commit | 4c9d1274408fb57d5e0b53dcda425dc4892c7b00 (patch) | |
tree | 78b0f24058d586cdd109de0387d43165e112003e /plugins/UserCountryMap/javascripts | |
parent | 0c9c30b731ccbacf47e154b9f7a590af49e3d799 (diff) | |
parent | 4b395d2385e0041973349c7575fc10378b85558e (diff) |
Merge branch 'master' into 3.0-m06
Conflicts:
.travis.yml
bower.json
core/Notification/Manager.php
core/Updates.php
core/Updates/2.16.2-b2.php
core/Version.php
libs/Zend/Validate/Hostname.php
libs/bower_components/jScrollPane/ajax.html
libs/bower_components/jScrollPane/anchors.html
libs/bower_components/jScrollPane/api.html
libs/bower_components/jScrollPane/arrow_hover.html
libs/bower_components/jScrollPane/arrow_positions.html
libs/bower_components/jScrollPane/arrows.html
libs/bower_components/jScrollPane/auto_reinitialise.html
libs/bower_components/jScrollPane/basic.html
libs/bower_components/jScrollPane/caps.html
libs/bower_components/jScrollPane/changelog.html
libs/bower_components/jScrollPane/destroy.html
libs/bower_components/jScrollPane/drag_size.html
libs/bower_components/jScrollPane/dynamic_content.html
libs/bower_components/jScrollPane/dynamic_height.html
libs/bower_components/jScrollPane/dynamic_width.html
libs/bower_components/jScrollPane/events.html
libs/bower_components/jScrollPane/faqs.html
libs/bower_components/jScrollPane/fixed_width.html
libs/bower_components/jScrollPane/focus.html
libs/bower_components/jScrollPane/fullpage_scroll.html
libs/bower_components/jScrollPane/iframe.html
libs/bower_components/jScrollPane/iframe2.html
libs/bower_components/jScrollPane/iframe_content1.html
libs/bower_components/jScrollPane/iframe_content2.html
libs/bower_components/jScrollPane/image.html
libs/bower_components/jScrollPane/image2.html
libs/bower_components/jScrollPane/index.html
libs/bower_components/jScrollPane/invisibles.html
libs/bower_components/jScrollPane/known_issues.html
libs/bower_components/jScrollPane/less_basic.html
libs/bower_components/jScrollPane/mwheel_intent.html
libs/bower_components/jScrollPane/override_animate.html
libs/bower_components/jScrollPane/runeimp.html
libs/bower_components/jScrollPane/runeimp2.html
libs/bower_components/jScrollPane/scroll_on_left.html
libs/bower_components/jScrollPane/scroll_to.html
libs/bower_components/jScrollPane/scroll_to_animate.html
libs/bower_components/jScrollPane/settings.html
libs/bower_components/jScrollPane/short.html
libs/bower_components/jquery/.bower.json
libs/bower_components/jquery/LICENSE.txt
libs/bower_components/jquery/dist/jquery.js
libs/bower_components/jquery/dist/jquery.min.js
libs/bower_components/jquery/dist/jquery.min.map
libs/bower_components/jquery/sizzle/dist/sizzle.js
libs/bower_components/jquery/src/ajax.js
libs/bower_components/jquery/src/ajax/jsonp.js
libs/bower_components/jquery/src/ajax/load.js
libs/bower_components/jquery/src/ajax/parseJSON.js
libs/bower_components/jquery/src/ajax/parseXML.js
libs/bower_components/jquery/src/ajax/script.js
libs/bower_components/jquery/src/ajax/xhr.js
libs/bower_components/jquery/src/attributes/attr.js
libs/bower_components/jquery/src/attributes/classes.js
libs/bower_components/jquery/src/attributes/prop.js
libs/bower_components/jquery/src/attributes/support.js
libs/bower_components/jquery/src/attributes/val.js
libs/bower_components/jquery/src/callbacks.js
libs/bower_components/jquery/src/core.js
libs/bower_components/jquery/src/core/access.js
libs/bower_components/jquery/src/core/init.js
libs/bower_components/jquery/src/core/parseHTML.js
libs/bower_components/jquery/src/core/ready.js
libs/bower_components/jquery/src/css.js
libs/bower_components/jquery/src/css/curCSS.js
libs/bower_components/jquery/src/css/hiddenVisibleSelectors.js
libs/bower_components/jquery/src/css/support.js
libs/bower_components/jquery/src/css/var/swap.js
libs/bower_components/jquery/src/data.js
libs/bower_components/jquery/src/data/accepts.js
libs/bower_components/jquery/src/deferred.js
libs/bower_components/jquery/src/deprecated.js
libs/bower_components/jquery/src/dimensions.js
libs/bower_components/jquery/src/effects.js
libs/bower_components/jquery/src/effects/Tween.js
libs/bower_components/jquery/src/event.js
libs/bower_components/jquery/src/event/support.js
libs/bower_components/jquery/src/manipulation.js
libs/bower_components/jquery/src/manipulation/support.js
libs/bower_components/jquery/src/offset.js
libs/bower_components/jquery/src/queue.js
libs/bower_components/jquery/src/serialize.js
libs/bower_components/jquery/src/traversing.js
libs/bower_components/jquery/src/traversing/findFilter.js
libs/bower_components/jquery/src/var/concat.js
libs/bower_components/jquery/src/var/indexOf.js
libs/bower_components/jquery/src/var/push.js
libs/bower_components/jquery/src/var/slice.js
libs/bower_components/jquery/src/wrap.js
plugins/API/ProcessedReport.php
plugins/AnonymousPiwikUsageMeasurement
plugins/CoreConsole/Commands/ManagePlugin.php
plugins/CoreHome/javascripts/dataTable.js
plugins/CoreHome/javascripts/manifest.json
plugins/CoreHome/templates/_topBar.twig
plugins/CoreUpdater/templates/updateSuccess.twig
plugins/CustomAlerts
plugins/CustomDimensions
plugins/DevicesDetection/Reports/GetBrowserVersions.php
plugins/DevicesDetection/Reports/GetBrowsers.php
plugins/ExamplePlugin/Updates/0.0.2.php
plugins/Feedback/templates/index.twig
plugins/LogViewer
plugins/Morpheus/stylesheets/general/_forms.less
plugins/Morpheus/templates/layout.twig
plugins/Morpheus/templates/user.twig
plugins/QueuedTracking
plugins/SegmentEditor/stylesheets/segmentation.less
plugins/SitesManager/tests/Integration/ApiTest.php
tests/PHPUnit/Integration/WidgetsListTest.php
tests/PHPUnit/System/expected/test_ManyVisitorsOneWebsiteTest_sortByProcessedMetric__API.getProcessedReport_day.xml
tests/PHPUnit/System/expected/test_OneVisitorTwoVisits_hideColumns___API.getProcessedReport_day.xml
tests/PHPUnit/System/expected/test_OneVisitorTwoVisits_showColumns___API.getProcessedReport_day.xml
tests/PHPUnit/System/expected/test_TwoVisitors_twoWebsites_differentDays_scheduled_report_in_csv__ScheduledReports.generateReport_month.original.csv
tests/PHPUnit/System/expected/test_TwoVisitors_twoWebsites_differentDays_scheduled_report_in_html_tables_only__ScheduledReports.generateReport_month.original.html
tests/PHPUnit/System/expected/test_apiGetReportMetadata__API.getReportMetadata_day.xml
tests/PHPUnit/System/expected/test_ecommerceOrderWithItems_scheduled_report_in_csv__ScheduledReports.generateReport_week.original.csv
tests/PHPUnit/System/expected/test_ecommerceOrderWithItems_scheduled_report_in_html_tables_only__ScheduledReports.generateReport_week.original.html
tests/UI/expected-ui-screenshots
tests/UI/specs/SegmentSelectorEditor_spec.js
Diffstat (limited to 'plugins/UserCountryMap/javascripts')
-rw-r--r-- | plugins/UserCountryMap/javascripts/visitor-map.js | 86 |
1 files changed, 66 insertions, 20 deletions
diff --git a/plugins/UserCountryMap/javascripts/visitor-map.js b/plugins/UserCountryMap/javascripts/visitor-map.js index b6a1a24d51..07b5710259 100644 --- a/plugins/UserCountryMap/javascripts/visitor-map.js +++ b/plugins/UserCountryMap/javascripts/visitor-map.js @@ -48,7 +48,8 @@ specialMetricsColorScale = colorManager.getColors( 'visitor-map', ['special-metrics-color-scale-1', 'special-metrics-color-scale-2', 'special-metrics-color-scale-3', - 'special-metrics-color-scale-4'] + 'special-metrics-color-scale-4'], + true ), countryHighlightColor = colors['country-highlight-color'], countrySelectedColor = colors['country-selected-color'], @@ -139,11 +140,34 @@ }; } - function formatNumber(v) { + function formatNumber(v, metric, first) { v = Number(v); - return v > 1000000 ? (v / 1000000).toFixed(1) + 'm' : - v > 1000 ? (v / 1000).toFixed(1) + 'k' : - v; + + if (v > 1000000) { + return (v / 1000000).toFixed(1) + 'm'; + } + + if (v > 1000) { + return (v / 1000).toFixed(1) + 'k'; + } + + if (!metric) { + return v; + } + + if (metric == 'avg_time_on_site') { + v += first ? ' sec' : 's'; + } else if (metric == 'bounce_rate') { + v += '%'; + } else if (metric === 'nb_actions_per_visit') { + if (parseInt(v, 10) === v) { + return v; + } + + return v.toFixed(1); + } + + return v; } // @@ -197,13 +221,7 @@ function addLegendItem(val, first) { var d = $('<div>'), r = $('<div>'), l = $('<div>'), metric = $$('.userCountryMapSelectMetrics').val(), - v = formatNumber(Math.round(val)); - - if (metric == 'avg_time_on_site') { - v += first ? ' sec' : 's'; - } else if (metric == 'bounce_rate') { - v += '%'; - } + v = formatNumber(Math.round(val), metric, first); d.css({ width: 17, height: 17, float: 'left', background: colscale(val) }); l.css({ 'margin-left': 20, 'line-height': '20px', 'text-align': 'right' }).html(v); @@ -245,7 +263,7 @@ if (id.length == 3) { c = (stats.p90 - stats.min) / (stats.max - stats.min); colscale = chroma.scale(specialMetricsColorScale, [0, c, c + 0.001, 1]) - .domain(chroma.limits(rows, 'c', 5, 'curMetric', filter)) + .domain(chroma.limits(rows, 'c', 5, 'curMetric', filter), 4, 'c') .mode('hsl'); } } @@ -464,7 +482,7 @@ $('.map-stats').html(formatValueForTooltips(UserCountryMap.countriesByIso[id], metric, 'world')); } else { $('.map-stats').html( - _.nb_visits.replace('%s', '<strong>' + formatNumber(totalVisits) + '</strong>') + (id != 'world' ? ' (' + + _.nb_visits.replace('%s', '<strong>' + formatNumber(totalVisits, metric) + '</strong>') + (id != 'world' ? ' (' + formatPercentage(totalVisits / worldTotalVisits) + ')' : '') ); } @@ -887,12 +905,11 @@ $.each(cities, function (i, city) { sumArea += isNaN(city.curMetric) ? 0 : Math.pow(radscale(city.curMetric), 2); }); + maxRad = Math.sqrt(area * f[metric] / sumArea); radscale = $K.scale.sqrt(cities.concat({ curMetric: 0 }), 'curMetric').range([2, maxRad + 2]); - var is_rate = metric.substr(0, 3) != 'nb_' || metric == 'nb_actions_per_visit'; - var citySymbols = map.addSymbols({ type: $K.LabeledBubble, data: cities, @@ -902,7 +919,26 @@ tolerance: 0 }, title: function (d) { - return radscale(d.curMetric) > 10 ? formatNumber(d.curMetric) : ''; + var v = d.curMetric; + if (isNaN(v)) { + return ''; + } + + if (metric === 'bounce_rate') { + v = Number((''+ v).replace('%', '')); + } else if (metric === 'avg_time_on_site') { + v = Number(v); + } + + if (isNaN(v)) { + return ''; + } + + if (radscale(v) > 10) { + return formatNumber(d.curMetric, metric); + } + + return ''; }, labelattrs: { fill: cityLabelColor, @@ -912,7 +948,7 @@ }, filter: function (d) { if (isNaN(d.lat) || isNaN(d.long)) return false; - return is_rate ? d.nb_visits > 5 && d.curMetric : d.curMetric; + return !!d.curMetric && d.curMetric !== '0'; }, aggregate: function (rows) { var row = aggregate(rows); @@ -927,14 +963,24 @@ }, sortBy: 'radius desc', location: function (city) { return [city.long, city.lat]; }, - radius: function (city) { return radscale(city.curMetric); }, + radius: function (city) { + var scale = radscale(city.curMetric); + if (isNaN(scale)) { + return 0.01; + } + return scale; + }, tooltip: function (city) { return '<h3>' + city.city_name + '</h3>' + formatValueForTooltips(city, metric, iso); }, attrs: function (city) { + var color = colscale(city.curMetric); + if (color && color.hex) { + color = color.hex(); + } return { - fill: colscale(city.curMetric).hex(), + fill: color, 'fill-opacity': 0.7, stroke: cityStrokeColor, cursor: 'pointer' |