d2jsp
Log InRegister
d2jsp Forums > d2jsp > General Help > Site Suggestions >
Poll > Fg Chart
123Next
Add Reply New Topic New Poll
  Guests cannot view or vote in polls. Please register or login.
Member
Posts: 3,028
Joined: Mar 23 2016
Gold: 7,568.50
Apr 26 2016 09:41am
Hey guys,

I was looking at my gold logs when I noticed it was all done in javascript, which gave me the idea to make a bookmarklet (a bookmark that runs javascript code) to make a chart of my FG going up and down, since it's easier to quickly see trends and how I'm doing "financially". An extension might have been a better proof of concept but it's also much harder to make it compatible with different browsers, installation is more complicated etc.

I'm done with the bookmarklet now, and since I like using it I thought maybe others would too, so that maybe the concept of a fg chart below the gold logs could be incorporated into the site.

It looks something like this:



In reality it's a bit more interactive than that, you can hover over each data point and see the precise date/fg value. The background is transparent so that it should look reasonably good with any theme.

Here's the code for anyone worried about viruses or whatever, although warning it's a bit messy and needs cleaning up/comments: http://pastebin.com/yqH1EqZ0

All it does is read the gold value & date from the current javascript array used for gold logs, sorts them by date, then chart it using Google charts. There's a ton of javascript charting libraries out there, I chose google's because it's simple to use and reliable but obviously it's debatable which library should be used if any should this make it to the real site.

Compressed for the bookmarklet:

To try it yourself, go to this JSFiddle link: OLDLINK and move the link named "FG Chart" to your bookmarks bar, then click on it when you're viewing your gold logs. I've tested it with IE and Vivaldi so far but seeing as it uses Google Charts I'm pretty sure it is compatible with most browsers.

That's it, thanks for reading this far and maybe trying it. Any feedback is appreciated!

Edit: Updating code:
Added a button to switch between monthly & cumulative view.

Code: http://pastebin.com/c0eeVemX

Bookmarklet: https://jsfiddle.net/1snyk7eb/1/

And a quick demo:

Admin
Posts: 24,860
Joined: Sep 24 2002
Gold: 38,082.77
Trader: Trusted
Apr 26 2016 01:09pm
That's pretty neat! I don't have any plans to directly implement something like this, but really like what you've made. I will continue to look into what I can do about opening things up a bit more to allow creative extensions like this to be enabled by users.
Trade Moderator
Posts: 27,985
Joined: Dec 20 2005
Gold: 149,175.00
Trader: Trusted
Apr 26 2016 01:21pm
Quote (njaguar @ Apr 26 2016 09:09pm)
That's pretty neat! I don't have any plans to directly implement something like this, but really like what you've made. I will continue to look into what I can do about opening things up a bit more to allow creative extensions like this to be enabled by users.


That would be awesome Paul :)

@topic , I liked the idea, got my yes :)
Member
Posts: 3,028
Joined: Mar 23 2016
Gold: 7,568.50
Apr 26 2016 01:27pm
Quote (njaguar @ Apr 26 2016 08:09pm)
That's pretty neat! I don't have any plans to directly implement something like this, but really like what you've made. I will continue to look into what I can do about opening things up a bit more to allow creative extensions like this to be enabled by users.


Awesome, thanks for the swift answer! I think that could pave the way for all sorts of fun scripts, whether they deal with charts/statistics or otherwise. I will continue to work on this and clean up the code for my own use in the meantime if that's OK :)
Jr Admin
Posts: 18,950
Joined: Aug 11 2011
Gold: 33,141.07
Trader: Mediator
Apr 26 2016 01:28pm
Looks like a tool that could come in handy, especially to those trading a lot and have a huge transaction history per month.

Great initiative OP!
Member
Posts: 124,795
Joined: May 2 2009
Gold: 89,253.64
Apr 26 2016 01:35pm
really nice
would it be possible to make one that includes every month since the beginning of time?
Member
Posts: 16,653
Joined: Jun 22 2010
Gold: 21,065,165.32
Apr 26 2016 02:29pm
Quote (Cheetos @ Apr 26 2016 09:35pm)
really nice
would it be possible to make one that includes every month since the beginning of time?


Based on how it's currently written it shouldn't be possible. It basically just reads the gold log's javascript array for the page (month) you're on.

However, you could store old daily/monthly logs in a data table and use that to draw the graph unless there's a way to access all of your gold logs at once which would obviously make it a lot easier and also "doable" with the current script. ;)

@OP
I really like your idea.

This post was edited by Platine on Apr 26 2016 02:31pm
Member
Posts: 14,128
Joined: Feb 11 2007
Gold: 81,707.28
Apr 26 2016 02:58pm
Yes

Quote (Cheetos @ Apr 26 2016 03:35pm)
really nice
would it be possible to make one that includes every month since the beginning of time?


And yes
Admin
Posts: 24,860
Joined: Sep 24 2002
Gold: 38,082.77
Trader: Trusted
Apr 26 2016 06:20pm
Quote (Platine @ Apr 26 2016 03:29pm)
Based on how it's currently written it shouldn't be possible. It basically just reads the gold log's javascript array for the page (month) you're on.

However, you could store old daily/monthly logs in a data table and use that to draw the graph unless there's a way to access all of your gold logs at once which would obviously make it a lot easier and also "doable" with the current script. ;)

@OP
I really like your idea.


Right, the script could easily just store and cache a month in a localStorage or IndexedDB, then use that to display more than the current month's data. It would still require you to manually go back through each month, at least once (to build your local cache), but yeah, it's possible to do it.
Retired Moderator
Posts: 14,142
Joined: Oct 16 2009
Gold: 50.00
Trader: Trusted
Apr 26 2016 06:25pm
You've only been here a month and already suggesting a pretty cool idea. I have a good feeling about you mate.

You have my yes ^_^
Go Back To Site Suggestions Topic List
123Next
Add Reply New Topic New Poll