|
@ -26,8 +26,8 @@ Bargraph.draw = function (groupIds, processedGroupData, framework) { |
|
|
if (group.visible === true && (framework.options.groups.visibility[groupIds[i]] === undefined || framework.options.groups.visibility[groupIds[i]] === true)) { |
|
|
if (group.visible === true && (framework.options.groups.visibility[groupIds[i]] === undefined || framework.options.groups.visibility[groupIds[i]] === true)) { |
|
|
for (j = 0; j < processedGroupData[groupIds[i]].length; j++) { |
|
|
for (j = 0; j < processedGroupData[groupIds[i]].length; j++) { |
|
|
combinedData.push({ |
|
|
combinedData.push({ |
|
|
x: processedGroupData[groupIds[i]][j].x, |
|
|
|
|
|
y: processedGroupData[groupIds[i]][j].y, |
|
|
|
|
|
|
|
|
screen_x: processedGroupData[groupIds[i]][j].screen_x, |
|
|
|
|
|
screen_y: processedGroupData[groupIds[i]][j].screen_y, |
|
|
groupId: groupIds[i], |
|
|
groupId: groupIds[i], |
|
|
label: processedGroupData[groupIds[i]][j].label |
|
|
label: processedGroupData[groupIds[i]][j].label |
|
|
}); |
|
|
}); |
|
@ -41,11 +41,11 @@ Bargraph.draw = function (groupIds, processedGroupData, framework) { |
|
|
|
|
|
|
|
|
// sort by time and by group
|
|
|
// sort by time and by group
|
|
|
combinedData.sort(function (a, b) { |
|
|
combinedData.sort(function (a, b) { |
|
|
if (a.x === b.x) { |
|
|
|
|
|
|
|
|
if (a.screen_x === b.screen_x) { |
|
|
return a.groupId < b.groupId ? -1 : 1; |
|
|
return a.groupId < b.groupId ? -1 : 1; |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
return a.x - b.x; |
|
|
|
|
|
|
|
|
return a.screen_x - b.screen_x; |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
@ -57,29 +57,29 @@ Bargraph.draw = function (groupIds, processedGroupData, framework) { |
|
|
group = framework.groups[combinedData[i].groupId]; |
|
|
group = framework.groups[combinedData[i].groupId]; |
|
|
var minWidth = 0.1 * group.options.barChart.width; |
|
|
var minWidth = 0.1 * group.options.barChart.width; |
|
|
|
|
|
|
|
|
key = combinedData[i].x; |
|
|
|
|
|
|
|
|
key = combinedData[i].screen_x; |
|
|
var heightOffset = 0; |
|
|
var heightOffset = 0; |
|
|
if (intersections[key] === undefined) { |
|
|
if (intersections[key] === undefined) { |
|
|
if (i+1 < combinedData.length) {coreDistance = Math.abs(combinedData[i+1].x - key);} |
|
|
|
|
|
if (i > 0) {coreDistance = Math.min(coreDistance,Math.abs(combinedData[i-1].x - key));} |
|
|
|
|
|
|
|
|
if (i+1 < combinedData.length) {coreDistance = Math.abs(combinedData[i+1].screen_x - key);} |
|
|
|
|
|
if (i > 0) {coreDistance = Math.min(coreDistance,Math.abs(combinedData[i-1].screen_x - key));} |
|
|
drawData = Bargraph._getSafeDrawData(coreDistance, group, minWidth); |
|
|
drawData = Bargraph._getSafeDrawData(coreDistance, group, minWidth); |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
var nextKey = i + (intersections[key].amount - intersections[key].resolved); |
|
|
var nextKey = i + (intersections[key].amount - intersections[key].resolved); |
|
|
var prevKey = i - (intersections[key].resolved + 1); |
|
|
var prevKey = i - (intersections[key].resolved + 1); |
|
|
if (nextKey < combinedData.length) {coreDistance = Math.abs(combinedData[nextKey].x - key);} |
|
|
|
|
|
if (prevKey > 0) {coreDistance = Math.min(coreDistance,Math.abs(combinedData[prevKey].x - key));} |
|
|
|
|
|
|
|
|
if (nextKey < combinedData.length) {coreDistance = Math.abs(combinedData[nextKey].screen_x - key);} |
|
|
|
|
|
if (prevKey > 0) {coreDistance = Math.min(coreDistance,Math.abs(combinedData[prevKey].screen_x - key));} |
|
|
drawData = Bargraph._getSafeDrawData(coreDistance, group, minWidth); |
|
|
drawData = Bargraph._getSafeDrawData(coreDistance, group, minWidth); |
|
|
intersections[key].resolved += 1; |
|
|
intersections[key].resolved += 1; |
|
|
|
|
|
|
|
|
if (group.options.stack === true) { |
|
|
if (group.options.stack === true) { |
|
|
if (combinedData[i].y < group.zeroPosition) { |
|
|
if (combinedData[i].y < group.zeroPosition) { |
|
|
heightOffset = intersections[key].accumulatedNegative; |
|
|
heightOffset = intersections[key].accumulatedNegative; |
|
|
intersections[key].accumulatedNegative += group.zeroPosition - combinedData[i].y; |
|
|
|
|
|
|
|
|
intersections[key].accumulatedNegative += group.zeroPosition - combinedData[i].screen_y; |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
heightOffset = intersections[key].accumulatedPositive; |
|
|
heightOffset = intersections[key].accumulatedPositive; |
|
|
intersections[key].accumulatedPositive += group.zeroPosition - combinedData[i].y; |
|
|
|
|
|
|
|
|
intersections[key].accumulatedPositive += group.zeroPosition - combinedData[i].screen_y; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
else if (group.options.barChart.sideBySide === true) { |
|
|
else if (group.options.barChart.sideBySide === true) { |
|
@ -89,12 +89,12 @@ Bargraph.draw = function (groupIds, processedGroupData, framework) { |
|
|
else if (group.options.barChart.align === 'right') {drawData.offset += 0.5*drawData.width;} |
|
|
else if (group.options.barChart.align === 'right') {drawData.offset += 0.5*drawData.width;} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
DOMutil.drawBar(combinedData[i].x + drawData.offset, combinedData[i].y - heightOffset, drawData.width, group.zeroPosition - combinedData[i].y, group.className + ' vis-bar', framework.svgElements, framework.svg, group.style); |
|
|
|
|
|
|
|
|
DOMutil.drawBar(combinedData[i].screen_x + drawData.offset, combinedData[i].screen_y - heightOffset, drawData.width, group.zeroPosition - combinedData[i].screen_y, group.className + ' vis-bar', framework.svgElements, framework.svg, group.style); |
|
|
// draw points
|
|
|
// draw points
|
|
|
if (group.options.drawPoints.enabled === true) { |
|
|
if (group.options.drawPoints.enabled === true) { |
|
|
let pointData = { |
|
|
let pointData = { |
|
|
x:combinedData[i].x, |
|
|
|
|
|
y:combinedData[i].y - heightOffset, |
|
|
|
|
|
|
|
|
screen_x:combinedData[i].screen_x, |
|
|
|
|
|
screen_y:combinedData[i].screen_y - heightOffset, |
|
|
groupId: combinedData[i].groupId, |
|
|
groupId: combinedData[i].groupId, |
|
|
label: combinedData[i].label, |
|
|
label: combinedData[i].label, |
|
|
}; |
|
|
}; |
|
@ -116,16 +116,16 @@ Bargraph._getDataIntersections = function (intersections, combinedData) { |
|
|
var coreDistance; |
|
|
var coreDistance; |
|
|
for (var i = 0; i < combinedData.length; i++) { |
|
|
for (var i = 0; i < combinedData.length; i++) { |
|
|
if (i + 1 < combinedData.length) { |
|
|
if (i + 1 < combinedData.length) { |
|
|
coreDistance = Math.abs(combinedData[i + 1].x - combinedData[i].x); |
|
|
|
|
|
|
|
|
coreDistance = Math.abs(combinedData[i + 1].screen_x - combinedData[i].screen_x); |
|
|
} |
|
|
} |
|
|
if (i > 0) { |
|
|
if (i > 0) { |
|
|
coreDistance = Math.min(coreDistance, Math.abs(combinedData[i - 1].x - combinedData[i].x)); |
|
|
|
|
|
|
|
|
coreDistance = Math.min(coreDistance, Math.abs(combinedData[i - 1].screen_x - combinedData[i].screen_x)); |
|
|
} |
|
|
} |
|
|
if (coreDistance === 0) { |
|
|
if (coreDistance === 0) { |
|
|
if (intersections[combinedData[i].x] === undefined) { |
|
|
|
|
|
intersections[combinedData[i].x] = {amount: 0, resolved: 0, accumulatedPositive: 0, accumulatedNegative: 0}; |
|
|
|
|
|
|
|
|
if (intersections[combinedData[i].screen_x] === undefined) { |
|
|
|
|
|
intersections[combinedData[i].screen_x] = {amount: 0, resolved: 0, accumulatedPositive: 0, accumulatedNegative: 0}; |
|
|
} |
|
|
} |
|
|
intersections[combinedData[i].x].amount += 1; |
|
|
|
|
|
|
|
|
intersections[combinedData[i].screen_x].amount += 1; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
@ -172,11 +172,11 @@ Bargraph.getStackedYRange = function(combinedData, groupRanges, groupIds, groupL |
|
|
if (combinedData.length > 0) { |
|
|
if (combinedData.length > 0) { |
|
|
// sort by time and by group
|
|
|
// sort by time and by group
|
|
|
combinedData.sort(function (a, b) { |
|
|
combinedData.sort(function (a, b) { |
|
|
if (a.x === b.x) { |
|
|
|
|
|
|
|
|
if (a.screen_x === b.screen_x) { |
|
|
return a.groupId < b.groupId ? -1 : 1; |
|
|
return a.groupId < b.groupId ? -1 : 1; |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
return a.x - b.x; |
|
|
|
|
|
|
|
|
return a.screen_x - b.screen_x; |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
var intersections = {}; |
|
|
var intersections = {}; |
|
@ -190,20 +190,20 @@ Bargraph.getStackedYRange = function(combinedData, groupRanges, groupIds, groupL |
|
|
|
|
|
|
|
|
Bargraph._getStackedYRange = function (intersections, combinedData) { |
|
|
Bargraph._getStackedYRange = function (intersections, combinedData) { |
|
|
var key; |
|
|
var key; |
|
|
var yMin = combinedData[0].y; |
|
|
|
|
|
var yMax = combinedData[0].y; |
|
|
|
|
|
|
|
|
var yMin = combinedData[0].screen_y; |
|
|
|
|
|
var yMax = combinedData[0].screen_y; |
|
|
for (var i = 0; i < combinedData.length; i++) { |
|
|
for (var i = 0; i < combinedData.length; i++) { |
|
|
key = combinedData[i].x; |
|
|
|
|
|
|
|
|
key = combinedData[i].screen_x; |
|
|
if (intersections[key] === undefined) { |
|
|
if (intersections[key] === undefined) { |
|
|
yMin = yMin > combinedData[i].y ? combinedData[i].y : yMin; |
|
|
|
|
|
yMax = yMax < combinedData[i].y ? combinedData[i].y : yMax; |
|
|
|
|
|
|
|
|
yMin = yMin > combinedData[i].screen_y ? combinedData[i].screen_y : yMin; |
|
|
|
|
|
yMax = yMax < combinedData[i].screen_y ? combinedData[i].screen_y : yMax; |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
if (combinedData[i].y < 0) { |
|
|
|
|
|
intersections[key].accumulatedNegative += combinedData[i].y; |
|
|
|
|
|
|
|
|
if (combinedData[i].screen_y < 0) { |
|
|
|
|
|
intersections[key].accumulatedNegative += combinedData[i].screen_y; |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
intersections[key].accumulatedPositive += combinedData[i].y; |
|
|
|
|
|
|
|
|
intersections[key].accumulatedPositive += combinedData[i].screen_y; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|