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

Setting data.names with object's properties #2852

Open
gustainMars opened this issue Aug 25, 2021 · 0 comments
Open

Setting data.names with object's properties #2852

gustainMars opened this issue Aug 25, 2021 · 0 comments

Comments

@gustainMars
Copy link

gustainMars commented Aug 25, 2021

Just apologies if my english grammar is poor, or doesn't make much sense, i'm not fluent... Yet! ^^'.
Well, I am new to c3, but I have a bar graph and I need to set on c3.generate the name for data.id, that I defined it using data.keys.x, but I don't want to show it. I want to use description as showed below. But I receive a List of objects from my API and I don't know the id of each query result that the user will filter. I would like an option on the c3.generate, like data.names but accepting objects instead and looping it foreach item of my list. Does c3 already have that funcionality? Because I didn't find anyone with a similar problem, or wanted something like this... There it is an example of what I've done so far, and in the data.names what I would like that c3 do for me:

var chart = c3.generate({
  data: {
      json: [
          {id: 'data1', description: 'foo', value1: 350, value2: -200, value3: 150},
          {id: 'data2', description: 'boo', value1: 450, value2: 100, value3: 550},
          {id: 'data3', description: 'bar', value1: 450, value2: -200, value3: 250},
      ],
      type: 'bar',
      keys: {
          x: 'id',
          value: ['value1', 'value2', 'value3'],
      },
      names: {
          //something like that or maybe a function that returns the data of those properties of each index of the list
         id: description
      }
  },
  axis: {
      x: {
          type: 'category',
          categories: ['Value 1', 'Value 2', 'Value 3']
      }
  }
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant