d2-charts-api
Advanced tools
Comparing version 32.0.0 to 32.0.1
@@ -12,3 +12,7 @@ 'use strict'; | ||
exports.hasExtraAxis = hasExtraAxis; | ||
exports.hasExtraAxisItems = hasExtraAxisItems; | ||
exports.getAxisIdsMap = getAxisIdsMap; | ||
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 SERIES_ITEM_SERIES = exports.SERIES_ITEM_SERIES = 'series'; | ||
@@ -47,2 +51,17 @@ var SERIES_ITEM_AXIS = exports.SERIES_ITEM_AXIS = 'axis'; | ||
// returns: true or false | ||
function hasExtraAxisItems(seriesItems, columns) { | ||
var axisIds = Object.keys(getIdAxisMap(seriesItems)); | ||
var seriesIds = columns.reduce(function (all, dim) { | ||
all.push.apply(all, _toConsumableArray(dim.items.map(function (item) { | ||
return item.id; | ||
}))); | ||
return all; | ||
}, []); | ||
return axisIds.find(function (id) { | ||
return seriesIds.includes(id); | ||
}); | ||
} | ||
// returns: | ||
@@ -49,0 +68,0 @@ // { |
@@ -116,3 +116,3 @@ 'use strict'; | ||
if ((0, _type.isDualAxis)(layout.type) && (0, _seriesItems.hasExtraAxis)(layout.seriesItems)) { | ||
if ((0, _type.isDualAxis)(layout.type) && (0, _seriesItems.hasExtraAxis)(layout.seriesItems) && (0, _seriesItems.hasExtraAxisItems)(layout.seriesItems, layout.columns)) { | ||
axes.push({ | ||
@@ -119,0 +119,0 @@ title: { |
{ | ||
"name": "d2-charts-api", | ||
"version": "32.0.0", | ||
"version": "32.0.1", | ||
"description": "DHIS2 charts api", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -34,2 +34,13 @@ export const SERIES_ITEM_SERIES = 'series'; | ||
// returns: true or false | ||
export function hasExtraAxisItems(seriesItems, columns) { | ||
const axisIds = Object.keys(getIdAxisMap(seriesItems)) | ||
const seriesIds = columns.reduce((all, dim) => { | ||
all.push(...(dim.items.map(item => item.id))); | ||
return all; | ||
}, []); | ||
return axisIds.find(id => seriesIds.includes(id)); | ||
} | ||
// returns: | ||
@@ -36,0 +47,0 @@ // { |
@@ -9,3 +9,3 @@ import arrayClean from 'd2-utilizr/lib/arrayClean'; | ||
import { getIsStacked } from '../type'; | ||
import { hasExtraAxis } from '../seriesItems'; | ||
import { hasExtraAxis, hasExtraAxisItems } from '../seriesItems'; | ||
@@ -91,3 +91,5 @@ const DEFAULT_MIN_VALUE = 0; | ||
if (isDualAxis(layout.type) && hasExtraAxis(layout.seriesItems)) { | ||
if (isDualAxis(layout.type) && | ||
hasExtraAxis(layout.seriesItems) && | ||
hasExtraAxisItems(layout.seriesItems, layout.columns)) { | ||
axes.push({ | ||
@@ -94,0 +96,0 @@ title: { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
336859
3933