score:0
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.
score:0
None of this worked for me. What worked with angularjs was:
'x' : d3.time.format.iso.parse(date).getTime(), 'y' : 10
score:2
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
score:13
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.
Source: stackoverflow.com
Related Query
- How to graph dates on X axis in Rickshaw
- How to graph dates on X axis while skipping weekends d3.js?
- How to format the Y axis values on Rickshaw Graphs
- How can I draw one axis frequency distribution graph in d3?
- Append Value to Rickshaw Graph Axis and what is ticksTreatment and Preserve
- c3 graph in a dark background; how to change axis and tick value color
- How to remove weekends dates from x axis in dc js chart
- How to remove axis line overflow in c3js line graph
- how to make the x axis scrollable in a d3 line chart graph
- How to make graph through rickshaw and angularjs?
- How to render dates on x axis prior to 1900 with d3 .js scatter plot
- how to automatically resize d3.js graph to include axis
- How to remove unwanted lines in Axis scale of a graph when using D3.js?
- How to get a dashed line on Y axis and how to display the value beside the graph in d3
- How do I limit the panning on a force directed graph layout without axis ? D3/JS
- How do I prevent graph elements from reaching the axis of my graph in D3 and scale properly?
- How to make hour and minutes as x axis in nvd3.js graph
- How to place a date in a tooltip when only part of axis ticks with dates are shown? Using D3.js
- How can I convert the unix date values along the axis of a d3.js graph to format dd-mm-yy?
- How to Add X and Y axis in the pre existing graph using D3
- How to make two sets of axis labels in grouped line graph in dimple.js?
- How to make dynamic graph with rickshaw without refreshing the browser?
- how to add y axis label(custom text) in rickshaw graph?
- How to make force layout graph in D3.js responsive to screen/browser size
- How do I display dates on the x-axis for nvd3 / d3.js?
- How to update axis using d3.js
- dealing with dates on d3.js axis
- How to convert/save d3.js graph to pdf/jpeg
- How can I get the D3.js axis ticks and positions as an array?
- How to add a click event on nvd3.js graph
More Query from same tag
- Draw the line use the same y values, plots line at the bottom
- Plotting data on quadrilateral area
- How do I retrieve an array from a csv file in javascript using d3?
- Adding d3.js charts to Wordpress
- How to animate range input element properly?
- Display only values from the data set into X axis ticks
- Link drawing issue in d3 force layout
- D3 Pie in Angular 2?
- d3js mousemove event is not bubbling
- d3.js treemap could paint internal nodes too
- Histogram in JavaScript?
- How to prevent d3.drag().on('end' from firing .on('click'
- Making X-axis in cross filter dynamic
- append circle to map in d3
- General reduceInitial function crossfilter
- display text inside circle on mousehover using d3.js
- Style d3 svg line with css
- D3.js how to embed selection into a new element
- d3 I want that gridlines overflow will be hidden
- Coloring a Nest treemap with D3.JS
- Porting Parallel Coordinates code from d3.js v3.5.16 to 4.0
- Repainting/Refreshing Graph in D3
- Django Static CSV to be used by d3
- trying to create JSON code for NVD3 Charts
- SVG implementation of Monotone cubic interpolation without a Library like d3
- D3: get element attribute inside selectAll
- D3 find the angle of line
- D3 data join() calls enter instead of update
- How do I set the right date from an external JSON file?
- dot not displayed into a line/scatter combo plot d3.js