Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

javascript - How can I shade sections of a JSXGraph board?

I have a jsxgraph board set up with a few simple lines, like this:

my jsxgraph

I want to shade portions of it, for example, the white area between the blue line and the dotted line. What's the best way to go about this? I've looked in the API but none of the provided elements jumped out at me, and I haven't seen any examples so far that do what I'm trying to do. Is the Inequality element easily extendable to multiple lines?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can use a polygon and hide the edges and vertices of the polygon. Here is an example:

    var board = JXG.JSXGraph.initBoard("jxgbox", {
        boundingbox: [-1, 5, 5, -1],
        axis: true
    });

    var p1 = board.create('point', [2, 1]);
    var shade = board.create('polygon', [p1, [0,p1.Y()], [0,4]],
            {
                borders: {visible: false},
                vertices: {visible: false}
            }
        );

If you need to intersect the coordinate axes, you can access them with board.defaultAxes.x and board.defaultAxes.y.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...