Convert length of time to percentages nvd3

I am looking for leads on how to convert time based events from seconds to hours into percentages which can be displayed properly on nvd3 graphs.

The problem currently is that when using a time based scale, the Y axis either dynamic or static, does not show all of the data properly.
For example, there are events which are 2 seconds long while there are others which are a few hours long. When putting both on the same scale, one ends up either being so small that it cannot be seen or so large that it just shows a huge bar on the graph.

Therefore, we need to convert the time based events to percentages so that a Y axis could work. Then users could mouse over each event to get finer details.

I am not the programmer, I am only looking for leads or input on how this could be done by others who may have done something similar.

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Can you please show us some test data so we can see what we're working with? Thanks.

projectsAuthor Commented: 2014-09-24

Test data such as?
The data is time based events, so when you look at the database, you'll see

start_time
2014-09-11 18:58:12

and

end_time
2014-09-11 18:58:14

As you can see, the above is 2 seconds. The data is just that, but the time can range between seconds to hours.

Using nvd3, we need to show each of these events in a graph but since the range is go great, the data is not showing up very well as explained in my question. The answer seems to be to convert the time based events into percentages so they can be displayed on a graph properly.

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

I don't know any of these things, that's why I posted all of the info I have.
What I can tell you is that the range can be from seconds to hours.
That kind of data doesn't display on a graph so I need to find some alternative way to show this data on a graph.
One lead was using a logarithmic scale which lead to the idea of converting the time based output to percentages instead.

In terms of what to use for percentages, I don't know and is why I posted this question, to get some idea of how others may have dealt with something like this.

Here is how you might deal with it. Take all of your data and find the largest timespan. Let that equal 100%, then divide that timespan into all the other data (and multiply by 100) to get a percentage.

Here is another way to deal with it. Set an arbitrary upper limit, say 1 hour to represent 100%, then divide that timespan into all the other data (and multiply by 100) to get a percentage. This will allow for percentages greater than 100.

You could also set a lower limit, etc. The key is to decide what will give you a meaningful visual display.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

there are events which are 2 seconds long while there are others which are a few hours long

I think you need to use a logarithmic scale. You can use JavaScript's Math.log(y) method. I created the simplest demonstration code possible with HTML5 canvas. It assumes that you can convert your data into the number of seconds for each event.

It isn't completed yet but it shows that this was doable. There is a range of 2 seconds to 5 hours on this chart. Amazingly, everything shows just as it should. When the user mouses over any bar, the details show up in an info bubble so this works nicely.

For each duration, we have used the function Math.log
We return a number between 0 and 10
So, our Y axis has a range of 0 to 10

@rrz; There is no actual relation, it's just a representation of time, as a percentage so that it can be displayed as it is. Otherwise, the 5 hour event for example would be nothing but a huge red bar on the screen. Or I'm not understanding your question.

@ray; I'm sure I can share the code but it's not done yet, including the labels.
I'll revisit this question once it's done.

However, once everything is done, gone over, good as can be, it may very well all end up being open source, free to use. I'm not sure how that will work just yet however. Lots to figure out.