Skip to content

Setting data.names with object's properties #2852

@gustainMars

Description

@gustainMars

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']
      }
  }
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions