mirror of https://github.com/doccano/doccano.git
pythonannotation-tooldatasetsactive-learningtext-annotationdatasetnatural-language-processingdata-labelingmachine-learning
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
70 lines
1.4 KiB
70 lines
1.4 KiB
import StatisticsService from '@/services/statistics.service'
|
|
|
|
function makeData(object, label) {
|
|
const labels = object ? Object.keys(object) : []
|
|
const counts = object ? Object.values(object) : []
|
|
return {
|
|
labels,
|
|
datasets: [{
|
|
label,
|
|
backgroundColor: '#00d1b2',
|
|
data: counts
|
|
}]
|
|
}
|
|
}
|
|
|
|
export const state = () => ({
|
|
loading: false,
|
|
stats: {}
|
|
})
|
|
|
|
export const mutations = {
|
|
setLoading(state, payload) {
|
|
state.loading = payload
|
|
},
|
|
setStatistics(state, payload) {
|
|
state.stats = payload
|
|
}
|
|
}
|
|
|
|
export const getters = {
|
|
progress(state) {
|
|
return (labels) => {
|
|
const complete = state.stats.total - state.stats.remaining
|
|
const incomplete = state.stats.remaining
|
|
return {
|
|
datasets: [{
|
|
data: [complete, incomplete],
|
|
backgroundColor: ['#00d1b2', '#ffdd57']
|
|
}],
|
|
labels
|
|
}
|
|
}
|
|
},
|
|
labelStats(state) {
|
|
return (label) => {
|
|
return makeData(state.stats.label, label)
|
|
}
|
|
},
|
|
userStats(state) {
|
|
return (label) => {
|
|
return makeData(state.stats.user, label)
|
|
}
|
|
}
|
|
}
|
|
|
|
export const actions = {
|
|
fetchStatistics({ commit }, payload) {
|
|
commit('setLoading', true)
|
|
StatisticsService.getStatistics(payload)
|
|
.then((response) => {
|
|
commit('setStatistics', response.data)
|
|
})
|
|
.catch((error) => {
|
|
alert(error)
|
|
})
|
|
.finally(() => {
|
|
commit('setLoading', false)
|
|
})
|
|
}
|
|
}
|