How essential is it for C3 to sort the x axis list?
See original GitHub issuePlotting experience from Python/Matplotlib, R, Matlab, Excel, etc., suggests that the ordering of the x values of a plot is important, i.e., if you use a non-sorted list of for your x axis and ask for a line plot, you’ll get a jagged line. C3.js doesn’t do this: it’ll sort the x-axis data before drawing a “normal-looking” (but unexpected, and in some cases, incorrect) plot.
How important is this decision to C3’s design? Can it be relaxed by a user-settable parameter?
var chart = c3.generate({
bindto : '#ch',
data : {
x : 'x',
rows : [
[ 'x', 'data1', 'data2' ],
[ 11, 120, 300 ],
[ 22, 160, 240 ],
[ -33, 200, 290 ], // <----- note shuffled x point
[ 44, 160, 230 ],
[ 55, 130, 300 ],
]
}
});
Background: I’m using tooltip.contents
and a non-sorted list for x in a scatter plot, and have to create a lookup object to transform the x values to indexes just for this. The x list can’t be stored sorted because it indexes many other lists.
Issue Analytics
- State:
- Created 9 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
C3.js x-axis show every other categories - Stack Overflow
If you wanted every 5th tick to show and had 100 ticks in total, you'd set the value of max to be equal...
Read more >Re: Sort by expression whatever the selection - Qlik Community
I only sort by expression ascending, State is not checked. It works fine if I have no selection. If I filter on C3,...
Read more >Customizing Axes in D3.js - Glenn Henshaw
We will make a horizontal axis and customize it in different ways using D3 methods and CSS selections. First I'll show you how...
Read more >Changing the order of the x axis in Power BI - YouTube
When Power BI decides on the order of the columns in a visualisation it only knows about numeric order or alphabetical order.
Read more >Combining Datasets: Concat and Append
The first argument is a list or tuple of arrays to concatenate. Additionally, it takes an ... x = [[1, 2], [3, 4]]...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi, Thank you for the feedback and the discussion. I added
data.xSort
option to determine whether the data will be sorted or not byx
values.Now you can do that by setting this option
false
, then the sort will be skipped and the order of the data will be maintained. Than, you can access the element of unsorted data by the index obtained from data intooltip.content
. Could you try the latest code? Thanks.@shafiquejamal it works for me with version 0.4.11. Setting <c3 chart object>
.data.xSort = false
solved a problem similar to the one described by the original poster. The dots keep their index numbers from the supplied data set (and the corresponding drawing order is respected) regardless of their x values.That version is rather old, though. Perhaps the functionality has become broken in later versions?