export const newitem= ({commit}, payload) => {
axios.post('/api/product/add', payload)
.then((response) => {
commit('additem', response.data);
})
}
methods: {
submit(){this.$store.dispatch('prod/newitem, this.$data.form);}
}
$.ajax({
method: 'POST',
url: 'url',
success: function (data) {
var month=[];
var device=[];
$.each(JSON.parse(data), function(index, report)
{
month.push(report.month)
});
$.each(JSON.parse(data), function(index, name)
{
device.push(name.devices)
});
//Build chart
var ctx = document.getElementById('chart').getContext('2d');
regionChart = new Chart(ctx, {
// The type of chart we want to create
type: 'horizontalBar',
dataType:'json',
// The data for our dataset
data: {
labels: month,
datasets: [{
label: "Chart",
data: device,
}]
},
});
}
});