123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <template>
- <div style="margin-top: 10px;">
- <canvas :id="id" width="740" height="400"/>
- </div>
- </template>
- <script lang="ts">
- import { SGraphAreaGroupItem, SGraphScene, SGraphView } from "@persagy-web/graph/lib";
- import { Component, Vue } from "vue-property-decorator";
- import { v1 as uuid } from "uuid";
- /**
- * 区域组
- *
- * @author 郝洁 <haojie@persagy.com>
- */
- @Component
- export default class AreaCanvas extends Vue {
- id: string = uuid();
- view: SGraphView | undefined;
- areaData = {
- outline: [
- [
- [{x: 0, y: 0}, {x: 0, y: 1000}, {x: 1000, y: 1000}, {x: 1000, y: 0}],
- [{x: 200, y: 200}, {x: 800, y: 200}, {x: 800, y: 800}, {x: 200, y: 800}]
- ],
- [
- [{x: 1000, y: 1000}, {x: 1200, y: 1000}, {x: 1200, y: 1200}, {x: 1000, y: 1200}]
- ]
- ],
- style: {
- "default": {
- "stroke": "#cccccc",
- "fill": "SLinearGradient{0,0;0,1200;0,#ff483bff;0.5,#04ff00ff;1,#3d4effff;}",
- "lineWidth": 2,
- "effect": {}
- },
- "selected": {
- "stroke": "#66ff66",
- "fill": "SRadialGradient{500,500,50;500,500,800;0,#ff483bff;0.5,#04ff00ff;1,#3d4effff;}",
- "lineWidth": 3,
- "effect": {}
- },
- "disabled": {
- "stroke": "#333333",
- "fill": "#afafaf",
- "lineWidth": 1,
- "effect": {}
- },
- }
- };
- mounted() {
- this.init();
- };
- init() {
- this.view = new SGraphView(this.id);
- const scene = new SGraphScene();
- const item = new SGraphAreaGroupItem(null, this.areaData);
- item.selectable = true;
- item._resizeable = false;
- scene.addItem(item);
- this.view.scene = scene;
- this.view.fitSceneToView();
- this.view.scalable = false;
- }
- }
- </script>
- <style scoped>
- </style>
|