c3js / c3js/c3

Columns not displayed in expected order in legend after adding columns

Open
#1,547 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
9.3k
Forks
1.4k
Avg merge
6d 16h
Merged PRs (30d)
1

Description

Demo of issue: http://jsfiddle.net/h2s3ftqo/

I would expect chart.load to insert any new columns in the order specified.

```
chart.load({
columns: [
['18-24', 234],
['25-34', 43],
['35-44', 484],
],
```

Instead, new columns are added to end of the legend, so the legend is in this order:

```
'18-24'
'35-44'
'25-34'
```

(Where the first two age groups were already existing on the chart, and the third age group was added dynamically.)

You can work around this by adding unload:true but then the chart flickers.

![chart out of order](https://cloud.githubusercontent.com/assets/9092656/12462082/06bb126c-bf82-11e5-94e4-96096fffec3c.png)

Contributor guide

Open the contributing guide

Research direction

Start with the linked JSFiddle demo and trace chart.load when columns are added dynamically, focusing on how the legend order is updated. Confirm that the columns array order is preserved without relying on unload:true, and verify that the legend no longer flickers or places new columns at the end.

Written by the indexing model from the issue text.

Assessment

Tech stack
d3, javascript
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.