From 7767dde5c379bdcd48b0875797fc039f6f99ed3c Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sun, 15 May 2016 16:58:06 +0200 Subject: [PATCH] Positioning bug fixes --- Chart/Chart.js | 20 ++++++++++++++------ Chart/PieChart.js | 3 ++- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/Chart/Chart.js b/Chart/Chart.js index 55862b3..1b9da05 100644 --- a/Chart/Chart.js +++ b/Chart/Chart.js @@ -301,14 +301,14 @@ } if (this.dataSettings.info.visible && this.dataSettings.marker.visible) { - var div = this.chartSelect.append("div").attr("class", "charttooltip").style("opacity", 0); + let div = this.chartSelect.append("div").attr("class", "charttooltip").style("opacity", 0); div.html(self.axis.x.label.text + ': ' + 100 + "
" + self.axis.y.label.text + ': ' + 100); /* todo: allow also hover on charts without marker... not possible since hover only on marker and not on point? */ temp.on("mouseover", function (d) { - var dim = div.node().getBoundingClientRect(); - var pos = this.getBoundingClientRect(); + let dim = div.node().getBoundingClientRect(); + let pos = this.getBoundingClientRect(); div.transition() .duration(200) @@ -329,7 +329,7 @@ jsOMS.Chart.prototype.drawText = function (svg) { - var temp, pos = 0, topmargin = 0; + let temp, pos = 0, topmargin = 0; /* No subtitle without title */ if (this.subtitle !== undefined && this.subtitle.visible && this.title !== undefined && this.title.visible) { @@ -372,12 +372,21 @@ } if (this.footer !== undefined && this.footer.visible) { + let spacer = 0; + + // if no x axis available an element less will be drawn and the footer + // will be out of bounds. + // todo: fix this hacky solution!!! + if(typeof this.axis.x === 'undefined') { + spacer = -this.margin.top; + } + pos = this.calculateHorizontalPosition(this.footer.position); temp = svg.append("text") .attr("class", "footer") .attr('y', this.dimension.height - - this.margin.bottom + this.position.footer.top + 10) + - this.margin.bottom + spacer + this.position.footer.top) .attr('x', pos) .style("text-anchor", this.footer.anchor) .text(this.footer.text); @@ -393,7 +402,6 @@ jsOMS.Chart.prototype.drawAxis = function (svg, xAxis1, yAxis1) { - // draw clipper let defs = svg.append('svg').attr('width', 0).attr('height', 0).append('defs'), pos = 0, temp; defs.append('clipPath').attr('id', 'clipper1').append('rect').attr('x', 0).attr('y', 0) diff --git a/Chart/PieChart.js b/Chart/PieChart.js index ad3f5bf..6759378 100644 --- a/Chart/PieChart.js +++ b/Chart/PieChart.js @@ -48,6 +48,7 @@ dataPointEnter = temp[0]; dataPoint = temp[1]; + // todo: create own legend drawing this.chart.drawLegend(svg, dataPointEnter, dataPoint); this.chart.drawText(svg); @@ -87,7 +88,7 @@ }).enter().append('path') .attr("transform", "translate(" + (this.chart.dimension.width / 2) + "," - + (this.chart.dimension.height / 2 - this.chart.margin.bottom) + ")") + + (this.chart.dimension.height / 2 - this.chart.margin.bottom - this.chart.margin.top + 10) + ")") .attr('fill', function (d) { return self.chart.color(d.data.name);