Neue Visualisierung für die Piwik Browsers-Statistik

After writing down my latest ideas for better Piwik visualizations, I just couldn’t wait to see them in action. Since the Open Flash Chart library doesn’t support multi-level pie charts I decided to create the visualization from scratch. The initial version (0.1) took me about two hours coding.

In the following image you can compare the hierarchical pie visualization (top) with the current pie visualization (bottom).

I named the plugin UserSettingsExt as it extends the current UserSettings plugin. You can download it from the Piwik Developer Zone to test it on your own Piwik installation.

Changelog

  • 0.1 – basic pie chart drawing, label placement.
  • 0.2 – added standard piwik tooltips
  • 0.3 – added automatic resizing

If you don’t want to miss any updates, you can subscribe to the plugins rss-feed at the Piwik Developer Zone.

Feedback welcome.

After writing down my latest ideas for better Piwik visualizations, I just couldn’t wait to see them in action. Since the Open Flash Chart library doesn’t support multi-level pie charts I decided to create the visualization from scratch. The initial version (0.1) took me about two hours coding.

In the following image you can compare the hierarchical pie visualization (top) with the current pie visualization (bottom).

I named the plugin UserSettingsExt as it extends the current UserSettings plugin. You can download it from the Piwik Developer Zone to test it on your own Piwik installation.

Changelog

  • 0.1 – basic pie chart drawing, label placement.
  • 0.2 – added standard piwik tooltips
  • 0.3 – added automatic resizing

If you don’t want to miss any updates, you can subscribe to the plugins rss-feed at the Piwik Developer Zone.

Feedback welcome.


Flattr this

Further Ideas For Piwik Visualization Improvements

In this post I want to present two ideas for improvements to the current Piwik visualizations.

Screen resolution stats

The first idea is about improving the screen resolution charts. Here is an example for the current available visualizations in Piwik:

The current charts (pie,bar) aren’t quite applicable to get an useful overview about the visitors screen resolutions. Both charts are limited to a few big values and combine all other values in the “others” element. This can lead to wrong interpretation of the data, since there might be many different screen sizes. In the example nearly the half of the sites visitors have screen resolutions that arent’ displayed in the charts.

The obvious reason is that pie and bar charts are made for simple, one-dimensional data sets but the number of visits per screen resolution is a perfect representative of two-dimensional data sets. The two dimensions are obviously the screen width and the screen height. One of the simplest yet best visualization type to display two-dimensional data sets is the scatter plot. You can see the difference in no time by looking at the following prototype. In my opinion, this is the only way to make the screen resolution stats usable.

Browser statistics

My second idea is about the browser statistic charts. Again, there is only limited use to the currently provided charts.

The chart shows data of multiple browsers in multiple versions. Each combination of browser and value is treated as a distinct value and hence is shown in a unique color. The main problem of the current visualizations is (again) that the data is treated as one-dimensional. The data is in fact a hierarchical data set: the first layer is the browser layer which contains the sub-layer browser versions. One way of making a visualization more useable is to decrease the complexity, which can be done by only showing the browser level.

The visualization now clearly shows the information that is asked by most of the Piwik users: Which browsers are used by the visitors of my website? Some users might also want to know more details about the different browser versions, so there is a link to an second view that shows all browser versions.

Feedback welcome..

Ansatz zur automatischen Auswahl von Linienfarben in Diagrammen

Ein Problem bei der (automatischen) Erzeugung von Liniendiagrammen liegt in der Auswahl von unterscheidbaren Farben. In diesem Artikel wird ein Ansatz entwickelt, der dieses Problem lösen soll.

Ausgangspunkt ist zunächst der RGB-Farbraum. Um verschiedene Farben zu erzeugen, können einfach zufällige Farben aus dem RGB-Raum ausgewählt werden. Die folgende Darstellung zeigt eine derart getroffene Auswahl von zehn verschiedenen Linienfarben (rechtsklicken um neue Zufallsfarben zu erzeugen):

