Permalink
Browse files

Move test to HTML. Round to Integers for crisper images.

  • Loading branch information...
1 parent ddaa2d4 commit 20085c5e9eeffaa32da526b30d68972369356cee @topfunky committed Sep 8, 2009
Showing with 19 additions and 24 deletions.
  1. +11 −0 index.html
  2. +4 −12 js-sparklines.pkg.js
  3. +4 −12 lib/js-sparklines.js
View
@@ -20,5 +20,16 @@
<script src="lib/cufon-yui.js" type="text/javascript" charset="utf-8"></script>
<script src="lib/04b21_400.font.js" type="text/javascript" charset="utf-8"></script>
<script src="lib/js-sparklines.js" type="text/javascript" charset="utf-8"></script>
+
+ <script>
+ JSSparklines('chart',
+ [5, 5, 5, 5, 21, 10, 3, 24, 18, 50, 0, 1, 45, 29, 5, 21, 10, 3, 24, 18, 50, 0, 1, 45, 29, 5, 21, 10, 3, 24, 18, 50, 0, 1, 45, 29, 5, 21, 10, 3, 24, 18, 50, 0, 1, 45, 29, 5, 21, 10, 3, 24, 18, 50, 0, 1, 45, 29, 5, 21, 10, 3, 24, 18, 50, 0, 1, 45, 29, 5, 21, 10, 3, 24, 18, 50, 0, 1, 45, 29, 5, 21, 10, 3, 24, 18, 50, 0, 1, 45, 29, 5, 21, 10, 3, 24, 18, 50, 0, 1, 45, 29, 5, 21, 10, 3, 24, 18, 50, 0, 1, 45, 29, 5],
+ {
+ width:400,
+ height:30,
+ title:"Sparkline Graph",
+ target:25,
+ good_threshold:20});
+ </script>
</body>
</html>
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -44,16 +44,16 @@ var JSSparklines = function(elementName, datapoints, opts) {
bar_color = color_bad;
var x_offset = i*(bar_width+spacing) + this.width - datapoints.length*(bar_width+spacing);
- var y_offset = (height - normalizedDatapoints[i]*height);
+ var y_offset = parseInt(height - normalizedDatapoints[i]*height);
var bar = paper.rect(x_offset,
y_offset,
bar_width,
- normalizedDatapoints[i]*height)
+ Math.ceil(normalizedDatapoints[i]*height))
bar.attr({stroke:'transparent', fill:bar_color});
}
// Target line
- var targetLine = paper.rect(0, (height - (target/maximumDatavalue)*height), width, 1)
+ var targetLine = paper.rect(0, parseInt(height - (target/maximumDatavalue)*height), width, 1)
targetLine.attr({stroke:"transparent", fill:color_target});
// Text title
@@ -67,14 +67,6 @@ var JSSparklines = function(elementName, datapoints, opts) {
// HACK: Redraw title over background after font calculations
paper.print(2, (this.height - 6),
- opts.title.toUpperCase(), paper.getFont("04b21", 400), 8);
+ opts.title.toUpperCase(), paper.getFont("04b21", 400), 8).attr({fill:"#555555"});
}
-JSSparklines('chart',
- [5, 5, 5, 5, 21, 10, 3, 24, 18, 50, 0, 1, 45, 29, 5, 21, 10, 3, 24, 18, 50, 0, 1, 45, 29, 5, 21, 10, 3, 24, 18, 50, 0, 1, 45, 29, 5, 21, 10, 3, 24, 18, 50, 0, 1, 45, 29, 5, 21, 10, 3, 24, 18, 50, 0, 1, 45, 29, 5, 21, 10, 3, 24, 18, 50, 0, 1, 45, 29, 5, 21, 10, 3, 24, 18, 50, 0, 1, 45, 29, 5, 21, 10, 3, 24, 18, 50, 0, 1, 45, 29, 5, 21, 10, 3, 24, 18, 50, 0, 1, 45, 29, 5, 21, 10, 3, 24, 18, 50, 0, 1, 45, 29, 5],
- {
- width:400,
- height:30,
- title:"Sparkline Graph",
- target:25,
- good_threshold:20});

0 comments on commit 20085c5

Please sign in to comment.