Scrobble Graph profiles show quite a bit of information on the listening habits of the user, however it lacks some graphs showing the amount of scrobbles over time. I know there’s a handful of websites out there that have all kinds of graphs and can show you detailed information on most every aspect of your library. However, I wanted to implement my own graph generator, one that didn’t have minutes of queue waiting.

At the moment my generator has two options, one where you can see your scrobbles over the course of weeks, months or even years and, if you want, compare it with another user. The other feature I added just recently, the Artist Scrobble History, shows you how many tracks by a particular artist you’ve scrobbled over time, again, you can also compare data between two users.

Because’s API probably uses flood control and limits the requests, pulling data from their servers can take up some time, especially if it’s a lot of data (e.g. request a year’s worth) so I added database caching which speeds up the process a lot if you want to review earlier requested information. Currently the form will also auto complete artist names, granted, its implementation is not exactly great as it just pulls already cached names from the cache database rather than from’s one. I could use the API’s artist search function but then I’d be stuck with the slow requests again.

Next up is AJAXification of the page, rather than page reloads I’d like the data to be pulled in with AJAX, if it takes a while a loading icon can be displayed and once all the information is downloaded the chart can be presented. All this will force me to refactor a whole lot of the code though. Rather than having a couple of functions and some procedural function calls which in the end result in the javascript getting the appropriate data I’ll need to make it so the arrays of data are returned with JSON encoding whenever the page is requested, that way the data can be handed to the ‘main’ page’s javascript which in turn can generate the graph.

I first tried the lazy way, copying all the generation code into a separate file and have AJAX pull that in, however since the JS wasn’t executed the chart wasn’t drawn and you didn’t see anything. So I had to use the eval() function for it to work. I’ve read that’s not really a great idea so even though it works this way, I’ll make a better, less hack-y version sometime.

In the future I might add another feature that plots how your genre listening habits have changed. If you have any other ideas feel free to post them in the comments and I’ll see if they can be added as well.