Die Nachteile dieses Ansatzes sind offensichtlich und sind vor allem auch Nachteile des Farbmodells. Selbst eine gleichverteilte Auswahl von Farben im RGB-Raum würde mitunter zu nahezu identischen Farben führen. Daher habe ich mich im Folgenden auf den HSL-Farbraum konzentriert. Wie alle wahrnehmungsorientierten Farbräume enthält auch der HSL-Raum die Dimension Farbwert – ein Wert zwischen 0° und 360° der den Farbton bestimmt. Die folgende Darstellung zeigt die Auswahl von 10 Farben mit gleichem Abstand im Farbraum (in diesem Fall 36°):

Wie man sieht bekommt man dadurch 10 Ausschnitte aus dem Regenbogenspektrum. Bei genauerem Hinsehen fallen aber immer noch Nachteile auf: So sind vor allem die beiden Grün- und Blautöne schwer voneinander zu unterscheiden. Um eine mögliche Ursache dafür zu nennen mache ich einen kurzen Ausflug zur Wahrnehmungspsychologie. Auf unserer Netzhaut befinden sich zwei Typen von Rezeptorzellen, die sog. Stäbchen und Zapfen. Während die Stäbchen vor allem zum Sehen in der Dämmerung benutzt werden, dienen Zapfen zum Farbsehen. Nun gibt es unter den Zapfen-Zellen wiederum drei verschiedene Typen, wovon jeder zur Wahrnehmung bestimmter Farbfrequenzen geeignet ist. Um die Sache kurz zu machen, es gibt jeweils einen Zapfentyp für rote, grüne und blaue Farbfrequenzen. Und jetzt kommts: die Verteilung der Zapfenzellen ist in etwa 10:1:1 (rot zu grün zu blau). Daher fällt es Menschen naturgemäß leichter, Rottöne voneinander zu unterscheiden als Blau- oder Grüntöne.

Ich habe versucht, diesen Umstand über eine Transferfunktion für die Farbtöne auszugleichen. Die folgende Abbildung zeigt oben einen Farbwertverlauf ohne und unten mit Korrektur. Wie man sehen kann, habe ich einfach den Bereich für grüne und blaue Farbtöne “zusammengedrückt”, um mehr Spielraum zwischen Rot und Gelb zu bekommen.

oben: normaler HSL-Verlauf, unten: HSL-Verlauf mit Farbtonkorrektur

oben: normaler HSL-Verlauf, unten: HSL-Verlauf mit Farbtonkorrektur

Wählt man die 10 Zufallsfarben nun aus diesem, korrigierten Spektrum, erhält man folgendes Resultat:

Die Farbtonkorrektur hat etwas zur Unterscheidbarkeit der grünen und blauen Linien beigetragen. Für den günstigen Fall, das die Linienhelligkeit keine weitere Bedeutung in der Visualisierung hat, kann man die Unterscheidbarkeit der Linien weiter steigern, indem man abwechselnd helle und dunkle Linien verwendet:

Zur Erzeugung der Abbildungen habe ich die ActionScript-Klasse PerceptualColor verwendet. Die Farbwertkorrektur wird über die folgende Klasse HueCorrection gelöst. Ein- und Ausgabe für die Funktion correctHue ist ein Farbwinkel zwischen 0 und 360°.

public class HueCorrection
{
	private static var _tf:Array = [
		[10,5], [30,45], [50,70],
		[70,94], [110,100], [125,115],
		[145,148],[161,174], [182,179],
		[188,185],
		[210,225], [250,255]
	];
 
	public static function correctHue(hue:Number):Number {
		var h:uint = hue / 360 * 255;
		var new_hue:Number;
		var lx:Number = 0;
		var ly:Number = 0;
 
		for (var i:uint=0; i<_tf.length; i++) {
			if (h == _tf[i][1]) {
				new_hue = _tf[i][0];
				break;
			} else if (h < _tf[i][1]) {
				new_hue = lx + ((_tf[i][0] - lx) / (_tf[i][1] - ly)) * (h - ly);
				break;
			}
			lx = _tf[i][0];
			ly = _tf[i][1];
		}
		return new_hue / 255 * 360;
	}
}