Examples of JsDoubleFunction


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

        final PVLinearScale y = PV.Scale.linear(0, 2200).range(0, h);

        PVPanel vis = getPVPanel().width(w).height(h).margin(19.5).right(40);

        vis.add(PV.Layout.Stack()).layers(Cause.values()).values(crimea)
                .x(new JsDoubleFunction() {
                    public double f(JsArgs args) {
                        CrimeanWarData d = args.getObject();
                        return x.fd(d.getDate());
                    }
                }).y(new JsDoubleFunction() {
                    public double f(JsArgs args) {
                        CrimeanWarData d = args.getObject(0);
                        Cause t = args.getObject(1);
                        return y.fd(t.getValue(d));
                    }
View Full Code Here

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

        datax.push(JsUtils.toJsArrayNumber(1, 1.2, 1.7, 1.5, 1.7));
        datax.push(JsUtils.toJsArrayNumber(.5, 1, .8, 1.1, 1.3));
        datax.push(JsUtils.toJsArrayNumber(.2, .5, .8, .9, 1));

        vis.add(PV.Layout.Stack()).layers(data).order("inside-out")
                .offset("wiggle").x(new JsDoubleFunction() {
                    public double f(JsArgs args) {
                        PVMark _this = args.getThis();
                        return x.fd(_this.index());
                    }
                }).y(new JsDoubleFunction() {
                    public double f(JsArgs args) {
                        double d = args.getDouble(0);
                        return y.fd(d);
                    }
                }).layer().add(PV.Area).fillStyle(new JsFunction<PVColor>() {
View Full Code Here

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

        PVPanel vis = getPVPanel().width(w).height(h).bottom(20).left(20)
                .right(10).top(5);

        /* The bars. */
        PVBar bar = vis.add(PV.Bar).dataDouble(data)
                .top(new JsDoubleFunction() {
                    public double f(JsArgs args) {
                        PVMark _this = args.getThis();
                        return y.fd(_this.index());
                    }
                }).height(new JsDoubleFunction() {
                    public double f(JsArgs args) {
                        return y.rangeBand();
                    }
                }).left(0).width(new JsDoubleFunction() {
                    public double f(JsArgs args) {
                        double d = args.getDouble();
                        return x.fd(d);
                    }
                });
View Full Code Here

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

        PVPanel vis = getPVPanel().width(w).height(h).right(60).bottom(20);

        /* Price of The Quarter of Wheat. */
        vis.add(PV.Area).data(wheat).interpolate(STEP_AFTER).bottom(0)
                .height(new JsDoubleFunction() {
                    public double f(JsArgs args) {
                        WheatPrice d = args.getObject();
                        return y.fd(d.wheat);
                    }
                }).left(new JsDoubleFunction() {
                    public double f(JsArgs args) {
                        WheatPrice d = args.getObject();
                        return x.fd(d.year);
                    }
                }).fillStyle("#aaa").strokeStyle("#999").add(PV.Rule);

        /* Weekly Wages of a Good Mechanic. */
        vis.add(PV.Area)
                .data(new JsFunction<JsArrayGeneric<WheatPrice>>() {
                    public JsArrayGeneric<WheatPrice> f(JsArgs args) {
                        JsArrayGeneric<WheatPrice> array = JsUtils
                                .createJsArrayGeneric();
                        for (WheatPrice w : wheat) {
                            if (!Double.isNaN(w.wages)) {
                                array.push(w);
                            }
                        }
                        return array;
                    }
                }).left(new JsDoubleFunction() {
                    public double f(JsArgs args) {
                        WheatPrice d = args.getObject();
                        return x.fd(d.year);
                    }
                }).bottom(0).height(new JsDoubleFunction() {
                    public double f(JsArgs args) {
                        WheatPrice d = args.getObject();
                        return y.fd(d.wages);
                    }
                }).fillStyle("hsla(195, 50%, 80%, .75)").anchor(TOP)
                .add(PV.Line)
                .fillStyle((String) null).lineWidth(4)
                .strokeStyle("lightcoral").add(PV.Line)
                .top(new JsDoubleFunction() {
                    public double f(JsArgs args) {
                        PVLine _this = args.getThis();
                        return _this.proto().top() + 1.5;
                    }
                }).lineWidth(1.5).strokeStyle("black");

        vis.add(PV.Label).left(130).bottom(31).font("italic 10px serif")
                .text("Weekly Wages of a Good Mechanic");

        /* Y-axis. */
        vis.add(PV.Rule).bottom(-.5).add(PV.Rule).data(PV.range(0, 100, 10))
                .bottom(y).strokeStyle("rgba(255, 255, 255, .2)").anchor(RIGHT)
                .add(PV.Label).visible(new JsBooleanFunction() {
                    public boolean f(JsArgs args) {
                        PVMark _this = args.getThis();
                        return _this.index() % 2 == 0;
                    }
                }).text(new JsStringFunction() {
                    public String f(JsArgs args) {
                        int s = args.getInt();
                        return s + (s != 0 ? "" : " shillings");
                    }
                });

        /* X-axis. */
        vis.add(PV.Rule).data(PV.range(1560, 1830, 10)).bottom(0).left(x)
                .height(-4).add(PV.Rule).data(PV.range(1600, 1850, 50))
                .bottom(0).height(h).strokeStyle("rgba(0, 0, 0, .2)")
                .anchor(BOTTOM).add(PV.Label).textMargin(8);

        /* Monarchs. */
        vis.add(PV.Bar).data(monarch).height(5).top(new JsDoubleFunction() {
            public double f(JsArgs args) {
                PVMark _this = args.getThis();
                Monarch d = args.getObject();
                return (!d.commonwealth && (_this.index() % 2 == 1)) ? 15 : 10;
            }
        }).fillStyle(new JsStringFunction() {
            public String f(JsArgs args) {
                Monarch d = args.getObject();
                return d.commonwealth ? null : "#000";
            }
        }).strokeStyle("#000").left(new JsDoubleFunction() {
            public double f(JsArgs args) {
                Monarch d = args.getObject();
                return x.fd(d.start);
            }
        }).width(new JsDoubleFunction() {
            public double f(JsArgs args) {
                Monarch d = args.getObject();
                return x.fd(d.end) - x.fd(d.start);
            }
        }).anchor(CENTER).add(PV.Label).textBaseline(TOP).textMargin(6)
View Full Code Here

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

    private void createVisualization(Pair[] points) {
        int w = 400;
        int h = 200;

        final PVLinearScale x = PV.Scale.linear(points, new JsDoubleFunction() {
            public double f(JsArgs args) {
                Pair d = args.getObject();
                return d.x;
            }
        }).range(0, w);
        final PVLinearScale y = PV.Scale.linear(0, 4).range(0, h);

        /* The root panel. */
        PVPanel vis = getPVPanel().width(w).height(h).bottom(20).left(20)
                .right(10).top(5);

        /* Y-axis and ticks. */
        vis.add(PV.Rule).data(y.ticks(5)).bottom(y)
                .strokeStyle(new JsStringFunction() {
                    public String f(JsArgs args) {
                        double d = args.getDouble();
                        return d != 0 ? "#eee" : "#000";
                    }
                }).anchor(LEFT).add(PV.Label).text(y.tickFormat());

        /* X-axis and ticks. */
        vis.add(PV.Rule).data(x.ticks()).visible(new JsBooleanFunction() {
            public boolean f(JsArgs args) {
                double d = args.getDouble();
                return d != 0;
            }
        }).left(x).bottom(-5).height(5).anchor(BOTTOM).add(PV.Label)
                .text(x.tickFormat());

        /* The area with top line. */
        vis.add(PV.Area).data(points).bottom(1).left(new JsDoubleFunction() {
            public double f(JsArgs args) {
                Pair d = args.getObject();
                return x.fd(d.x);
            }
        }).height(new JsDoubleFunction() {
            public double f(JsArgs args) {
                Pair d = args.getObject();
                return y.fd(d.y);
            }
        }).fillStyle("rgb(121,173,210)").anchor(TOP).add(PV.Line).lineWidth(3);
View Full Code Here

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

    private void createVisualization(JsArrayGeneric<Pair> data) {
        /* Sizing and scales. */
        int w = 400;
        int h = 200;
        final PVLinearScale x = PV.Scale.linear(data, new JsDoubleFunction() {
            public double f(JsArgs args) {
                Pair d = args.getObject(0);
                return d.x;
            }
        }).range(0, w);
        final PVLinearScale y = PV.Scale.linear(0, 4).range(0, h);

        /* The root panel. */
        PVPanel vis = getPVPanel().width(w).height(h).bottom(20).left(20)
                .right(10).top(5);

        /* X-axis ticks. */
        vis.add(PV.Rule).data(x.ticks()).visible(new JsBooleanFunction() {
            public boolean f(JsArgs args) {
                double d = args.getDouble(0);
                return d > 0;
            }
        }).left(x).strokeStyle("#eee").add(PV.Rule).bottom(-5).height(5)
                .strokeStyle("#000").anchor(BOTTOM).add(PV.Label)
                .text(x.tickFormat());

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

        /* The line. */
        vis.add(PV.Line).data(data).interpolate(STEP_AFTER)
                .left(new JsDoubleFunction() {
                    public double f(JsArgs args) {
                        Pair d = args.getObject(0);
                        return x.fd(d.x);
                    }
                }).bottom(new JsDoubleFunction() {
                    public double f(JsArgs args) {
                        Pair d = args.getObject(0);
                        return y.fd(d.y);
                    }
                }).lineWidth(3);
View Full Code Here

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

        return this;
    }

    private void createVisualization(JsArrayGeneric<Bullet> bullets) {
        PVPanel vis = getPVPanel().data(bullets).width(400).height(30)
                .margin(20).left(100).top(new JsDoubleFunction() {
                    public double f(JsArgs args) {
                        PVMark _this = args.getThis();
                        return 10 + _this.index() * 60;
                    }
                });
View Full Code Here

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

    /**
     * Scales are functions. Use this method if the scale returns double values
     * and you need to call it with a function.
     */
    public final JsDoubleFunction fd(final JsDoubleFunction f) {
        return new JsDoubleFunction() {
            public double f(JsArgs args) {
                return fd(f.f(args));
            }
        };
    }
View Full Code Here

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

    /**
     * Scales are functions. Use this method if the scale returns double values
     * and you need to call it with a function.
     */
    public final JsDoubleFunction fd(final JsStringFunction f) {
        return new JsDoubleFunction() {
            public double f(JsArgs args) {
                return fd(f.f(args));
            }
        };
    }
View Full Code Here

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

    /**
     * Scales are functions. Use this method if the scale returns double values
     * and you need to call it with a function.
     */
    public final JsDoubleFunction fd(final JsFunction<JsDate> f) {
        return new JsDoubleFunction() {
            public double f(JsArgs args) {
                return fd(f.f(args));
            }
        };
    }
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.