Skip to content

Commit

Permalink
Add gridlines and axis layers.
Browse files Browse the repository at this point in the history
  • Loading branch information
jheer committed Apr 17, 2013
1 parent f0f3b90 commit 456746a
Show file tree
Hide file tree
Showing 10 changed files with 412 additions and 498 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vega",
"version": "1.2.1",
"version": "1.3.0",
"description": "Vega Runtime",
"keywords": [
"vega",
Expand Down
1 change: 1 addition & 0 deletions src/_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ vg.config.axis = {
ticks: 10,
padding: 3,
axisColor: "#000",
gridColor: "#ccc",
tickColor: "#000",
tickLabelColor: "#000",
axisWidth: 1,
Expand Down
2 changes: 1 addition & 1 deletion src/_package.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var vg = {};

// semantic versioning
vg.version = '1.2.1';
vg.version = '1.3.0';

// type checking functions
var toString = Object.prototype.toString;
Expand Down
16 changes: 11 additions & 5 deletions src/canvas/marks.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,26 +379,32 @@ vg.canvas.marks = (function() {

function drawGroup(g, scene, bounds) {
if (!scene.items.length) return;
var items = scene.items, group,
var items = scene.items, group, axes,
renderer = this, gx, gy, i, n, j, m;

drawRect(g, scene, bounds);

for (i=0, n=items.length; i<n; ++i) {
group = items[i];
axes = group.axisItems || [];
gx = group.x || 0;
gy = group.y || 0;

// render group contents
g.save();
g.translate(gx, gy);
if (bounds) bounds.translate(-gx, -gy);
if (bounds) bounds.translate(-gx, -gy);
for (j=0, m=axes.length; j<m; ++j) {
if (axes[j].def.layer === "back") {
renderer.draw(g, axes[j], bounds);
}
}
for (j=0, m=group.items.length; j<m; ++j) {
renderer.draw(g, group.items[j], bounds);
}
if (group.axisItems) {
for (j=0, m=group.axisItems.length; j<m; ++j) {
renderer.draw(g, group.axisItems[j], bounds);
for (j=0, m=axes.length; j<m; ++j) {
if (axes[j].def.layer !== "back") {
renderer.draw(g, axes[j], bounds);
}
}
if (bounds) bounds.translate(gx, gy);
Expand Down
7 changes: 7 additions & 0 deletions src/parse/axes.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ vg.parse.axes = (function() {

// axis offset
if (def.offset) axis.offset(def.offset);

// axis layer
if (def.layer) axis.layer(def.layer);

// axis grid lines
if (def.grid) axis.grid(def.grid);

// style properties
if (def.properties) {
Expand All @@ -82,6 +88,7 @@ vg.parse.axes = (function() {
if (p.minorTicks) axis.minorTickProperties(p.minorTicks);
}
if (p.labels) axis.tickLabelProperties(p.labels);
if (p.grid) axis.gridLineProperties(p.grid);
if (p.axis) axis.domainProperties(p.axis);
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/parse/properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ vg.parse.properties = (function() {
? vg.str(ref.value)
: "item.datum.data";

// get value from enclosing group
if (ref.group !== undefined) {
val = "group." + ref.group;
}

// get data field value
if (ref.field !== undefined) {
val = "item.datum["
Expand Down
Loading

0 comments on commit 456746a

Please sign in to comment.