d2-charts-api
Advanced tools
Comparing version 25.0.7 to 27.0.0
@@ -7,4 +7,2 @@ 'use strict'; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
exports.default = function (series, store, layout, isStacked, extraOptions) { | ||
@@ -41,2 +39,6 @@ switch (layout.type) { | ||
var _getCumulativeData = require('./../getCumulativeData'); | ||
var _getCumulativeData2 = _interopRequireDefault(_getCumulativeData); | ||
var _pie = require('./pie'); | ||
@@ -101,18 +103,12 @@ | ||
} else { | ||
var _ret = function () { | ||
var newSeries = []; | ||
var newSeries = []; | ||
series.forEach(function (seriesObj) { | ||
newSeries.push(seriesObj, Object.assign({}, DEFAULT_TRENDLINE, { | ||
color: getDarkerColor(seriesObj.color), | ||
data: getRegressionData(seriesObj.data) | ||
})); | ||
}); | ||
series.forEach(function (seriesObj) { | ||
newSeries.push(seriesObj, Object.assign({}, DEFAULT_TRENDLINE, { | ||
color: getDarkerColor(seriesObj.color), | ||
data: getRegressionData(seriesObj.data) | ||
})); | ||
}); | ||
return { | ||
v: newSeries | ||
}; | ||
}(); | ||
if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") return _ret.v; | ||
return newSeries; | ||
} | ||
@@ -133,3 +129,4 @@ } | ||
if (isStacked) { | ||
seriesObj.stacking = 'normal'; | ||
// DHIS2-1060: stacked charts can optionally be shown as 100% stacked charts | ||
seriesObj.stacking = layout.usePercentStackedValues === true ? 'percent' : 'normal'; | ||
} | ||
@@ -145,4 +142,9 @@ | ||
// DHIS2-701: use cumulative values | ||
if (layout.useCumulativeValues === true) { | ||
series = (0, _getCumulativeData2.default)(series); | ||
} | ||
return series; | ||
} | ||
//# sourceMappingURL=index.js.map |
@@ -8,2 +8,6 @@ 'use strict'; | ||
exports.default = function (series, layout, metaData, dashboard) { | ||
if (layout.hideSubtitle) { | ||
return null; | ||
} | ||
var subtitle = void 0; | ||
@@ -43,2 +47,7 @@ | ||
style: { | ||
// DHIS2-578: dynamically truncate subtitle when it's taking more than 1 line | ||
whiteSpace: 'nowrap', | ||
overflow: 'hidden', | ||
textOverflow: 'ellipsis', | ||
fontSize: '14px', | ||
@@ -57,6 +66,15 @@ color: '#555', | ||
function getDefault(layout, dashboard, filterTitle) { | ||
var subtitle = void 0; | ||
// DHIS2-578: allow for optional custom subtitle | ||
if ((0, _isString2.default)(layout.subtitle)) { | ||
subtitle = layout.subtitle; | ||
} else if (dashboard || (0, _isString2.default)(layout.title)) { | ||
subtitle = filterTitle; | ||
} | ||
return { | ||
text: dashboard || (0, _isString2.default)(layout.title) ? filterTitle : undefined | ||
text: subtitle | ||
}; | ||
} | ||
//# sourceMappingURL=index.js.map |
@@ -9,4 +9,4 @@ 'use strict'; | ||
exports.default = function (type) { | ||
return typeMap.get(type) || { | ||
type: type.toLowerCase().replace('stacked', '') | ||
return chartTypeMap.get(type.toLowerCase()) || { | ||
type: type.toLowerCase() | ||
}; | ||
@@ -21,3 +21,3 @@ }; | ||
var typeMap = new Map([ | ||
var chartTypeMap = new Map([ | ||
@@ -33,9 +33,19 @@ // radar | ||
type: 'solidgauge' | ||
}], | ||
// stackedcolumn | ||
['stackedcolumn', { | ||
type: 'column' | ||
}], | ||
// stackedbar | ||
['stackedbar', { | ||
type: 'bar' | ||
}]]); | ||
var stackedTypes = ['area']; | ||
var stackedTypes = ['stackedcolumn', 'stackedbar', 'area']; | ||
function getIsStacked(type) { | ||
return type.indexOf('stacked') !== -1 || (0, _arrayContains2.default)(stackedTypes, type); | ||
return (0, _arrayContains2.default)(stackedTypes, type.toLowerCase()); | ||
} | ||
//# sourceMappingURL=type.js.map |
@@ -47,2 +47,4 @@ 'use strict'; | ||
var _type = require('../type'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -118,5 +120,9 @@ | ||
gridLineColor: DEFAULT_GRIDLINE_COLOR, | ||
labels: getLabels(layout) | ||
labels: getLabels(layout), | ||
// DHIS2-649: put first serie at the bottom of the stack | ||
// in this way the legend sequence matches the serie sequence | ||
reversedStacks: (0, _type.getIsStacked)(layout.type) ? false : true | ||
}); | ||
} | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "d2-charts-api", | ||
"version": "25.0.7", | ||
"version": "27.0.0", | ||
"description": "DHIS2 charts api", | ||
"main": "index.html", | ||
"main": "index.js", | ||
"scripts": { | ||
"start": "webpack-dev-server", | ||
"build": "rm -rf lib/ && ./node_modules/.bin/babel src/ -d lib/ --presets es2015,stage-2 --source-maps" | ||
"build": "rm -rf lib/ && ./node_modules/babel-cli/bin/babel.js src/ -d lib/ --presets es2015,stage-2 --source-maps" | ||
}, | ||
@@ -17,4 +17,4 @@ "author": "", | ||
"highcharts-more": "0.1.2", | ||
"highcharts-solid-gauge": "0.1.2", | ||
"highcharts-no-data-to-display": "0.1.2" | ||
"highcharts-no-data-to-display": "0.1.2", | ||
"highcharts-solid-gauge": "0.1.2" | ||
}, | ||
@@ -21,0 +21,0 @@ "devDependencies": { |
import { fitData } from '../../../../util/regression/jqplot_regression'; | ||
import { rgb } from 'd3-color'; | ||
import getStackedData from './../getStackedData'; | ||
import getCumulativeData from './../getCumulativeData'; | ||
import getPie from './pie'; | ||
@@ -78,3 +79,4 @@ import getGauge from './gauge'; | ||
if (isStacked) { | ||
seriesObj.stacking = 'normal'; | ||
// DHIS2-1060: stacked charts can optionally be shown as 100% stacked charts | ||
seriesObj.stacking = layout.usePercentStackedValues === true ? 'percent' : 'normal'; | ||
} | ||
@@ -90,2 +92,7 @@ | ||
// DHIS2-701: use cumulative values | ||
if (layout.useCumulativeValues === true) { | ||
series = getCumulativeData(series); | ||
} | ||
return series; | ||
@@ -115,2 +122,2 @@ } | ||
return series; | ||
} | ||
} |
@@ -8,2 +8,7 @@ import isString from 'd2-utilizr/lib/isString'; | ||
style: { | ||
// DHIS2-578: dynamically truncate subtitle when it's taking more than 1 line | ||
whiteSpace: 'nowrap', | ||
overflow: 'hidden', | ||
textOverflow: 'ellipsis', | ||
fontSize: '14px', | ||
@@ -22,4 +27,14 @@ color: '#555', | ||
function getDefault(layout, dashboard, filterTitle) { | ||
let subtitle; | ||
// DHIS2-578: allow for optional custom subtitle | ||
if (isString(layout.subtitle)) { | ||
subtitle = layout.subtitle; | ||
} | ||
else if (dashboard || isString(layout.title)) { | ||
subtitle = filterTitle; | ||
} | ||
return { | ||
text: dashboard || isString(layout.title) ? filterTitle : undefined | ||
text: subtitle | ||
}; | ||
@@ -29,2 +44,6 @@ } | ||
export default function (series, layout, metaData, dashboard) { | ||
if (layout.hideSubtitle) { | ||
return null; | ||
} | ||
let subtitle; | ||
@@ -49,2 +68,2 @@ | ||
) : subtitle; | ||
} | ||
} |
import arrayContains from 'd2-utilizr/lib/arrayContains'; | ||
const typeMap = new Map([ | ||
const chartTypeMap = new Map([ | ||
@@ -14,15 +14,26 @@ // radar | ||
type: 'solidgauge' | ||
}], | ||
// stackedcolumn | ||
['stackedcolumn', { | ||
type: 'column' | ||
}], | ||
// stackedbar | ||
['stackedbar', { | ||
type: 'bar' | ||
}] | ||
]); | ||
const stackedTypes = ['area']; | ||
const stackedTypes = ['stackedcolumn', 'stackedbar', 'area']; | ||
export function getIsStacked(type) { | ||
return type.indexOf('stacked') !== -1 || arrayContains(stackedTypes, type); | ||
return arrayContains(stackedTypes, type.toLowerCase()); | ||
} | ||
export default function (type) { | ||
return typeMap.get(type) || { | ||
type: type.toLowerCase().replace('stacked', '') | ||
return chartTypeMap.get(type.toLowerCase()) || { | ||
type: type.toLowerCase() | ||
}; | ||
} | ||
} |
@@ -8,2 +8,3 @@ import arrayClean from 'd2-utilizr/lib/arrayClean'; | ||
import getGauge from './gauge'; | ||
import { getIsStacked } from '../type'; | ||
@@ -78,3 +79,7 @@ const DEFAULT_MIN_VALUE = 0; | ||
gridLineColor: DEFAULT_GRIDLINE_COLOR, | ||
labels: getLabels(layout) | ||
labels: getLabels(layout), | ||
// DHIS2-649: put first serie at the bottom of the stack | ||
// in this way the legend sequence matches the serie sequence | ||
reversedStacks: getIsStacked(layout.type) ? false : true | ||
}); | ||
@@ -81,0 +86,0 @@ } |
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
158860
119
2405