question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Loading new JSON data into scatter plot replaces, instead of adding to existing data

See original GitHub issue

http://c3js.org/samples/chart_scatter.html shows a new category being added to a scatterplot at 1000 milliseconds.

I am trying to do the same but with data being loaded from JSON. I specified the same keys as when initially creating it. Instead of adding the new data as new category (and color) to the existing graph, C3 will remove the existing points, add the new ones and zoom to them.

Is this a bug or am I using it wrong?

var chart_scatterplot = c3.generate({
    bindto: '#chart_scatterplot',
    data: {
        json: jsonfile,
        keys: {
            x: 'xvariable',
            value: ['valuevariable'],
        },
        type: 'scatter',
    },
});

setTimeout(function () {
    chart_scatterplot.load({
        json: differentjsonfile,
        keys: {
            x: 'xvariable',
            value: ['valuevariable'],
        },
    });
}, 1000);

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
burembacommented, Oct 21, 2014

concat doesn’t work for my case because I want to add a new segment to to graph. Instead of using this code:

chart_scatterplot.load({
        json: differentjsonfile,
        keys: {
            value: ['valuevariable'],
        }
});

If I use the following:

var dataset = differentjsonfile.map(function(a) { return a.valuevariable });
dataset.splice(0, 0, "differentCol");
chart_scatterplot.load({
        columns: dataset
});

It works because the name of the column in new dataset has a different name (differentCol). Therefore what we need is the ability to specify graph keys for json datasets.

1reaction
kannescommented, Sep 23, 2014

Using your example the following happens for me: First 3 points are shown, the x axis ranges from 100 to 300. When the second dataset is loaded, I see (the newly loaded) 3 points and the x axis updates to the range 200 to 400. The original 3 points are removed. Only the 3 points from the second data set are there.

I am looking for a way to ADD the second set of points to the chart. I would end up with 6 points.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Json file replaces the data instead of adding - Stack Overflow
I have a Json file which i'm using for my website, however when I fill out the form and send it over to...
Read more >
Build a Scatter Plot - Tableau Help
Use scatter plots to visualize relationships between numerical variables. In Tableau, you create a scatter plot by placing at least one measure on...
Read more >
Creating and updating figures in Python - Plotly
This method accepts a graph object trace (an instance of go.Scatter , go.Bar , etc.) and adds it to the figure. This allows...
Read more >
How to Annotate Matplotlib Scatter Plots? - GeeksforGeeks
Approach: Import libraries. Create data. Store all the annotations in a list in order with the sequence of the points to be displayed....
Read more >
Adding a dataset to an analysis - Amazon QuickSight
You can also remove or replace data sets. ... Or choose Add on the application bar and then Add Visual to create a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found