d2-charts-api
Advanced tools
Comparing version 31.0.9 to 31.0.10
@@ -20,4 +20,4 @@ 'use strict'; | ||
type: _layout.type, | ||
seriesId: _layout.columns[0].dimension, | ||
categoryId: _layout.rows[0].dimension | ||
seriesId: _layout.columns && _layout.columns.length ? _layout.columns[0].dimension : null, | ||
categoryId: _layout.rows && _layout.rows.length ? _layout.rows[0].dimension : null | ||
}); | ||
@@ -24,0 +24,0 @@ |
@@ -49,2 +49,7 @@ 'use strict'; | ||
var HIGHCHARTS_COLUMN = 'column'; | ||
var HIGHCHARTS_BAR = 'bar'; | ||
var HIGHCHARTS_PERCENT = 'percent'; | ||
var HIGHCHARTS_NORMAL = 'normal'; | ||
function getColor(colors, index) { | ||
@@ -70,3 +75,3 @@ return colors[index] || getColor(colors, index - colors.length); | ||
// DHIS2-1060: stacked charts can optionally be shown as 100% stacked charts | ||
seriesObj.stacking = layout.percentStackedValues === true ? 'percent' : 'normal'; | ||
seriesObj.stacking = layout.percentStackedValues === true ? HIGHCHARTS_PERCENT : HIGHCHARTS_NORMAL; | ||
} | ||
@@ -78,3 +83,3 @@ | ||
if ((seriesType === 'column' || seriesType === 'bar') && layout.noSpaceBetweenColumns) { | ||
if ((seriesType === HIGHCHARTS_COLUMN || seriesType === HIGHCHARTS_BAR) && layout.noSpaceBetweenColumns) { | ||
seriesObj.pointPadding = 0; | ||
@@ -81,0 +86,0 @@ seriesObj.groupPadding = 0; |
@@ -13,9 +13,3 @@ 'use strict'; | ||
cursor: 'pointer', | ||
data: (0, _getCategories2.default)(store.data[0].metaData, layout).map(function (category, index) { | ||
return { | ||
name: category, | ||
color: colors[index], | ||
y: series[0].data[index] | ||
}; | ||
}), | ||
data: series, | ||
dataLabels: { | ||
@@ -29,8 +23,2 @@ enabled: true, | ||
}; | ||
var _getCategories = require('../getCategories'); | ||
var _getCategories2 = _interopRequireDefault(_getCategories); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
//# sourceMappingURL=pie.js.map |
@@ -25,3 +25,2 @@ 'use strict'; | ||
switch (layout.type) { | ||
case _type.CHART_TYPE_PIE: | ||
case _type.CHART_TYPE_GAUGE: | ||
@@ -28,0 +27,0 @@ subtitle = (0, _gauge2.default)(series, layout, dashboard, filterTitle); |
@@ -13,8 +13,5 @@ 'use strict'; | ||
var seriesFunction = (0, _type.isYearOverYear)(type) ? _yearOnYear2.default : getDefault; | ||
var seriesFunction = getSeriesFunction(type); | ||
return data.reduce(function (acc, res) { | ||
seriesId = seriesId || res.headers[0].name; | ||
categoryId = categoryId || res.headers[1].name; | ||
var headers = res.headers; | ||
@@ -47,2 +44,6 @@ var metaData = res.metaData; | ||
var _pie = require('./pie'); | ||
var _pie2 = _interopRequireDefault(_pie); | ||
var _type = require('../../../config/adapters/dhis_highcharts/type'); | ||
@@ -52,2 +53,4 @@ | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
var VALUE_ID = 'value'; | ||
@@ -76,3 +79,4 @@ | ||
rows.forEach(function (row) { | ||
key = getPrefixedId(row, seriesHeader) + '-' + getPrefixedId(row, categoryHeader); | ||
key = [].concat(_toConsumableArray(seriesHeader ? [getPrefixedId(row, seriesHeader)] : []), _toConsumableArray(categoryHeader ? [getPrefixedId(row, categoryHeader)] : [])).join('-'); | ||
value = row[valueIndex]; | ||
@@ -108,2 +112,14 @@ | ||
} | ||
function getSeriesFunction(type) { | ||
switch (type) { | ||
case _type.CHART_TYPE_PIE: | ||
return _pie2.default; | ||
case _type.CHART_TYPE_YEAR_OVER_YEAR_COLUMN: | ||
case _type.CHART_TYPE_YEAR_OVER_YEAR_LINE: | ||
return _yearOnYear2.default; | ||
default: | ||
return getDefault; | ||
} | ||
} | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "d2-charts-api", | ||
"version": "31.0.9", | ||
"version": "31.0.10", | ||
"description": "DHIS2 charts api", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -30,4 +30,4 @@ import objectClean from 'd2-utilizr/lib/objectClean'; | ||
type: _layout.type, | ||
seriesId: _layout.columns[0].dimension, | ||
categoryId: _layout.rows[0].dimension, | ||
seriesId: _layout.columns && _layout.columns.length ? _layout.columns[0].dimension : null, | ||
categoryId: _layout.rows && _layout.rows.length ? _layout.rows[0].dimension : null, | ||
}); | ||
@@ -34,0 +34,0 @@ |
@@ -9,2 +9,7 @@ import getCumulativeData from './../getCumulativeData'; | ||
const HIGHCHARTS_COLUMN = 'column'; | ||
const HIGHCHARTS_BAR = 'bar'; | ||
const HIGHCHARTS_PERCENT = 'percent'; | ||
const HIGHCHARTS_NORMAL = 'normal'; | ||
function getColor(colors, index) { | ||
@@ -30,3 +35,3 @@ return colors[index] || getColor(colors, index - colors.length); | ||
// DHIS2-1060: stacked charts can optionally be shown as 100% stacked charts | ||
seriesObj.stacking = layout.percentStackedValues === true ? 'percent' : 'normal'; | ||
seriesObj.stacking = layout.percentStackedValues === true ? HIGHCHARTS_PERCENT : HIGHCHARTS_NORMAL; | ||
} | ||
@@ -38,3 +43,3 @@ | ||
if ((seriesType === 'column' || seriesType === 'bar') && layout.noSpaceBetweenColumns) { | ||
if ((seriesType === HIGHCHARTS_COLUMN || seriesType === HIGHCHARTS_BAR) && layout.noSpaceBetweenColumns) { | ||
seriesObj.pointPadding = 0; | ||
@@ -41,0 +46,0 @@ seriesObj.groupPadding = 0; |
@@ -1,3 +0,1 @@ | ||
import getCategories from '../getCategories'; | ||
export default function(series, store, layout, isStacked, colors) { | ||
@@ -10,7 +8,3 @@ return [ | ||
cursor: 'pointer', | ||
data: getCategories(store.data[0].metaData, layout).map((category, index) => ({ | ||
name: category, | ||
color: colors[index], | ||
y: series[0].data[index], | ||
})), | ||
data: series, | ||
dataLabels: { | ||
@@ -17,0 +11,0 @@ enabled: true, |
@@ -58,3 +58,2 @@ import isString from 'd2-utilizr/lib/isString'; | ||
switch (layout.type) { | ||
case CHART_TYPE_PIE: | ||
case CHART_TYPE_GAUGE: | ||
@@ -61,0 +60,0 @@ subtitle = getGauge(series, layout, dashboard, filterTitle); |
import getYearOnYear from './yearOnYear'; | ||
import getPie from './pie'; | ||
import { | ||
isYearOverYear | ||
isYearOverYear, CHART_TYPE_YEAR_OVER_YEAR_COLUMN, CHART_TYPE_YEAR_OVER_YEAR_LINE, CHART_TYPE_PIE | ||
} from '../../../config/adapters/dhis_highcharts/type'; | ||
@@ -29,3 +30,7 @@ | ||
rows.forEach(row => { | ||
key = getPrefixedId(row, seriesHeader) + '-' + getPrefixedId(row, categoryHeader); | ||
key = [ | ||
...(seriesHeader ? [getPrefixedId(row, seriesHeader)] : []), | ||
...(categoryHeader ? [getPrefixedId(row, categoryHeader)] : []), | ||
].join('-'); | ||
value = row[valueIndex]; | ||
@@ -62,9 +67,18 @@ | ||
function getSeriesFunction(type) { | ||
switch (type) { | ||
case CHART_TYPE_PIE: | ||
return getPie; | ||
case CHART_TYPE_YEAR_OVER_YEAR_COLUMN: | ||
case CHART_TYPE_YEAR_OVER_YEAR_LINE: | ||
return getYearOnYear; | ||
default: | ||
return getDefault; | ||
} | ||
} | ||
export default function({ type, data, seriesId, categoryId }) { | ||
const seriesFunction = isYearOverYear(type) ? getYearOnYear : getDefault; | ||
const seriesFunction = getSeriesFunction(type); | ||
return data.reduce((acc, res) => { | ||
seriesId = seriesId || res.headers[0].name; | ||
categoryId = categoryId || res.headers[1].name; | ||
const headers = res.headers; | ||
@@ -71,0 +85,0 @@ const metaData = res.metaData; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
133
3452
306618