Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Radius function data changes #915

Closed
pareeohnos opened this issue Jan 19, 2015 · 10 comments
Closed

Radius function data changes #915

pareeohnos opened this issue Jan 19, 2015 · 10 comments
Labels
C-bug Category: This is a bug resolved maybe

Comments

@pareeohnos
Copy link

I've run into an issue that's causing the data supplied to the radius function I use to change after a data item has been clicked.

I'm really struggling to figure out where in the code it's happening and am having no luck figuring out what's going on but I'm considering the idea that it is a bug.

I have the following simple function for my radius

point: {
  r: function(item) {
    var val = item.value;
    console.log(item);

    if (val === null || val === undefined || val === 0) {
      return 0;
    } else {
      return 4.5;
    }
  }
}

When the page first loads the console output looks as expected, with the items outputting as something like

Object {x: Wed Jan 01 2014 00:00:00 GMT+0000 (GMT), value: 100, id: "Name", index: 0, name: "Name"}

This is what I'm expecting. What's happening however, is when I click on a point, the radius function is then supplied something that looks like this

Object {id: "Name", id_org: "Name", values: Array[1002]}

My function then returns 0 and the point effectively disappears.

I added a debugging output to the on click event to inspect the data item there, and the data hasn't changed and is passed to that function correctly, but is broken for the radius function.

Looking through the c3 code it seems that the id_org is generated for use with caching, or the convertDataToTargets method. Is this meant to be used by the radius or is this a bug?

If intentional, how can I then get the individual data item I want in the radius function? It feels like a bug given the argument supplied completely changes form, making any code relying on it unstable.

@masayuki0812
Copy link
Member

Hi, can you provide a fiddle? I can't reproduce this case, I mean I don't see this even if I click the points:

Object {id: "Name", id_org: "Name", values: Array[1002]}

And which version of c3 are you using?

@pareeohnos
Copy link
Author

hmm I can't seem to replicate this now :( not a clue what's going on but I'll keep digging and update later.

@pareeohnos
Copy link
Author

ok I've managed to reproduce it. It seems as though it comes into play when I specify different chart types.

The code I'm working with allows the user to customise how many charts are rendered, and what type of chart they are. Originally when the charts loaded, I had hard coded the type that they started with and never had a problem, however I then changed it so that the type could be configured at load time. This then introduced the error shown in this fiddle:

http://jsfiddle.net/rsgLezgy/2/

This fiddle sets up 3 charts: one scatter, one area, and one line. If you click on any point, it will then disappear. I've got a console log output so you can see the invalid data output. By simply commenting out the line types: types.types, the points will no longer disappear.

I hope this is enough information. Let me know if you need any more.

@masayuki0812
Copy link
Member

Thank you for the fiddle. After some investigations, I found the data bound to the element clicked was changed unexpectedly. I don't know the reason (it seems a kind of bug related to select), but fixed by using selectAll instead.
I will release this fix in the next version v0.4.9. Thanks.

@masayuki0812 masayuki0812 added C-bug Category: This is a bug resolved maybe labels Feb 9, 2015
@pareeohnos
Copy link
Author

Amazing thanks :D

@pareeohnos
Copy link
Author

Just tried v0.4.9 but the issue is still there. I updated the fiddle (http://jsfiddle.net/8kxtyoe6/) with the new version and it is still replicating the issue

@masayuki0812
Copy link
Member

I can see this issue seems not happening anymore in v0.4.10-rc4 (the latest version) as you can see here: http://jsfiddle.net/8kxtyoe6/1/

@pareeohnos
Copy link
Author

Perfect! That's working now. Thank you 😄

@masayuki0812
Copy link
Member

0.4.10 has been released, so let me close. Thanks!

@mjncoder
Copy link

Hi, it seems this bug is still an issue. I am using version 0.7.15 and am having the exact issue described by the original post.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug resolved maybe
Projects
None yet
Development

No branches or pull requests

3 participants