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

can't get legendCallback to fire at all #212

Closed
ssuess opened this issue Oct 4, 2017 · 0 comments
Closed

can't get legendCallback to fire at all #212

ssuess opened this issue Oct 4, 2017 · 0 comments

Comments

@ssuess
Copy link

ssuess commented Oct 4, 2017

Expected Behavior

legendCallback should fire when this._chart.generateLegend() is called.

Actual Behavior

Can't get it to fire.

My charts display, and a generic legend is being generated and shown, but my legendCallback is being ignored, it is not firing. My console.log line ('legCallback') shows nothing. But I know the generateLegend method is working because my (generic) legend shows in my div.

Here is my code:

mounted () {
this.renderChart(this.pielabels, {
      responsive: true,
      maintainAspectRatio: false,
      legendCallback: function (chart) {
        var text = []
        console.log('legCallback')
        text.push('<div>')
        for (var i = 0; i < chart.data.datasets.length; i++) {
          text.push('<li><span style=\'background-color:#333\'>')
          text.push(chart.data.datasets[i].label)
          text.push('</span></li>')
        }
        text.push('</div>')
        return text.join('')
      },
      legend: {
        display: false
      },
      titleFontStyle: 'bold'
    })
    this.$bus.$emit('legendgen', this._chart.generateLegend())
  }
@ssuess ssuess closed this as completed Oct 4, 2017
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