Skip to content

Commit

Permalink
Fix #14 texImage2D: no canvas.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesleesaunders committed Nov 14, 2018
1 parent 3dd02ab commit 2e948e3
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 50 deletions.
42 changes: 21 additions & 21 deletions build/d3-x3dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,9 +362,6 @@ function componentAxis () {
var tickSize = 1;
var tickPadding = 1;

/* Slice */
var slice = Array.prototype.slice;

var axisDirectionVectors = {
x: [1, 0, 0],
y: [0, 1, 0],
Expand Down Expand Up @@ -415,14 +412,6 @@ function componentAxis () {
return selection;
};

var defaultValues = scale.ticks ? scale.ticks.apply(scale, tickArguments) : scale.domain();
var values = tickValues === null ? defaultValues : tickValues;

var defaultFormat = scale.tickFormat ? scale.tickFormat.apply(scale, tickArguments) : function (d) {
return d;
};
var format = tickFormat === null ? defaultFormat : tickFormat;

var range = scale.range();
var range0 = range[0];
var range1 = range[range.length - 1];
Expand All @@ -434,7 +423,10 @@ function componentAxis () {

var path = selection.selectAll("transform").data([null]);

var tick = selection.selectAll(".tick").data(values, scale).order();
var tickValuesDefault = scale.ticks ? scale.ticks.apply(scale, tickArguments) : scale.domain();
tickValues = tickValues === null ? tickValuesDefault : tickValues;

var tick = selection.selectAll(".tick").data(tickValues, scale).order();

var tickExit = tick.exit();
var tickEnter = tick.enter().append("transform").attr("translation", function (t) {
Expand All @@ -444,19 +436,25 @@ function componentAxis () {
}).attr("class", "tick");

var line = tick.select(".tickLine");
var text = tick.select("billboard");

path = path.merge(path.enter().append("transform").attr("rotation", rotVec.join(" ")).attr("translation", dirVec.map(function (d) {
return d * (range0 + range1) / 2;
}).join(" ")).append("shape").call(makeSolid, color).attr("class", "domain"));
tick = tick.merge(tickEnter);
line = line.merge(tickEnter.append("transform"));
var newText = tickEnter.append("transform");

newText.attr("translation", tickDirVec.map(function (d) {
return -d * tickPadding;
})).append("billboard").attr("axisOfRotation", "0 0 0").append("shape").call(makeSolid, "black").append("text").attr("string", format).append("fontstyle").attr("size", 1.3).attr("family", "SANS").attr("style", "BOLD").attr("justify", "MIDDLE");
text = text.merge(newText);
var tickFormatDefault = scale.tickFormat ? scale.tickFormat.apply(scale, tickArguments) : function (d) {
return d;
};
tickFormat = tickFormat === null ? tickFormatDefault : tickFormat;

if (tickFormat !== "") {
var text = tick.select("billboard");
var newText = tickEnter.append("transform");
newText.attr("translation", tickDirVec.map(function (d) {
return -d * tickPadding;
})).append("billboard").attr("axisOfRotation", "0 0 0").append("shape").call(makeSolid, "black").append("text").attr("string", tickFormat).append("fontstyle").attr("size", 1.3).attr("family", "SANS").attr("style", "BOLD").attr("justify", "MIDDLE");
text = text.merge(newText);
}

tickExit.remove();
path.append("cylinder").attr("radius", 0.1).attr("height", range1 - range0);
Expand Down Expand Up @@ -522,6 +520,9 @@ function componentAxis () {
return arguments.length ? (tickDir = value, my) : tickDir;
};

/* Slice */
var slice = Array.prototype.slice;

/**
* Get Ticks
* @todo How is this used? Replace with tickArguments()?
Expand Down Expand Up @@ -620,8 +621,7 @@ function axisThreePlane () {

var yzAxis = componentAxis().scale(yScale).dir("y").tickDir("z").tickSize(zScale.range()[1] - zScale.range()[0]).color("red");

var yxAxis = componentAxis().scale(yScale).dir("y").tickDir("x").tickSize(xScale.range()[1] - xScale.range()[0]).tickFormat("") // FIXME: GitHub Issue #14
.color("red");
var yxAxis = componentAxis().scale(yScale).dir("y").tickDir("x").tickSize(xScale.range()[1] - xScale.range()[0]).tickFormat("").color("red");

var zxAxis = componentAxis().scale(zScale).dir("z").tickDir("x").tickSize(xScale.range()[1] - xScale.range()[0]).color("black");

Expand Down
2 changes: 1 addition & 1 deletion build/d3-x3dom.min.js

Large diffs are not rendered by default.

Binary file modified build/d3-x3dom.zip
Binary file not shown.
55 changes: 28 additions & 27 deletions src/component/axis.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ export default function() {
let tickSize = 1;
let tickPadding = 1;

/* Slice */
const slice = Array.prototype.slice;

const axisDirectionVectors = {
x: [1, 0, 0],
y: [0, 1, 0],
Expand Down Expand Up @@ -77,12 +74,6 @@ export default function() {
return selection;
};

const defaultValues = scale.ticks ? scale.ticks.apply(scale, tickArguments) : scale.domain();
const values = tickValues === null ? defaultValues : tickValues;

const defaultFormat = scale.tickFormat ? scale.tickFormat.apply(scale, tickArguments) : function(d) { return d; };
const format = tickFormat === null ? defaultFormat : tickFormat;

const range = scale.range();
const range0 = range[0];
const range1 = range[range.length - 1];
Expand All @@ -95,8 +86,11 @@ export default function() {
let path = selection.selectAll("transform")
.data([null]);

const tickValuesDefault = scale.ticks ? scale.ticks.apply(scale, tickArguments) : scale.domain();
tickValues = tickValues === null ? tickValuesDefault : tickValues;

let tick = selection.selectAll(".tick")
.data(values, scale).order();
.data(tickValues, scale).order();

const tickExit = tick.exit();
const tickEnter = tick.enter()
Expand All @@ -109,8 +103,6 @@ export default function() {
.attr("class", "tick");

let line = tick.select(".tickLine");
let text = tick.select("billboard");

path = path.merge(path.enter()
.append("transform")
.attr("rotation", rotVec.join(" "))
Expand All @@ -120,22 +112,28 @@ export default function() {
.attr("class", "domain"));
tick = tick.merge(tickEnter);
line = line.merge(tickEnter.append("transform"));
let newText = tickEnter.append("transform");

newText
.attr("translation", tickDirVec.map(function(d) { return -d * tickPadding; }))
.append("billboard")
.attr("axisOfRotation", "0 0 0")
.append("shape")
.call(makeSolid, "black")
.append("text")
.attr("string", format)
.append("fontstyle")
.attr("size", 1.3)
.attr("family", "SANS")
.attr("style", "BOLD")
.attr("justify", "MIDDLE");
text = text.merge(newText);
const tickFormatDefault = scale.tickFormat ? scale.tickFormat.apply(scale, tickArguments) : function(d) { return d; };
tickFormat = tickFormat === null ? tickFormatDefault : tickFormat;

if (tickFormat !== "") {
let text = tick.select("billboard");
let newText = tickEnter.append("transform");
newText
.attr("translation", tickDirVec.map(function(d) { return -d * tickPadding; }))
.append("billboard")
.attr("axisOfRotation", "0 0 0")
.append("shape")
.call(makeSolid, "black")
.append("text")
.attr("string", tickFormat)
.append("fontstyle")
.attr("size", 1.3)
.attr("family", "SANS")
.attr("style", "BOLD")
.attr("justify", "MIDDLE");
text = text.merge(newText);
}

tickExit.remove();
path
Expand Down Expand Up @@ -212,6 +210,9 @@ export default function() {
return arguments.length ? (tickDir = value, my) : tickDir;
};

/* Slice */
const slice = Array.prototype.slice;

/**
* Get Ticks
* @todo How is this used? Replace with tickArguments()?
Expand Down
2 changes: 1 addition & 1 deletion src/component/axisThreePlane.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default function() {
.dir("y")
.tickDir("x")
.tickSize(xScale.range()[1] - xScale.range()[0])
.tickFormat("") // FIXME: GitHub Issue #14
.tickFormat("")
.color("red");

const zxAxis = componentAxis()
Expand Down

0 comments on commit 2e948e3

Please sign in to comment.