FlotChart Data Change - javascript

I am currently using Flotcharts plugin on my website.
I want to use one of the charts. However, I am unsure how the information is being plotted in order to change the information.
Can someone please advise me on how the following coding works / broken up:
d1 = [
[1262304000000, 5], [1264982400000, 200], [1267401600000, 1605], [1270080000000, 1129],
[1272672000000, 1163], [1275350400000, 1905], [1277942400000, 2002], [1280620800000, 2917],
[1283299200000, 2700], [1285891200000, 2700], [1288569600000, 2100], [1291161600000, 1700]
]
Thank you in advance! :)

Not a lot of context in your question, so it's hard to offer much information in an answer, but your array d1 consists of a set of data points. Each data point has an x-value and a y-value. It looks the x-value is a date/time value and the y-value is a number. (The large numbers such as 1262304000000 look like native JavaScript date/time values; 1262304000000, for example, is midnight on January 1, 2010.) Other than that, there's not much else we can offer unless you want to add more context.

Related

Flot (flot.js) only populated entries in legend

First, I want to apologise for any mistakes in asking the question properly according to the site rules, it's my first time doing it and I tried my best.
So I have the following issue:
Let's say I have that data (consider it - date / value):
I then init a chart with it, the only relevant option to that moment is:
xaxis: { mode: "time" }
and I get the following result:
("Дек" == December)
Now my problem is that there are mid-day hours in the legend which I don't want. I want only days in it. I tried adding this to the xasis:
tickSize: [1, "day"]
but it creates a legend entry for each day of the whole timespan (01.12, 02.12, 03.12 and so on to 06.12) and I want only the days for which I have some data present.
After a while spent in searching in documentation and google I found that there is actually another property for this:
minTickSize: [1, "day"]
That does the trick.

Advanced custom date range in fullcalendar

Im working with fullcalendar and the scheduler plugin. What im trying to do is having some more advanced date range.
I input a JS array a start time and differents duration. It should then create the range accordingly.
Here's an example
Inputed array : array = [ 30min, 30min, 120min, 30min, 9h ]
Outputed date range :
9h, 9h30, 10h, 13h, 13h30
Regarding the scheduler im fine, i've done it in the rangeUpdated and updateGridDates functions and it works pretty well.
My concern is about the calendar since im a bit lost in the source code and i can't really find the place where I should do the logic for this.
Can any kind soul guide me througt this ?
Thank's in advance
So, I resolved my issue by doing the math in the computeTimeTop function. It is responsible for the calculation of the event position on the grid. I had to compute the position of the given time by locating between which slat it should be placed.

How can you do grouping in dc.js datatables?

Sample Data:
[
{ 'date': new Date(2014,03,12,0).getTime(), 'value': 1 },
{ 'date': new Date(2014,03,12,12).getTime(), 'value': 2}
]
I am loading this sort of data into dc.js, and doing some clever transformations to return dimensions that have the date key set to the beginning of the day (or month, or year, etc.) and then in the charts, I am reduceSuming the dataset, it works like a charm! I can reduce each days data into a total, or month, or quarter, etc. However, when I try to do the same thing in the dataTable, no dice, since it doesn't use real crossfilter groups, and it doesn't collapse the data into reductions like the charts can. Am I missing something, or am I just trying to get dataTables to do something they were not meant to do? I can use another tabling creation technique, but I thought maybe someone had figured out how to do it in dc.
Thanks!
If I would have looked just a little bit harder, I would have found this! Works well enough for now. Basically, you make a "fake" dimension using your desired group, giving it a .top() method that returns an object that represents your grouped data. Read the google group post for more details!

How to graph dates on X axis in Rickshaw

I have a set of data for dates. What value should I provide the X axis values? How do I make Rickshaw display the X data values as dates?
I looked around the docs and examples and cannot find anything.
I've just started using Rickshaw and was in the exact situation.
But, before I go any further, Rickshaw documentation is virtually nonexistent which is very upsetting because the performance of Rickshaw compared to other JS graphing libraries is outstanding.
The best way to find examples is to dig into the source code and example code on their github page try to make sense of things (not the way documentation should be).
That being said, let's try and build a strong base of questions/answers here on StackOverflow!
So, back to the question :) It looks like you've already found your own solution to the question, but I'll provide my solution as well.
Rather than using Rickshaw.Graph.Axis.Time, I've used Rickshaw.Graph.Axis.X and set the tickFormat accordingly.
var data = [ { x: TIME_SINCE_EPOCH_IN_SECONDS, y: VALUE },
{ x: NEXT_TIME_SINCE_EPOCH_IN_SECONDS, y: NEXT_VALUE } ]
var xAxis = new Rickshaw.Graph.Axis.X({
graph: graph,
tickFormat: function(x){
return new Date(x * 1000).toLocaleTimeString();
}
})
xAxis.render();
toLocaleTimeString() can be any of the Javascript date functions, such as toLocaleString(), toLocaleDateString(), toTimeString(), or toUTCString(). Obviously, because the tickFormat takes a function as an argument one can supply their own formatter.
Koliber, I'd be interested to understand your answer if you could provide more detail as well.
Additional to Lars' reply, I found by default Rickshaw is calling
.toUTCString(x.value*1000) //(just ctrl+F to find where =) ).
In my case, I saw different time label on X between Graphite and Rickshaw for this reason, and it works beautifully once I changed it to
.toLocaleString(x.value*1000).
Plus, you may need modify this in two places : Rickshaw.Graph.Axis.Time and the ...HoverDetails
I have finally figured out that the X axis values should be epoch time values. Then, using the code from the examples I was able to show a proper time scale.
I still have a problem because I would like to show the tick marks on weeks on the X axis. However, setting timeUnit to 'week' causes JavaScript errors. It works with other time units though.
None of this worked for me. What worked with angularjs was:
'x' : d3.time.format.iso.parse(date).getTime(), 'y' : 10

d3js set tickValues for time scale axis

I've searched in the official d3.js documentation, as well as, here in stackoverflow to find a way to add custom tickValues to a time scale axis; However, i haven't stumble across any documentation that confirms that something like that is possible.
So in essence, i have a time scale axis and i would like to show specific hours
e.g. i'd like to do something like this :
xHourAxis
.ticks(d3.time.hours, 2)
.tickFormat(d3.time.format('%I %p'))
.tickValues(2, 4, 6, 8, 10, 12) ;
So i want to display tick values every 2 hours, but not including the first (12 am) and the last (12 pm).
Does anyone know if there is any workaround for that?
Nearly there, but your code has two problems: First the tick values must be specified in an array, and second those values should be Javascript date objects. i.e. you just provide an array of dates to tickValues so your code would looks something like this:
xHourAxis
.tickFormat(d3.time.format('%I %p'))
.tickValues([new Date(2000,10,5), new Date(2005,2,7), new Date(2007,11,11)]);
Also, note that you needn't call the ticks() if you are going to later specify custom values.

Categories

Resources