Examples of JsStringFunction


Examples of org.thechiselgroup.choosel.protovis.client.jsutil.JsStringFunction

        bullet.tick().add(PV.Rule).anchor(BOTTOM).add(PV.Label)
                .text(bullet.x().tickFormat());

        bullet.anchor(LEFT).add(PV.Label).font("bold 12px sans-serif")
                .textAlign(RIGHT).textBaseline(BOTTOM)
                .text(new JsStringFunction() {
                    public String f(JsArgs args) {
                        Bullet d = args.getObject(0);
                        return d.title;
                    }
                });

        bullet.anchor(LEFT).add(PV.Label).textStyle("#616161").textAlign(RIGHT)
                .textBaseline(TOP).text(new JsStringFunction() {
            public String f(JsArgs args) {
                Bullet d = args.getObject(0);
                return d.subtitle;
            }
        });
View Full Code Here

Examples of org.thechiselgroup.choosel.protovis.client.jsutil.JsStringFunction

        bullet.tick().add(PV.Rule).anchor(BOTTOM).add(PV.Label)
                .text(bullet.x().tickFormat());

        bullet.anchor(LEFT).add(PV.Label).font("12px sans-serif")
                .textAlign(RIGHT).textBaseline(BOTTOM)
                .text(new JsStringFunction() {
                    public String f(JsArgs args) {
                        Bullet d = args.getObject(0);
                        return d.title;
                    }
                });

        bullet.anchor(LEFT).add(PV.Label).textStyle("#616161").textAlign(RIGHT)
                .textBaseline(TOP).text(new JsStringFunction() {
            public String f(JsArgs args) {
                Bullet d = args.getObject(0);
                return d.subtitle;
            }
        });
View Full Code Here

Examples of org.thechiselgroup.choosel.protovis.client.jsutil.JsStringFunction

        bullet.tick().add(PV.Rule).anchor(BOTTOM).add(PV.Label)
                .text(bullet.x().tickFormat());

        bullet.anchor(LEFT).add(PV.Label).font("bold 12px sans-serif")
                .textAlign(RIGHT).textBaseline(BOTTOM)
                .text(new JsStringFunction() {
                    public String f(JsArgs args) {
                        Bullet d = args.getObject(0);
                        return d.title;
                    }
                });

        bullet.anchor(LEFT).add(PV.Label).textStyle("#616161").textAlign(RIGHT)
                .textBaseline(TOP).text(new JsStringFunction() {
            public String f(JsArgs args) {
                Bullet d = args.getObject(0);
                return d.subtitle;
            }
        });
View Full Code Here

Examples of org.thechiselgroup.choosel.protovis.client.jsutil.JsStringFunction

        PVPanel vis = getPVPanel().width(w).height(h).top(10);

        vis.add(PV.Rule).data(y.ticks(5)).bottom(y).strokeStyle("#ccc")
                .anchor(LEFT).add(PV.Label).font("bold 12px sans-serif")
                .textMargin(6).textAlign(LEFT).textBaseline(BOTTOM)
                .text(new JsStringFunction() {
                    public String f(JsArgs args) {
                        double d = args.getDouble(0);
                        return "$" + JsUtils.toFixed(d, 2);
                    }
                });

        vis.add(PV.Rule).data(x.ticks(5)).left(x).strokeStyle("#ccc")
                .anchor(TOP).add(PV.Label).font("bold 12px sans-serif")
                .textMargin(6).textAlign(LEFT).textBaseline(TOP)
                .text(new JsStringFunction() {
                    public String f(JsArgs args) {
                        double d = args.getDouble(0);
                        return PV.Format.number().format(d) + " mi";
                    }
                });

        vis.add(PV.Line).data(driving).interpolate(CARDINAL).lineWidth(4)
                .strokeStyle("black").left(new JsDoubleFunction() {
                    public double f(JsArgs args) {
                        DrivingStats d = args.getObject(0);
                        return x.fd(d.miles);
                    }
                }).bottom(new JsDoubleFunction() {
                    public double f(JsArgs args) {
                        DrivingStats d = args.getObject(0);
                        return y.fd(d.gas);
                    }
                }).add(PV.Dot).lineWidth(1).fillStyle("white")
                .anchor(new JsStringFunction() {
                    public String f(JsArgs args) {
                        DrivingStats d = args.getObject(0);
                        return d.side;
                    }
                }).add(PV.Label).text(new JsStringFunction() {
                    public String f(JsArgs args) {
                        DrivingStats d = args.getObject(0);
                        return "" + d.year;
                    }
                });
