Skip to content

Commit

Permalink
using lightness for highlighting highly engaged users
Browse files Browse the repository at this point in the history
  • Loading branch information
gka authored and halfdan committed Feb 20, 2013
1 parent c5b81fe commit 25b0e70
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions plugins/UserCountryMap/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ function realtimeMap()
$view->defaultMetric = 'nb_visits';
$view->liveRefreshAfterMs = (int)Piwik_Config::getInstance()->General['live_widget_refresh_after_seconds'] * 1000;

$goals = Piwik_Goals_API::getInstance()->getGoals($idSite);
$site = new Piwik_Site($idSite);
$view->hasGoals = !empty($goals) || $site->isEcommerceEnabled();

// some translations
$view->localeJSON = json_encode(array(
'nb_actions' => Piwik_Translate('VisitsSummary_NbActionsDescription'),
Expand Down
7 changes: 3 additions & 4 deletions plugins/UserCountryMap/js/realtime-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@
* unless you type Shift+Alt+C
*/
function visitColor(r) {
var col;
var col,
engaged = self.config.siteHasGoals ? r.goalConversions > 0 : r.actions > 4;
if (colorMode == 'referrerType') {
col = ({
website: '#F29007',
Expand All @@ -178,9 +179,8 @@
// defu
else col = chroma.hsl(
42 * age(r), // hue
//engaged ? 42 : 20 * age(r) + 10,
Math.sqrt(age(r)), // saturation
(r.actions > 3 ? 0.6 : 0.5) - (1-age(r))* 0.45 // lightness
(engaged ? 0.65 : 0.5) - (1-age(r))* 0.45 // lightness
);
return col;
}
Expand All @@ -189,7 +189,6 @@
* attributes of the map symbols
*/
function visitSymbolAttrs(r) {
var engaged = r.actions > 3;
return {
fill: visitColor(r).hex(),
'fill-opacity': Math.pow(age(r),2) * 0.8 + 0.2,
Expand Down
1 change: 1 addition & 0 deletions plugins/UserCountryMap/templates/realtime-map.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@
config._ = JSON.parse('{$localeJSON}');
config.reqParams = JSON.parse('{$reqParamsJSON}');
config.siteHasGoals = {$hasGoals};
var realtimeMap;
Expand Down

0 comments on commit 25b0e70

Please sign in to comment.