Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
0 Members and 1 Guest are viewing this topic.

Statistics-Framework-SMP

2022-06-21 21:10:55

A helper script for Spider Monkey Panel and foobar2000 which allows to easily create customizable charts on demand, applying basic filtering, sorting and distribution settings.

Helper meant mostly for coders not for final users, although it may be easily included on any script (don't expect how to's by my side apart from these instructions).

Features
• Create charts: bars, scatter, line.
• Colors, axis, background, margins, labels and points are customizable.
• Data may be filtered, sorted or sliced on the fly.
• Data may be fit to a distribution or shown 'as is' (with selected sorting).
• Multiple series can be drawn on the same chart.

Usage
First create the chart object. In this case 2 series are added:
Code: [Select]
`const chart = new _chart({	data: [		[{x:'A', y: 10},{x:'B', y: 4},{x:'C', y: 6},{x:'D', y: 7},{x:'E', y: 3}], 		[{x:'A', y: 3},{x:'B', y: 7},{x:'C', y: 4},{x:'D', y: 2},{x:'E', y: 5}]	],	dataManipulation: {sort: null, filter: null, slice: null, distribution: null},	background: {color: RGB(200,200,200)},	margin: {left: _scale(20), right: _scale(10), top: _scale(10), bottom: _scale(15)},	axis: {		x: {show: true, color: RGB(0,0,0), width: _scale(2), ticks: 'auto', labels: true, key: 'Cities'}, 		y: {show: true, color: RGB(0,0,0), width: _scale(2), ticks: 5, labels: true, key: 'Population'}	},	x: 0,	w: window.Width,	y: 0,	h: window.Height,	tooltipText: '\n\n(This is additional info)'});`

Then, you may want to associate it to the panel callbacks for painting, resizing, mouse...:
Code: [Select]
`function on_paint(gr) {	if (!window.Width || !window.Height) {return;}	chart.paint(gr);}function on_size() {	const w = window.Width;	const h = window.Height;	const x = 0;	const y = 0;	if (!w || !h) {return;}	chart.changeConfig({x, y, w, h});}function on_mouse_move(x, y, mask) {	chart.move(x,y);}function on_mouse_leave(x, y, mask) {	chart.leave();};`

Code: [Select]
`include('helpers\\statistics_xxx_menu.js'); // menu_xxx.js must also be present!bindMenu(chart);function on_mouse_rbtn_up(x, y) {	chart.rbtn_up(x,y);	return true; // left shift + left windows key will bypass this callback and will open default context menu.}`

There are more usage examples on the 'examples' folder.

Installation
Since the framework only requires 1 file, i.e. the main one, you can simply include it along any other script where you will use the charts. The helpers will be loaded automatically.

When using the extra menus, the menu framework file must be present too.

https://github.com/regorxxx/Statistics-Framework-SMP

Re: Statistics-Framework-SMP

Plan to continue work on it with more chart types and distributions, anyway 'as is' should be handy for people who want to compute Last.FM , playback or library tag stats, etc.

The examples folder contains some scripts to compute graphs for genre (first chart) or style (second) tags for ex, while there is another one to show the most played artists (third chart). See first gif.

Obviously chart config should be saved somewhere (properties or json) to reload it between sessions.

Re: Statistics-Framework-SMP

Plan to continue work on it with more chart types and distributions, anyway 'as is' should be handy for people who want to compute Last.FM , playback or library tag stats, etc.

Wow, I've been hoping for something like this for years! Will take some time before I can dig in, but will share whatever I come up with if it's useful.

btw, not sure if you're aware of this?
https://github.com/apexcharts

Re: Statistics-Framework-SMP

Thing is we can't use standard js libraries within foobar since UI methods to draw things (strings, etc.) are restricted to those provided by SMP. So most fancy libraries out there need to be manually re-coded.

But the code logic for the data may be used, yep. And I may implement some of those charts styles/types, they look good.

I plan to do "something" with the framework, right now there are a few examples which use actual data from user's library; but my idea is implementing interactive charts which may be associated to customizable TitleFormat expressions. Also providing yearly reports like Spotify or MusicBrainz do.

Btw right now the colors are randomly set if they are not set manually (in case some color is too dark or light, just reload the panel).

Re: Statistics-Framework-SMP

The examples folder contains some scripts to compute graphs for genre (first chart) or style (second) tags for ex, while there is another one to show the most played artists (third chart).

FYI, example 1 loaded fine, but ex. 2+3 gave same error:

Code: [Select]
`Error: Spider Monkey Panel v1.6.1 (Statistics example 2: Statistics example 2 v1.0.0 by XXX)DrawLine failed:GdiPlus error: DrawLine failed with error (0xb): ValueOverflowFile: statistics_xxx.jsLine: 202, Column: 8Stack trace:  _chart/this.paintGraph/<@statistics_xxx.js:202:8  _chart/this.paintGraph@statistics_xxx.js:200:10  _chart/this.paint@statistics_xxx.js:254:8  on_paint/<@02_statistics.js:159:35  on_paint@02_statistics.js:159:9`