Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
color picker tweaks and new bar graph
- Loading branch information
Showing
4 changed files
with
97 additions
and
3 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
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// ======================================================================== | ||
// SCUI.BarGraph Tests | ||
// ======================================================================== | ||
|
||
|
||
/*global module test htmlbody ok equals same stop start */ | ||
|
||
|
||
htmlbody('<style> .sc-static-layout { border: 1px red dotted; } </style>'); | ||
|
||
(function() { | ||
var pane = SC.ControlTestPane.design() | ||
|
||
.add("bar", SCUI.BarGraph, { | ||
layout: {width: 300, height: 300}, | ||
content: [55, 20, 13, 32, 5, 1, 2, 10] | ||
}); | ||
|
||
pane.show(); // add a test to show the test pane | ||
|
||
// .......................................................... | ||
// TEST VIEWS | ||
// | ||
module('SCUI.BarGraph ui', pane.standardSetup()); | ||
|
||
test("Check that all bar graphas are visible", function() { | ||
ok(pane.view('bar').get('isVisibleInWindow'), 'bar graph should be visible'); | ||
}); | ||
})(); | ||
|
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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// ========================================================================== | ||
// Project: SCUI.BarGraph | ||
// ========================================================================== | ||
/*globals SCUI Raphael*/ | ||
require('graphing/graphael'); | ||
require('graphing/gbar'); | ||
/** @class | ||
this view makes the awesome raphael.js bar graphs work in sproutcore | ||
@extends SC.View | ||
*/ | ||
|
||
SCUI.BarGraph = SC.View.extend( | ||
/** @scope SCUI.BarGraph.prototype */ { | ||
|
||
/* | ||
*/ | ||
content: null, | ||
|
||
|
||
render: function(context, firstTime){ | ||
}, | ||
|
||
didAppendToDocument: function(){ | ||
// this is where colorpickers created | ||
var layer = this.$().get(0); | ||
var r = Raphael(layer), | ||
fin = function () { | ||
this.flag = r.g.popup(this.bar.x, this.bar.y, this.bar.value || "0").insertBefore(this); | ||
}, | ||
fout = function () { | ||
this.flag.animate({opacity: 0}, 300, function () {this.remove();}); | ||
}, | ||
fin2 = function () { | ||
var y = [], res = []; | ||
for (var i = this.bars.length; i--;) { | ||
y.push(this.bars[i].y); | ||
res.push(this.bars[i].value || "0"); | ||
} | ||
this.flag = r.g.popup(this.bars[0].x, Math.min.apply(Math, y), res.join(", ")).insertBefore(this); | ||
}, | ||
fout2 = function () { | ||
this.flag.animate({opacity: 0}, 300, function () {this.remove();}); | ||
}; | ||
|
||
r.g.hbarchart(0, 0, 300, 220, [this.get('content')]).hover(fin, fout); | ||
this._raphael = r; | ||
}, | ||
|
||
willDestroyLayer: function(){ | ||
if(this._raphael) this._raphael.remove(); | ||
} | ||
|
||
}); | ||
|
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