return result;
}
}).left(panelPosition).width(size);
/* Framed dot plots not along the diagonal. */
PVPanel plot = cell.add(PV.Panel).visible(new JsBooleanFunction() {
public boolean f(JsArgs args) {
TraitPair d = args.getObject(0);
return !d.px.equals(d.py);
}
}).strokeStyle("#aaa");
/* X-axis ticks. */
PVRule xtick = plot.add(PV.Rule)
.data(new JsFunction<JavaScriptObject>() {
public JavaScriptObject f(JsArgs args) {
TraitPair t = args.getObject();
return position.get(t.px).ticks(5);
};
}).left(new JsDoubleFunction() {
public double f(JsArgs args) {
double d = args.getDouble();
TraitPair t = args.getObject(1);
return position.get(t.px).fd(d);
};
}).strokeStyle("#eee");
/* Bottom label. */
xtick.anchor(BOTTOM).add(PV.Label).visible(new JsBooleanFunction() {
public boolean f(JsArgs args) {
return (cell.parent().index() == traits.length - 1)
&& (cell.index() % 2 == 0);
}
}).text(new JsStringFunction() {
public String f(JsArgs args) {
double d = args.getDouble();
TraitPair t = args.getObject(1);
return position.get(t.px).tickFormatDouble(d);
};
});
/* Top label. */
xtick.anchor(TOP).add(PV.Label).visible(new JsBooleanFunction() {
public boolean f(JsArgs args) {
return (cell.parent().index() == 0) && (cell.index() % 2 == 1);
}
}).text(new JsStringFunction() {
public String f(JsArgs args) {
double d = args.getDouble(0);
TraitPair t = args.getObject(1);
return position.get(t.px).tickFormatDouble(d);
};
});
/* Y-axis ticks. */
PVRule ytick = plot.add(PV.Rule)
.data(new JsFunction<JavaScriptObject>() {
public JavaScriptObject f(JsArgs args) {
TraitPair t = args.getObject(0);
return position.get(t.py).ticks(5);
};
}).bottom(new JsDoubleFunction() {
public double f(JsArgs args) {
double d = args.getDouble(0);
TraitPair t = args.getObject(1);
return position.get(t.py).fd(d);
};
}).strokeStyle("#eee");
/* Left label. */
ytick.anchor(LEFT).add(PV.Label).visible(new JsBooleanFunction() {
public boolean f(JsArgs args) {
return (cell.index() == 0) && (cell.parent().index() % 2 == 1);
}
}).text(new JsStringFunction() {
public String f(JsArgs args) {
double d = args.getDouble(0);
TraitPair t = args.getObject(1);
return position.get(t.py).tickFormatDouble(d);
};
});
/* Right label. */
ytick.anchor(RIGHT).add(PV.Label).visible(new JsBooleanFunction() {
public boolean f(JsArgs args) {
return (cell.index() == traits.length - 1)
&& (cell.parent().index() % 2 == 0);
}
}).text(new JsStringFunction() {
public String f(JsArgs args) {
double d = args.getDouble(0);
TraitPair t = args.getObject(1);
return position.get(t.py).tickFormatDouble(d);
};
});
/* Frame and dot plot. */
plot.add(PV.Dot).data(flowers).left(new JsDoubleFunction() {
public double f(JsArgs args) {
Flower d = args.getObject(0);
TraitPair t = args.getObject(1);
return position.get(t.px).fd(d.getTraitValue(t.px));
};
}).bottom(new JsDoubleFunction() {
public double f(JsArgs args) {
Flower d = args.getObject(0);
TraitPair t = args.getObject(1);
return position.get(t.py).fd(d.getTraitValue(t.py));
};
}).size(10).strokeStyle((String) null)
.fillStyle(new JsFunction<PVColor>() {
public PVColor f(JsArgs args) {
Flower d = args.getObject(0);
return color.fcolor(d.species);
}
});
/* Labels along the diagonal. */
cell.anchor(CENTER).add(PV.Label).visible(new JsBooleanFunction() {
public boolean f(JsArgs args) {
TraitPair t = args.getObject(0);
return t.px.equals(t.py);
}
}).font("bold 14px sans-serif").text(new JsStringFunction() {