Skip to content
Snippets Groups Projects
Commit 605d96f3 authored by esikkala's avatar esikkala
Browse files

Line chart: add mapper for filling empty values

parent 6da9f4ff
No related branches found
No related tags found
No related merge requests found
...@@ -97,6 +97,31 @@ export const mapLineChart = sparqlBindings => { ...@@ -97,6 +97,31 @@ export const mapLineChart = sparqlBindings => {
} }
} }
export const mapLineChartFillEmptyValues = sparqlBindings => {
const seriesData = []
const categoriesData = []
const sparqlBindingsLength = sparqlBindings.length
sparqlBindings.map((b, index, bindings) => {
const currentCategory = b.category.value
const currentValue = b.count.value
seriesData.push(currentValue)
categoriesData.push(currentCategory)
if (index + 1 < sparqlBindingsLength) {
let currentCategoryInt = parseInt(currentCategory)
const nextCategoryInt = parseInt(bindings[index + 1].category.value)
while (currentCategoryInt < nextCategoryInt) {
currentCategoryInt += 1
seriesData.push(0)
categoriesData.push(currentCategoryInt)
}
}
})
return {
seriesData,
categoriesData
}
}
export const mapPieChart = sparqlBindings => { export const mapPieChart = sparqlBindings => {
const results = sparqlBindings.map(b => { const results = sparqlBindings.map(b => {
return { return {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment