Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix NS_ERROR with Mozilla and wrong size #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions radar.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,21 @@ nv.models.radar = function() {
;


//============================================================
// Hack to fix Moz Firefox getBBox error when display:none
//------------------------------------------------------------
function getElemBBox(svgElement) {
try {
return svgElement.getBBox();
}
catch (TypeError) {
return {
width: svgElement.offsetWidth,
height: svgElement.offsetHeight
}
}
}

//============================================================
// chart function
//------------------------------------------------------------
Expand Down Expand Up @@ -180,7 +195,7 @@ nv.models.radar = function() {
axisLabels.exit().remove();

g_axisLabels.selectAll('.axis-label')
.attr("x", function (d, i) { return availableWidth / 2 + radius * Math.sin(i * radians / allAxis.length) + (this.getBBox().width / 1.5) * Math.sin(i * radians / allAxis.length); })
.attr("x", function (d, i) { return availableWidth / 2 + radius * Math.sin(i * radians / allAxis.length) + (getElemBBox(this).width / 1.5) * Math.sin(i * radians / allAxis.length); })
.attr("y", function (d, i) { return availableHeight / 2 - radius * Math.cos(i * radians / allAxis.length) - 20 * Math.cos(i * radians / allAxis.length); });

// series
Expand All @@ -200,8 +215,7 @@ nv.models.radar = function() {

function getSeriesNodeData(d) {
return d.values.map(function (v, i) {
var delta = (v.value - min) / (adjustedMax - min);

var delta = (v.value - min) / (range.slice(-1).pop() - min);
return {
x: availableWidth / 2 + radius * delta * factor * Math.sin(i * radians / allAxis.length),
y: availableHeight / 2 - radius * delta * factor * Math.cos(i * radians / allAxis.length),
Expand Down Expand Up @@ -339,4 +353,4 @@ nv.models.radar = function() {

nv.utils.initOptions(chart);
return chart;
};
};