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

Show/hide and customize labels:true for combined charts #190

Closed
gopeter opened this issue Apr 29, 2014 · 7 comments
Closed

Show/hide and customize labels:true for combined charts #190

gopeter opened this issue Apr 29, 2014 · 7 comments
Labels
C-feature-request Category: A feature request or an enhancement resolved maybe

Comments

@gopeter
Copy link
Contributor

gopeter commented Apr 29, 2014

It would be great, if labels: true can be configured for combined charts (http://c3js.org/samples/data_label.html).

Example: I have a combined chart with bars and and an area. Now I want to show the values of the area only (and customize it: the value shown should have a trailing "%").

bar

@masayuki0812
Copy link
Member

Hi @gopeter , I totally agree and I'll add this feature. Please give me some time.

@gopeter
Copy link
Contributor Author

gopeter commented Apr 29, 2014

Great, thank you!
A (related?) question: is it possible to swap both y-axis? My data object looks like

data: {
  x : 'x',
  columns: chartData,
  type: 'bar',
  types: {
    progress: 'area'
  },
  axes: {
    progress: 'y2'
  },
  labels: true,
  groups: [
    ['done', 'in progress', 'on hold', 'problem', 'soon']
  ]
},

and I want to display the grouped paramters on the top and the progress at the bottom (axis: { rotated: true })

Is there a way to show the grouped data on y2?

@masayuki0812
Copy link
Member

Sorry, currently it is not possible to swap the axes and I think it is possible to show stacked bars on y2 by setting data.axes. However, something wrong with bar stack on y2 when loading data. I'll fix.

@masayuki0812
Copy link
Member

Hi @gopeter , for labeling issue, I think now you can do that by setting options like this:

data: {
...
  labels: {
    format: {
      y: function () { return ""; },
      y2: function (v) { return v + "%"; }
    }
//  or 
//  format: function (v, id) { return id === 'progress' ? v + "%" : ""; }
  }
...
}

Could you try this on the latest code including the commit above?

gopeter pushed a commit to gopeter/c3 that referenced this issue May 2, 2014
Add id for data.labels.format - c3js#190
@gopeter
Copy link
Contributor Author

gopeter commented May 2, 2014

Thank you, works great!

@masayuki0812
Copy link
Member

Hi @gopeter , Sorry, bars can be stacked based on y2 axis by setting data.axes properly. I mean if the bar of data1, data2 and data3 needs to be stack, please set data.axes for all of these. If another data would be loaded, please set data.axes in advance (I think some args of load() would be needed to specify the axis that loading data relates to).
Could you try this solution?

@gopeter
Copy link
Contributor Author

gopeter commented May 6, 2014

Thanks, works great!

@gopeter gopeter closed this as completed May 6, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: A feature request or an enhancement resolved maybe
Projects
None yet
Development

No branches or pull requests

2 participants