score:3
Accepted answer
if you have an array to define the sorting order...
var desiredorder = ["start of 2013", "end of 2013", "2014", "2015", "2016"];
... just use indexof
in the sort
function:
var d_sequence = sequenceset.values().sort(function(a,b){
return desiredorder.indexof(a) - desiredorder.indexof(b)
});
here is the updated plunker: http://plnkr.co/edit/k09pl2vingv7ipmwbqh3?p=preview
Source: stackoverflow.com
Related Query
- Alternative to d3.ascending or d3.descending that achieves desired order
- dc.js/crossfilter -> How to sort data in dc.js chart (like row) - Ascending x Descending
- Sorting week number and year in ascending order
- I have a set of string data that I want plot in desired partitions with the string neatly near the plotted circles
- How to use colors in RGB as the input domain in a d3.js linear (or different) scale? Or how to code an algorithm that achieves the same?
- A few bars in the wrong place in a bar graph after sorting in ascending order
- How to access the DOM element that correlates to a D3 SVG object?
- Keeping order in D3 data
- Pie (donut) chart segment order in D3
- How to create floor plans that work nice with mobile and desktop browsers?
- Insert padding so that points do not overlap with y or x-axis
- d3: difference between sort and ascending
- Transform label in reverse order d3 radial chart
- how to deal with OnChanges that requires an AfterViewInit
- Draw imbricated blocks that are rotated and fliped with d3.js
- An alternative to NVD3.js (reusable charts library)?
- Basic d3: why can you select things that don't exist yet?
- D3 sort descending for multi-dimensional arrays
- d3.js alternative to axis.tickSubdivide?
- Does Vega-Lite provide all the features that Vega provides?
- D3: hide voronoi strokes that fall 'in the sea'
- How to create a reusable component in D3 with an API that manipulates each instance of the component?
- D3.js: alternative to selecting elements by data attributes?
- How to force nvd3 to display the equal number of ticks as that of the values plotted on the graph-nvd3
- Use D3.min to find lowest value that is not 0
- How to control the order of the layers on a map in d3js
- dagre-d3 how to click node and run an event after that
- If a transition lasts n seconds is it possible to start it at a specified percentage of that time?
- D3.js: How to combine 2 datasets in order to create a map and show values on.mouseover?
- How to update elements of an HTML that the elements are created using data from a CSV file?
More Query from same tag
- C3 bargraph going upper-side if we give y axis max value and the data array are same
- How to show only limited number of records in box plot dc.js
- Overlays not showing up on top of data-generated d3 shapes
- Stopping a Line At the Outer Edge of a Circle
- Date-axis for d3.js
- Eliminate sudden additions/deletions in D3 basis line chart transition
- Printing out nested dictionary in specific format and outputting to json file
- Set bars sizes according to data percents
- Callback parameters mystery
- How can I do d3 without this to support JSLint
- d3.js Transition on div not working
- [Help]: d3.js Scatterplot traverse through 3 different arrays
- Why does this one block of Javascript (D3) work, but not the other?
- D3 version 4: Brush not visible / accessible, but is active in the background
- D3 v4 force directed graph with rectangles
- Circles keep accumulating and are not merging correctly
- Bar Chart Columns Grouped Too Tightly
- Pie chart keeps adjusting itself when updating - D3
- How to set default value appearing in dropdown list with D3?
- D3 force collision detection for ellipses
- How do I name the series in my d3 chart?
- Text inside non-transparent rectangle is not visible
- Changes in d3 (Data-Driven Documents)
- DC.js - disabling brush also disables chart click events / crossfilter
- D3.js custom edge rendering
- D3: ordinal scale returning undefined in part of its range
- How to make axis have a top tick
- Missing data after adding the time range
- D3.js: placing nodes inside other node
- d3.zoom unexpected behavior: what am I missing?