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

Ticks not working with reactive props #127

Closed
joe642 opened this issue Jun 22, 2017 · 3 comments
Closed

Ticks not working with reactive props #127

joe642 opened this issue Jun 22, 2017 · 3 comments

Comments

@joe642
Copy link

joe642 commented Jun 22, 2017

Expected Behavior

The Y axis scale should be returned as a formatted string with a £ sign.

Actual Behavior

The callback works, but only when the data is loaded when the graph is loaded up empty

image

When the data is added in, the callback is not executed at all

image

<script>
  import { Line, mixins } from 'vue-chartjs'
  import functions from '../../functions';

  export default Line.extend({
    mixins: [mixins.reactiveProp],
    methods: {
      render() {
        console.log(this.chartData);
        if (this.chartData) {
          this.renderChart(
            this.chartData, 
          {
            responsive: false,
            maintainAspectRatio: false,
            scales: {
              yAxes: [{
                ticks: {
                  callback: function(value, index, values) {
                    console.log(value)
                    return functions.moneyFormat(value);
                  },
                },
              }],
            },
          });
        }
      },
    },
    mounted() {
      this.render();
    },
  });
</script>

Environment

  • vue.js version: 2.2.1
  • vue-chart.js version: 2.6.3
  • npm version: 3.10.3
@apertureless
Copy link
Owner

Can you please post a jsfiddle or codepen for reproduction?

It is working fine more me:
https://codepen.io/apertureless/pen/BZKBdX?editors=1010

@joe642
Copy link
Author

joe642 commented Jun 22, 2017

Thanks for getting back so quickly! I passed the options in as a prop as you did in your pen, rather than having it on the child component (like in my code above). It now works as expected.

@joe642 joe642 closed this as completed Jun 22, 2017
@apertureless
Copy link
Owner

Oh yeah, thats because you passed the options directly to the renderChart method.
Which does not work with the reactivePropMixin.

Because the reactiveProp mixin checks for updates and then call either update() or this.renderChart(chartData, options)

So it required a prop or data model named options.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants