Skip to content

Commit

Permalink
add a label with the current value
Browse files Browse the repository at this point in the history
  • Loading branch information
eklitzke committed Jul 13, 2010
1 parent a8d598a commit fda1869
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion main.html
Expand Up @@ -9,7 +9,7 @@
<link href="{{static_url('css/graphomatic.css')}}" rel="stylesheet" type="text/css">
<script src="{{static_url('js/jquery-1.4.2.js')}}"></script>
<script src="{{static_url('js/raphael.js')}}"></script>
<script src="{{static_url('js/rectangles.js')}}"></script>
<script src="{{static_url('js/graphomatic.js')}}"></script>
</head>
<body>
<h1>Graphomatic</h1>
Expand Down
11 changes: 11 additions & 0 deletions static/js/rectangles.js → static/js/graphomatic.js
Expand Up @@ -17,6 +17,7 @@ Raphael.el.red = function() {

G.Canvas = function (paper, params) {
this.clickedElement = null;
this.latestText = null;

this.background = [];

Expand Down Expand Up @@ -154,6 +155,15 @@ G.Canvas = function (paper, params) {
}
};

this.updateText = function (val) {
var txt = new String(val);
txt = txt.slice(0, 6);
if (this.latestText) {
this.latestText.remove();
}
this.latestText = paper.text(G.params.width - 50, 7, "now: " + txt).attr({"font-family": "Inconsolata, monospace", "font-size": "14px"});
}

this.addData = function (data) {
var data = JSON.parse(data);
return this.addPoint(data);
Expand All @@ -167,6 +177,7 @@ G.Canvas = function (paper, params) {
rect.toBack();
rect.purple();
this.moveLeft(rect);
this.updateText(data.val);

var lastBackground = this.background[this.background.length - 1];
lastBackground._contained = rect;
Expand Down

0 comments on commit fda1869

Please sign in to comment.