Using dates in Flot - flot

I need help displaying flot chart (search in similar thread does not work for me):
var graphData = [{
data: [ [1343772000*1000,130],[1343858400*1000,152]...
data: [ [1312149600*1000,202],[1312236000*1000,165]...
and
xaxis: {
mode: "time",
timeformat: "%d.%m",
minTickSize: [1, "day"]
},
The result is something like...
How can i display the correct dates in x-axis ?

It depends on what you mean by correct.
If you're talking about the x-axis label format, then the %d.%m timeformat that you're using tells Flot to show the number of the month followed by the day, which is exactly what appears in your screenshot.
If you want month names instead of numbers, you need to provide the 'monthNames' option, containing 12 strings, i.e. ["January, "February", ...]. Then you can use the %b format option to use the appropriate string. For more info on all the available format options see the time series data section of the docs.
Regarding the gap in the middle of the plot, that also appears correct. The timestamps in your first series start at August 2012, while the ones in the second series start at August 2011. If each series covers three months, then one would expect to see exactly what is shown in your screenshot.
If neither answer is relevant, then you need to provide more information about your data and what you expect to see.

Related

Excel - Plot time slots on a continuous time axis

Let's say we have time slots documented in which a production line was running. In between each product maufactured are time slots in which the machine was idling.
I now want to plot the machine status over time, basically as a boolean value (running vs idling).
I get the machine log and need the chart on the right.
The machining duration will ultimately be logged including seconds and may vary for each product.
The first - and probably biggest - challenge for me is to find a smart way to extract the status from the time stamps. My current first step ist to create a table row for each minute and use the if statement in H4 to check wether article 1 was being manufactured.
IF(AND([#Time]>Machine_log[#Start],[#Time]<Machine_log[#Finish]);;)
However, since the final list will range over 24 hours or more and the number of articles quickly reaches 50 and more, I would love to avoid using nested IFs on this one..
I'm thankfull for any input and open for inspiration :)
Thank you all in advance!
PS: Anyone know how a better way than a scatter chart with two values per X-Value to display the chart as vertical lines/right angles like this?
One option is to add only those points that are necessary to the Status extraction table (which I named "Status"). (I named the Machine log table "Log").
Note: it looks like you are using a semicolon list separator, so you'll need to change the commas in the formulas below to semicolons.
Formula for the Time column:
=IF(ROW()=ROW(Status),MIN(Log[Start])-1/144,IFERROR(INDEX(Log[[Start]:[Finish]],INT((ROW()-ROW(Status)-1)/4)+1,MOD(INT((ROW()-ROW(Status)-1)/2),2)+1),MAX(Log[Finish])+1/144))
Formula for the Production running? column (enter into H4 and fill down):
=IF(SUMPRODUCT(--(Log[[Start]:[Finish]]=[#Time])),IF([#Time]=G3,3-H3,H3),1)
These formulas will pad your plot with 10 minutes of off time on either side.
To answer your question about avoiding two points for each x-value: no, each point on the plot has to have a corresponding data pair.
UPDATE IN RESPONSE TO COMMENT: I failed to mention that the above solution assumes the time data in the Machine log table are in ascending order. This means that if your data span more than one day, they will need to contain a date component or you can get plots where the line crosses back to the beginning. For example, if you have 23:57:00 followed by 00:10:00 with no date component, Excel treats these as 11:57 pm on 1 January 1900 and 12:10 am on 1 January 1900. (To see this, change the format to "General", and you'll see the values that Excel uses to encode date-time aren't in ascending order.) The solution is to enter the dates as "8/16/2020 23:57:00" and "8/17/2020 00:10:00" in the formula bar. If you're copying over from another data source, the date needs to be copied with the time. If the dates and times are in separate columns, your Start and Finish columns would each be a date column plus a time column.

Creating a Stack Area Chart that shows Issues over Time using Beginning and End Dates

My Data looks like this:
||UNIQUE_KEY||LABEL1||LABEL2||START_DATE||END_DATE||
What I'd like to do is have 2 stacked area charts that show totals (count of UNIQUE_KEY), one chart for LABEL1 values & another for LABEL2values over time.
X axis would be Number, Y would be time. Charts would show a count of UNIQUE_KEY for each of the possible LABEL# values at each point in time.
I am at a loss how to translate the Start Date and End Dates into a framework so that excel considers that Issue open at that point in time for the dates that fall in between Start and End date.
I can think of ways to do it that are really ugly and I have to know id there's a slick way to get what I want.
Thanks!
edit... here's a snippet of the data (comma delimited) - and I refined my explanation above
Issue key,Issue Type,Work Type,Created,Resolved
SA-17070,Maintenance,PS_SYSTEM,7/7/2014,8/29/2014
SA-17006,Production Incident,PACKAGING,6/30/2014,8/29/2014
SA-23110,Production Incident,BUSINESS_PROCESS,8/1/2016,9/12/2016
SA-22628,Enhancement,BUSINESS_PROCESS,5/23/2016,8/25/2016
SA-16073,Maintenance,BUNDLE,4/17/2014,5/16/2014
SA-15625,Maintenance,BUNDLE,3/6/2014,3/14/2014
SA-17008,Maintenance,BUNDLE,6/30/2014,7/3/2014
SA-17062,Maintenance,BUNDLE,7/3/2014,7/7/2014
SA-16922,Maintenance,BUNDLE,6/19/2014,7/7/2014
SA-16913,Maintenance,BUNDLE,6/18/2014,7/7/2014
SA-17064,Maintenance,BUNDLE,7/7/2014,7/8/2014
SA-16956,Maintenance,BUNDLE,6/24/2014,7/28/2014
SA-17172,Maintenance,BUNDLE,7/15/2014,8/29/2014
SA-17349,Production Incident,BUNDLE,8/4/2014,8/7/2014
SA-19038,Configuration,BUNDLE,2/16/2015,2/19/2015
SA-19011,Maintenance,BUNDLE,2/12/2015,2/16/2015
SA-19298,Maintenance,BUNDLE,3/12/2015,3/23/2015
SA-19065,Production Incident,BUNDLE,2/18/2015,3/23/2015
SA-19235,Production Incident,BUNDLE,3/9/2015,4/30/2015
SA-20192,Maintenance,BUNDLE,7/13/2015,7/15/2015
SA-21317,Maintenance,BUNDLE,11/19/2015,12/2/2015
SA-21169,Maintenance,BUNDLE,11/3/2015,2/1/2016
SA-21283,Production Incident,BUNDLE,11/17/2015,12/11/2015
SA-21329,Production Incident,BUNDLE,11/19/2015,1/4/2016
SA-23487,Maintenance,BUNDLE,9/12/2016,10/25/2016
SA-23356,Maintenance,BUNDLE,8/29/2016,10/25/2016
SA-23443,Production Incident,BUNDLE,9/7/2016,9/9/2016
SA-23589,Production Incident,BUNDLE,9/24/2016,9/24/2016
SA-23931,Enhancement,BUNDLE,11/21/2016,12/2/2016
SA-17356,Configuration,PS_SYSTEM,8/4/2014,10/7/2014
This is not exactly what you described. This shows dates an issue is open on the Y-Axis, versus the issue number on the X-Axis. I know you want something different on the X-Axis, but it is unclear how you want this to map to the Y-Axis. (e.g. maximum Resolved time - minimum Created time?, duration of latest issue?)
Note: You could do the following once for each Issue Type, once for each Work Type.
To create a chart showing duration an issue is open, where duration is on the Y-axis and the issue "key" is on the X-axis ...
Add a column to your data that is Duration. It is Resolved - Created.
Select the Issue Key Column, Created Column, and the Duration column.
Insert a Stacked Column Chart.
Select the Resolved series and format. Set the fill color and line color to None.
Select the Y-axis and format the axis. Adjust the lower limit to something you want. Change the number format to Date.

Excel Custom Number Format on chart Axis

I'm trying to set a Custom format for the Y-Axis of an Excel Chart and I'm not getting the result I need. I've referenced the Peltier webpage as a good source of information on creating custom Excel formats. I've come up with the following.
[>=1000000]0,,"M";[>=1000]0,"K";0
It works well until I need the rage to show values like 1 million, 1.2 million, 1.4 million, ect... I've tried
[>=1000000]0.#,,"M";[>=1000]0,"K";0
It does display 1.2M and 1.4M as needed but it has a period on the 1 million line "1. M". How do I modify my format to only show the period when the number to right of the decimal point is not zero?
So it looks like the best approach to allow the Axis to scale normally is to show a Zero on the right hand side of the decimal point, therefore always showing decimal point.
So, using
[>=1000000]0.0,,"M";[>=1000]0,"K";0
produces
800K, 1.0M, 1.2M, 1.4M, 1.6M, 1.8M, 2M, 2.2M
Without sample data together with expected results this may require some tweaking but you can add a specific circumstance to remove the decimal point. One of these might be appropriate.
[>1000000]0.0,,\M;[=1000000]0,,\M;0.0,K
[>1000999]0.0,,\M;[>999000]0,,\M;0.0,K

how to get excel graphs to use the same custom date format as a cell mmm-yyyy

I applied a custom date format to a column in excel (the format yyyy-mm e.g. 2014-01)
But when I create a graph out of three columns of data (date-in above format |heading|value) the graph shows the date as 2014-01-31 2014-02-28.
How do I get the graph to display the date as I have formatted it 2014-01 only without changing the data type to text and pasting values?
I use Excel 2013 but as far as I know this aspect of charting has not changed much since long before Excel 2010. Select your horizontal axis (click on one of the date labels in the chart), select Format Axis... and you should be able to:
(a) format the values there independently (ie in your case reapply the same custom format as applied to the raw data) and/or
(b) tick Linked to source.
The latter approach may not work quite as well as the former. Linked to source may mean something a little different from just "take the formatting from the raw data" (well, for the axis labels the format has to be common to all, whereas in the raw data it may differ between data points) and with a quick look I have not found details (for Excel 2010) of exactly what that is supposed to do.
So the former approach may be more reliable. For this you may need a two-step process. First make your custom format available to the chart and then apply it. That way the results are the same, chart and raw data formatting, though the process is not fully automatic.
One thing to watch out for is the linearity of the chart for time values. For example, if the dates are strings and the data points Jan 2012, Feb 2012 and March 2013 there is some risk the resulting labels will be equally spaced whereas the gap between the second two points should normally be thirteen times that of the gap between the first two points. Where data is approximately at regular time intervals anyway this is not always immediately obvious.

Excel: Every other date on X-axis displayed fromthe end

I have a set of dates and matching numbers in excel, one number for every month in 2013. I need to display these numbers with the dae on the X-axis in a simple line graph. I am mainly intereseted in the number for the last month but also the historical numbers.
It is to crowded on the X-axis to show every single month so I only show every other month. This is easily done by right clicking the axis etc.
Now, since the last month is the most important one I would like to show that month (2013-12) and every other month backwards.
The axis should look something like this:
2013-02, 2013-04, 2013-06, 2013-08, 2013-10, 2013-12
But no matter how I change in excel I end up with this:
2013-01, 2013-03, 2013-05, 2013-07, 2013-09, 2013-11
Since the last month (december) is the most important one I would say it is logical to display that month.
The only way I can get it working is by dropping the first observation which I don't want to do.
Any suggestions how I can et this working in excel?
You have a "fencepost problem". You want to display 12 values, but if you want to display every second one, either you take all the odd numbers (in which case december is hidden) or all the even ones (which hides january)
If you're okay with hiding january, then add a dummy month at the beginning of your series, and give it the value:
=na()
Excel will allot it space but will not give it a point on the graph.
Alternately, if your axis is too crowded, turn the label text sideways or put the year 2013 in the title and only put the months on the x axis (1, 2, 3, ..., 12)

Resources