Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chart is now working, still hard coded data
maybe we have an js expert who can find a cleaner approach to solve the "this" problem.
- Loading branch information
1 parent
69a01b6
commit da3fe2a
Showing
1 changed file
with
16 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,6 +62,7 @@ | |
value: 20, | ||
}, | ||
}, | ||
|
||
ready: function() { | ||
this.$.ajaxCaller.generateRequest(); | ||
}, | ||
|
@@ -73,7 +74,6 @@ | |
handleResponse: function (data) { | ||
//var goodData = this._normalizeJSON(data.detail.response); | ||
var diagramDiv = this.$.diagram; | ||
alert(this.squareSpacing); | ||
var svgWidth = 500, | ||
svgHeight = 500; | ||
//values should range between 1, 100 | ||
|
@@ -106,18 +106,19 @@ | |
}, | ||
|
||
_showLabel: function (d, i) { | ||
var polyElement = Polymer.dom(this).parentNode.parentNode.parentNode; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
JakobEdding
Contributor
|
||
d3.select('svg').append('rect') | ||
.attr('x', this._spaceSquareHor(d, i) - 3) | ||
.attr('y', this._spaceSquareVert(d, i) - 14) | ||
.attr('x', polyElement._spaceSquareHor(d, i) - 3) | ||
.attr('y', polyElement._spaceSquareVert(d, i) - 14) | ||
.attr('id', 'label-bg-' + i) | ||
.attr('fill', 'white') | ||
.attr('width', 60) | ||
.attr('height', 15); | ||
|
||
d3.select('svg').append('text') | ||
.text(d + ' at ' + i) | ||
.attr('x', this._spaceSquareHor(d, i)) | ||
.attr('y', this._spaceSquareVert(d, i) - 3) | ||
.attr('x', polyElement._spaceSquareHor(d, i)) | ||
.attr('y', polyElement._spaceSquareVert(d, i) - 3) | ||
.attr('id', 'label-' + i) | ||
.style('font-size', '0.8em') | ||
.attr('fill', 'black'); | ||
|
@@ -129,11 +130,19 @@ | |
}, | ||
|
||
_spaceSquareHor: function (d, i) { | ||
return this.squareSpacing * (i % this.squaresPerRow); | ||
var polyElement = this; | ||
if (Polymer.dom(this).childNodes.length == 0) { | ||
var polyElement = Polymer.dom(this).parentNode.parentNode.parentNode; | ||
} | ||
return polyElement.squareSpacing * (i % polyElement.squaresPerRow); | ||
}, | ||
|
||
_spaceSquareVert: function (d, i) { | ||
return this.squareSpacing * (Math.floor(i / this.squaresPerRow)); | ||
var polyElement = this; | ||
if (Polymer.dom(this).childNodes.length == 0) { | ||
var polyElement = Polymer.dom(this).parentNode.parentNode.parentNode; | ||
} | ||
return polyElement.squareSpacing * (Math.floor(i / polyElement.squaresPerRow)); | ||
}, | ||
/** | ||
* Normalizes the data supplied by the API to work with Plotly | ||
|
is there any smarter way to do this, by classname or identifier maybe? Could also ask Franz