CartoDB Torque - using a start and end for each point - cartodb

I am trying to make an animated map using the torque from CartoDB.
I have about 8000 points, which I would like to show and hide following a 'period of validity'. Let's say for instance it shows data for one day; some points will be valid all day, others from midnight to 6am, others 4am to 8am, and so on and so forth. The torque would start at midnight, showing all the points valid at that time, then to 1am, removing and adding some, and so on until midnight.
In order to do that, I would like to set a start and an end time, but I cannot find any option for this. I saw the cumulative option, but then it would stay until the end of the animation, which is not exactly what I want.
Any suggestion would be welcomed, thanks!

The only thing it cames to me is repeating the records as many times as the time step you want on the animated map and assigning this new time as the torque animation field.
So if your torque steps every hour, and your point is valid for six, then you'll have one point per hour. To produce that query you'll probably need to use generate_series.

Related

Transposing two colums into rows of 4 each with a date sense checker - Google Sheets

I don't quite know how to word this.
I have a set of data which comes in two columns (essentially containers in storage or containers arriving soon)
I then take the two sets of data, and plug it into a "production schedule" using the below formula, only after I have added both unique columns into one workable column (seen in Column "O" or "Combined"). The formula which plots them into 4 workable slots per day is as follows:
=ArrayFormula(split(transpose(split(regexreplace(query(array_constrain(if(mod(row(O5:O), 4) = 2, "^", "|") & O5:O,max(row(O5:O) * (O5:O<> "")),1),,9^99), "^^",), "^", true, false)), "|", true, false))
For some unknown reason which I have yet to resolve, the above formula leaves a couple spaces instead of filling it with potential containers within the first couple of days, which I have yet to resolve.
The issue I have is that the above formula now plots for me each day I can work the containers, but it is not sense checking whether the containers will actually arrive in time for them to be worked in reality according to how the above formula is plotting them to be worked.
MY QUESTION:
How do I add to the above formula so that it also checks to make sure that the date it is automatically plotted in for "production" aligns with a 2 day logic test for the containers arrival. I.E. if the container is to arrive on the 10th September, logically it can only be worked from the 12th September, not on the 10th September or before the 10th September. If this check says it can only be worked later, then it should plot from the day it can be worked and then each container afterwards must be placed in a "production slot".
It also needs to take into consideration what is in storage first before plotting, but I think this is resolved with the unique formula I am using to adjust the plotting.
The sample sheet I am working off of:
https://docs.google.com/spreadsheets/d/1_niDFQtTcL9c3yROeh4qHmD_irBGbF066Pz2jEaQ674/edit?usp=sharing
Hope you can assist me here, this is a mammoth formula I am trying to plot to make a manual job substantially easier going forward.
Thanks in advance.

Highcharts: getting runtime durations on the yAxis

I run daily a job. Today, that job takes 1:45:09 hrs. I have a lot of such durations for that job from the past weeks and I want to be able to show that graphically using a simple column chart. On the Y axis I want duration ticks from 0:00:00 - 5:00:00 or so that I can easily compare the runtimes from the past weeks and see if the job is gradually taking longer and longer.
I have read and implemented a lot of answers from StackOverflow and other internet resources but none of them fit my purpose. When using unix timestamps (since 1970, etc) I get columns that are all of the same hight and Y-axis ticks in years instead of hours from 1970 to now.
Another option was to just calculate the minutes or seconds. Then the difference become appearant, but instead of time elements in the Y axis and tooltips I get integers.
Can someone show me how to achieve my goal in a fiddle? The question looks common enough to me for any monitoring software.
-- EDIT --
Here is a Photoshop sample of what I am trying to achieve:
On the Y-axis: a time scale. In the tooltip: date, objectname and time taken.
-- END EDIT --
BTW, I have no chart type preference. The usual column charts just seem to fit the purpose.
Thanks for any help!

Date histogram every half a month

