A
A
Artur Galyaev2020-11-11 19:00:36
Vue.js
Artur Galyaev, 2020-11-11 19:00:36

How to use vuex getters in data?

I get data for charts from api, they are in the store, next:

computed: {
    ...mapGetters('budget', ['sessions', 'leads', 'sales', 'cps', 'cpl'])
  },

How to use it in charts? I tried like this:
datacollection: {
                   labels: this.dataset,
             datasets: [
               {
                    label: 'Sessions',
                    backgroundColor: 'rgba(85,203,242,0)',
                    borderColor: '#f2842f',
                    yAxisID: 'left',
                    data: this.session,
                    pointRadius: 4,
                    borderWidth: 2,
                    pointBackgroundColor: '#fff',
                },
                {
                    label: 'Sales',
                    backgroundColor: 'rgba(85,120,242,0)',
                    borderColor: '#ec5155',
                    yAxisID: 'left',
                    data: this.sales,
                    pointRadius: 4,

                    borderWidth: 2,
                    pointBackgroundColor: '#fff',
                },
              ],
        	},

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Yarkov, 2020-11-11
@yarkov Vue.js

How to use vuex getters in data?

What for? Do you plan to change the information in the store from the component?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question