1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| <script type="module"> let graph = new Graph({ "target": "graphWrapper" });
BgUtil.generateGrid(Object.assign({ "interval": 10, "graph": graph }, graph.getSize()));
let layer = graph.addLayer(); let [x, y, width, height] = [100, 80, 600, 100]; let colorBand = ["#FF0000", "#FFFF00", "#00FF00", "#00FFFF", "#0000FF", "#FF00FF", "#FF0000"]; let gradient = new Gradient({ "type": "linear", "coords": { "x1": x, "y1": y, "x2": x + width, "y2": y }, "colorStops": [ { "offset": "0", "color": colorBand[0] }, { "offset": "0.166", "color": colorBand[1] }, { "offset": "0.333", "color": colorBand[2] }, { "offset": "0.5", "color": colorBand[3] }, { "offset": "0.667", "color": colorBand[4] }, { "offset": "0.833", "color": colorBand[5] }, { "offset": "1", "color": colorBand[0] }, ] });
layer.getSource().add(new Rect({ x, y, width, height, "style": { "fillColor": gradient, "fillStyle": 1, "color": "none" } }));
for (let i = 0; i < 7; i++) { layer.getSource().add(new Text({ "x": x + width / 6 * i, "y": y + height + 40, "text": 60 * i, "style": { "fillStyle": 1, "fillColor": "#000000", "fontSize": 36, "fontName": "黑体", "textAlign": "center", "textBaseline": "middle" } })); } </script>
|