View Full Code Here

Examples of org.thechiselgroup.choosel.protovis.client.jsutil.JsStringFunction

    private void createVisualization(JsArrayGeneric<Experiment> experiments) {
        int w = 860;
        int h = 300;
        final PVOrdinalScale x = PV.Scale.ordinal(experiments,
                new JsStringFunction() {
                    public String f(JsArgs args) {
                        Experiment d = args.getObject(0);
                        return d.id;
                    }
                }).splitBanded(0, w, 3d / 5d);
        final PVLinearScale y = PV.Scale.linear(0, 1).range(0, h);
        double s = x.rangeBand() / 2d;

        PVPanel vis = getPVPanel().width(w).height(h).margin(20);

        /* Add the y-axis rules */
        vis.add(PV.Rule).data(y.ticks()).bottom(y)
                .strokeStyle(new JsStringFunction() {
                    public String f(JsArgs args) {
                        double d = args.getDouble();
                        return (d == 0 || d == 1) ? "#000" : "#ccc";
                    }
                }).anchor(LEFT).add(PV.Label).text(y.tickFormat());

        /* Add a panel for each data point */
        PVPanel points = vis.add(PV.Panel).data(experiments)
                .left(new JsDoubleFunction() {
                    public double f(JsArgs args) {
                        Experiment d = args.getObject();
                        return x.fd(d.id);
                    }
                }).width(s * 2);

        /* Add the experiment id label */
        points.anchor(BOTTOM).add(PV.Label).textBaseline(TOP)
                .text(new JsStringFunction() {
                    public String f(JsArgs args) {
                        Experiment d = args.getObject();
                        return d.id;
                    }
                });

        /* Add the range line */
        points.add(PV.Rule).left(s).bottom(new JsDoubleFunction() {
            public double f(JsArgs args) {
                Experiment d = args.getObject();
                return y.fd(d.min);
            }
        }).height(new JsDoubleFunction() {
            public double f(JsArgs args) {
                Experiment d = args.getObject();
                return y.fd(d.max) - y.fd(d.min);
            }
        });

        /* Add the min and max indicators */
        points.add(PV.Rule).data(new JsFunction<JsArrayNumber>() {
            public JsArrayNumber f(JsArgs args) {
                Experiment d = args.getObject();
                return JsUtils.toJsArrayNumber(d.min, d.max);
            }
        }).bottom(y).left(s / 2).width(s);

        /* Add the upper/lower quartile ranges */
        points.add(PV.Bar).bottom(new JsDoubleFunction() {
            public double f(JsArgs args) {
                Experiment d = args.getObject();
                return y.fd(d.lq);
            }
        }).height(new JsDoubleFunction() {
            public double f(JsArgs args) {
                Experiment d = args.getObject();
                return y.fd(d.uq) - y.fd(d.lq);
            }
        }).fillStyle(new JsStringFunction() {
            public String f(JsArgs args) {
                Experiment d = args.getObject();
                return d.median > .5 ? "#aec7e8" : "#ffbb78";
            }
        }).strokeStyle("black").lineWidth(1).antialias(false);
View Full Code Here

Examples of org.thechiselgroup.choosel.protovis.client.jsutil.JsStringFunction

        vis.add(PV.Rule).data(x.ticks()).left(x).strokeStyle("#eee")
                .anchor(BOTTOM).add(PV.Label).text(x.tickFormat());

        /* Prices. */
        vis.add(PV.Rule).data(y.ticks(7)).bottom(y).left(-10).right(-10)
                .strokeStyle(new JsStringFunction() {
                    public String f(JsArgs args) {
                        double d = args.getDouble();
                        return d % 10 != 0 ? "#ccc" : "#333";
                    }
                }).anchor(LEFT).add(PV.Label).textStyle(new JsStringFunction() {
                    public String f(JsArgs args) {
                        double d = args.getDouble();
                        return d % 10 != 0 ? "#999" : "#333";
                    }
                }).text(y.tickFormat());

        /* Candlestick. */
        vis.add(PV.Rule).data(days).left(new JsDoubleFunction() {
            public double f(JsArgs args) {
                DaySummary d = args.getObject();
                return x.fd(d.jsDate);
            }
        }).bottom(new JsDoubleFunction() {
            public double f(JsArgs args) {
                DaySummary d = args.getObject();
                return y.fd(Math.min(d.high, d.low));
            }
        }).height(new JsDoubleFunction() {
            public double f(JsArgs args) {
                DaySummary d = args.getObject();
                return Math.abs(y.fd(d.high) - y.fd(d.low));
            }
        }).strokeStyle(new JsStringFunction() {
            public String f(JsArgs args) {
                DaySummary d = args.getObject();
                return d.open < d.close ? "#ae1325" : "#06982d";
            }
        }).add(PV.Rule).bottom(new JsDoubleFunction() {
View Full Code Here

Examples of org.thechiselgroup.choosel.protovis.client.jsutil.JsStringFunction

                        return _this.fillStyle().darker();
                    }
                }).event(PV.Event.MOUSEOVER, nodeMouseOverHandler)
                .event(PV.Event.MOUSEOUT, nodeMouseOutHandler)
                .anchor(PVAlignment.BOTTOM).add(PV.Label)
                .text(new JsStringFunction() {
                    public String f(JsArgs args) {
                        PVNode d = args.getObject();
                        return d.nodeName();
                    }
                }).events("all")