How to write an interval that groups by every half a month? Rather than 1M I want something like 1/2M to group by from the first to the 16th and from the 16th to the end of the month, every month. Is there a way to do so?
I don't want to end up doing an interval on each day and then calculate manually my results as it's not clean and it would be resource hungry, is there a simple way to do so using setInterval? (in Elasticsearch or Elastica I don't care, I just want the algorithm behind it, thanks!)
$date_grp_agg = new \Elastica\Aggregation\DateHistogram('date');
$date_grp_agg->setField('date')->setFormat("MM-yy")->setInterval('1M'); // This one
Unfortunately, neither 0.5M (half month) nor 2w (2 weeks) are supported, but you could try to use a number of days, i.e. 15d.
$date_grp_agg->setField('date')->setFormat("MM-yy")->setInterval('15d');
Granted, it will not fit months perfectly, i.e. it won't start on the 1st and end on the last day of the month, but it can get you close to the kind of interval you're looking for.

Summing times in Google sheets

I have a sheet where I record my working hours (this is more for me to remind me to stop working than anything else). For every day, I have three possible shifts - early, normal & late, and I have a formula which will sum up any times put into these columns and give me the daily total hours.
To summarise the duration of time spent working in a day, I use the following formula: =(C41-B41)+(E41-D41)+12+(G41-F41) which is:
early end time minus early start time
normal end time minus normal start time PLUS 12 hours
late end time minus late start time
Which gives me output like this:
What I cannot seem to achieve is, the ability to sum the daily totals into something which shows me the total hours worked over 1-week. If I attempt to sum the daily totals together for the example image shown, I get some wild figure such as 1487:25:00 when formatting as 'Duration' or 23:25:00 when formatted as 'Time'!
All my cells where I record the hours worked are formatted as 'Time'
When using arithmetic operations on date values in Google Sheets, it's important to remember that the internal representation of a date is numeric, and understood as the number of days since January 1, 1970.
What follows from that, is that if you want to add 12 hours to a time duration, you should not write "+12" because that will in fact add 12 days. Instead add "+12/24". In other words, try the following formula instead of the one you are using now:
=(C41-B41)+(E41-D41)+(12/24+G41-F41)

UI design for time tracking

I'm trying to think an interface for a time-keeping system that will let users see "at a glance" how much time still needs to be completed.
This is complicated by the fact that there are no fixed hours - employees must work at least 6 hours on any given week day, and at the end of each month should have worked 7.5 hours for each week day that month. 7.5 hours either way can be carried over to next month. Employees can also take up to 1 morning and 1 afternoon per month 'flex' time. Time needs should be recorded by 10.15 the following day, but this rule is bent during busy times, and end of week and particularly end of month boundaries become more important.
So what's the most readable format to display the currently entered time and highlight approaching deadlines for uncompleted entries, while still giving a feeling for how far ahead/behind track the employee is (i.e. if you have a week to go that month and you're 8 hours ahead you could schedule a little extra duvet time).
My first take was a bar chart for each day with a red line at 6. But this doesn't give you any idea of how far ahead or behind you are for each day or month or whether you are close to missing a deadline...
(Please excuse the horrible mockup)
Maybe I'm trying to convey too much info in one place?
--
Here's a mockup of time recorded v.s. time required as suggested by Dickon Reed
--
EDIT: this side works great for stuff like this. i'm going to kick some of these ideas around in the morning and hopefully get something posted back here.
Your first chart could be improved by showing the remaining time as shown below. The remaining time until the next weekly/montly deadline is divided evenly over the remaining days before the deadline. So the UI will answer to the question: "How many hours per day will I need to work to meet my deadline?" If the user wants to take one morning/afternoon off (or did I understand you incorrectly?), you should have a checkbox for that day, after checking which the estimates will be adjusted accordingly.
You should also show the exact time on top of every vertical bar, so that the user doesn't need to estimate it in his head (I was lazy and added them to only a couple of bars in the mockup). Also highlight the current day, for example in the below picture this was done by circling "Thursday" and using a bold font for the time that the user has been working today. You could also use some visual effect for today's vertical bar.
improved bar chart http://img11.imageshack.us/img11/6755/20090216203339em2.png
For your second chart you should also draw in the weekly or monthly deadlines, as horizontal bars. In some cases the second chart might be better, but in this case I would settle with the first chart (with my improvements), because it might better correspond to the users' mental model, and that way you can also visualize the daily minimum 6h some way.
how about a "test tube/thermometer" image, like they have for charities... it fills up as you add time, trying to reach a goal (the red line).
Fill each day with a different color, and label accordingly... if the user works overtime M-T, they may have reached the line before Friday, etc.
similar to:
alt text http://goyamarketing.com/blog/wp-content/uploads/2008/11/goal_thermometer.gif
The char bar looks nice visually, but what you really need to know is how far behind/ahead you are in your hours totally.
If i understood correctly, you are interested only in your current saldo and your current deadline, so you could display that information in 2 seperate fields (e.g. below the chart). Of course, you could also mark the deadline with some horizontal line in the graph.
How about a pie chart where the total size represents the minimum goal and add pie slices for each day with actual days that met the minimum one color, days with extra time another and then fill the remaining days as gray slices with the number of hours the employee would have to work divided evenly among them?
A line plot with "working days elapsed" on the X axis and "fraction of monthly required work done" on the Y axis? With only a few data points, it should be clear by visually extrapolating whether you'll hit the top early or late. The plot would look like an irregular staircase.
ps. "The Visual Display of Quantative Information" by Edward Tufte is a great book for ideas on this kind of topic.
To take Dickon Reed's idea one step further, why not do each point as a +/- hours ahead or behind, with your baseline always 0. That way you have more detail. I'm not sure if I got my point across, but it's hard to do without an example, and I'm short on time.

Resources