View Full Code Here

Examples of org.thechiselgroup.choosel.protovis.client.jsutil.JsStringFunction

                .nodes(PVDom.create(root, new FlareData.UnitDomAdapter())
                        .nodes()).depth(85).breadth(7.25).orient("radial");

        tree.link().add(PV.Line);

        tree.node().add(PV.Dot).fillStyle(new JsStringFunction() {
            public String f(JsArgs args) {
                PVDomNode n = args.getObject();
                return n.firstChild() != null ? "#aec7e8" : "#ff7f0e";
            }
        });
View Full Code Here

Examples of org.thechiselgroup.choosel.protovis.client.jsutil.JsStringFunction

                        vis.set("i", -1);
                        _this.render();
                    }
                });

        treemap.label().add(PV.Label).font(new JsStringFunction() {
            public String f(JsArgs args) {
                PVDomNode d = args.getObject();
                MyDataClass myData = d.nodeObject();
                return myData.getAdditionalProperty() != null ? "bold 20px serif"
                        : "italic 10px serif";
View Full Code Here

Examples of org.thechiselgroup.choosel.protovis.client.jsutil.JsStringFunction

                    public double f(JsArgs args) {
                        PVMark _this = args.getThis();
                        return _this.index() * bigAngle + bigAngle / 2
                                - Math.PI / 2;
                    }
                }).fillStyle(new JsStringFunction() {
                    public String f(JsArgs args) {
                        Antibiotics d = args.getObject(0);
                        return gramColor.get(d.gram);
                    }
                });

        /* Antibiotics. */
        bg.add(PV.Wedge).angle(smallAngle).startAngle(new JsDoubleFunction() {
            public double f(JsArgs args) {
                PVWedge _this = args.getThis();
                return _this.proto().startAngle() + smallAngle;
            }
        }).outerRadius(new JsDoubleFunction() {
            public double f(JsArgs args) {
                Antibiotics d = args.getObject();
                return radius(d.penicillin, a, b);
            }
        }).fillStyle(drugColor.get("Penicillin")).add(PV.Wedge)
                .startAngle(new JsDoubleFunction() {
                    public double f(JsArgs args) {
                        PVWedge _this = args.getThis();
                        return _this.proto().startAngle() + 2 * smallAngle;
                    }
                }).outerRadius(new JsDoubleFunction() {
                    public double f(JsArgs args) {
                        Antibiotics d = args.getObject();
                        return radius(d.streptomycin, a, b);
                    }
                }).fillStyle(drugColor.get("Streptomycin")).add(PV.Wedge)
                .outerRadius(new JsDoubleFunction() {
                    public double f(JsArgs args) {
                        Antibiotics d = args.getObject();
                        return radius(d.neomycin, a, b);
                    }
                }).fillStyle(drugColor.get("Neomycin"));

        /* Circular grid lines. */
        bg.add(PV.Dot).data(PV.range(-3, 4)).fillStyle((String) null)
                .strokeStyle("#eee").lineWidth(1).size(new JsDoubleFunction() {
                    public double f(JsArgs args) {
                        int i = args.getInt();
                        return Math.pow(radius(Math.pow(10, i), a, b), 2);
                    }
                }).anchor(TOP).add(PV.Label).visible(new JsBooleanFunction() {
                    public boolean f(JsArgs args) {
                        int i = args.getInt();
                        return i < 3;
                    }
                }).textBaseline(MIDDLE).text(new JsStringFunction() {
                    public String f(JsArgs args) {
                        int i = args.getInt();
                        return JsUtils.toFixed(Math.pow(10, i), (i > 0) ? 0
                                : -i);
                    }
                });

        /* Radial grid lines. */
        bg.add(PV.Wedge).data(PV.range(antibiotics.length + 1))
                .innerRadius(innerRadius - 10).outerRadius(outerRadius + 10)
                .fillStyle((String) null).strokeStyle("black").angle(0);

        /* Labels. */
        bg.anchor(OUTER).add(PV.Label).textAlign(CENTER)
                .text(new JsStringFunction() {
                    public String f(JsArgs args) {
                        Antibiotics d = args.getObject();
                        return d.bacteria;
                    }
                });

        /* Antibiotic legend. */
        vis.add(PV.Bar).data(drugColor.keySet()).right(width / 2 + 3)
                .top(new JsDoubleFunction() {
                    public double f(JsArgs args) {
                        PVMark _this = args.getThis();
                        return height / 2 - 28 + _this.index() * 18;
                    }
                }).fillStyle(new JsStringFunction() {
                    public String f(JsArgs args) {
                        String d = args.getObject();
                        return drugColor.get(d);
                    }
                }).width(36).height(12).anchor(RIGHT).add(PV.Label)
                .textMargin(6).textAlign(LEFT);

        /* Gram-stain legend. */
        vis.add(PV.Dot).data(gramColor.keySet()).left(width / 2 - 20)
                .bottom(new JsDoubleFunction() {
                    public double f(JsArgs args) {
                        PVMark _this = args.getThis();
                        return -60 + _this.index() * 18;
                    }
                }).fillStyle(new JsStringFunction() {
                    public String f(JsArgs args) {
                        String d = args.getObject();
                        return gramColor.get(d);
                    }
                }).strokeStyle((String) null).size(30).anchor(RIGHT)
                .add(PV.Label).textMargin(6).textAlign(LEFT)
                .text(new JsStringFunction() {
                    public String f(JsArgs args) {
                        String d = args.getObject();
                        return "Gram-" + d;
                    }
                });
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.