2022-08-30 15:36:33 +00:00
|
|
|
/*
|
|
|
|
Copyright 2021-present The maxGraph project Contributors
|
|
|
|
Copyright (c) 2006-2020, JGraph Ltd
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2022-01-08 01:49:35 +00:00
|
|
|
import { Graph, EdgeStyle, constants, KeyHandler } from '@maxgraph/core';
|
2021-04-21 11:36:38 +00:00
|
|
|
|
|
|
|
import { globalTypes } from '../.storybook/preview';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
title: 'Icon_Images/Indicators',
|
|
|
|
argTypes: {
|
2021-08-30 14:20:26 +00:00
|
|
|
...globalTypes,
|
|
|
|
},
|
2021-04-21 11:36:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const Template = ({ label, ...args }) => {
|
|
|
|
const container = document.createElement('div');
|
|
|
|
container.style.position = 'relative';
|
|
|
|
container.style.overflow = 'hidden';
|
|
|
|
container.style.width = `${args.width}px`;
|
|
|
|
container.style.height = `${args.height}px`;
|
|
|
|
container.style.background = 'url(/images/grid.gif)';
|
|
|
|
container.style.cursor = 'default';
|
|
|
|
|
|
|
|
// Creates the graph inside the given container
|
2021-08-30 14:20:26 +00:00
|
|
|
const graph = new Graph(container);
|
2021-04-21 11:36:38 +00:00
|
|
|
graph.setConnectable(true);
|
2022-01-08 01:49:35 +00:00
|
|
|
new KeyHandler(graph);
|
2021-04-21 11:36:38 +00:00
|
|
|
|
|
|
|
// Enables moving of vertex labels
|
|
|
|
graph.vertexLabelsMovable = true;
|
|
|
|
|
|
|
|
// Creates a style with an indicator
|
|
|
|
let style = graph.getStylesheet().getDefaultVertexStyle();
|
|
|
|
|
2021-05-02 06:04:34 +00:00
|
|
|
style.shape = 'label';
|
|
|
|
style.verticalAlign = 'bottom';
|
|
|
|
style.indicatorShape = 'ellipse';
|
|
|
|
style.indicatorWidth = 34;
|
|
|
|
style.indicatorHeight = 34;
|
|
|
|
style.imageVerticalAlign = 'top'; // indicator v-alignment
|
|
|
|
style.imageAlign = 'center';
|
|
|
|
style.indicatorColor = 'green';
|
2021-10-20 01:28:27 +00:00
|
|
|
// delete style.strokeColor; // transparent
|
|
|
|
// delete style.fillColor; // transparent
|
2021-04-21 11:36:38 +00:00
|
|
|
|
|
|
|
// Creates a style with an indicator
|
|
|
|
style = graph.getStylesheet().getDefaultEdgeStyle();
|
|
|
|
|
2021-08-30 14:20:26 +00:00
|
|
|
style.edge = EdgeStyle.ElbowConnector;
|
2022-01-08 01:49:35 +00:00
|
|
|
style.elbow = constants.ELBOW.VERTICAL;
|
2021-05-02 06:04:34 +00:00
|
|
|
style.rounded = true;
|
2021-04-21 11:36:38 +00:00
|
|
|
|
|
|
|
// Gets the default parent for inserting new cells. This
|
|
|
|
// is normally the first child of the root (ie. layer 0).
|
|
|
|
const parent = graph.getDefaultParent();
|
|
|
|
|
|
|
|
// Adds cells to the model in a single step
|
2022-01-08 01:49:35 +00:00
|
|
|
graph.batchUpdate(() => {
|
2021-04-21 11:36:38 +00:00
|
|
|
graph.insertVertex(parent, null, 'Bottom Label', 80, 80, 80, 60);
|
2022-04-17 06:58:35 +00:00
|
|
|
graph.insertVertex(parent, null, 'Top Label', 200, 80, 60, 60, {
|
|
|
|
indicatorShape: 'actor',
|
|
|
|
indicatorWidth: 28,
|
|
|
|
indicatorColor: 'blue',
|
|
|
|
imageVerticalAlign: 'bottom',
|
|
|
|
verticalAlign: 'top',
|
|
|
|
});
|
|
|
|
graph.insertVertex(parent, null, 'Right Label', 300, 80, 120, 60, {
|
|
|
|
indicatorShape: 'cloud',
|
|
|
|
indicatorWidth: 40,
|
|
|
|
indicatorColor: '#00FFFF',
|
|
|
|
imageVerticalAlign: 'center',
|
|
|
|
verticalAlign: 'middle',
|
|
|
|
imageAlign: 'left',
|
|
|
|
align: 'left',
|
|
|
|
spacingLeft: 44,
|
|
|
|
});
|
2022-01-08 01:49:35 +00:00
|
|
|
});
|
2021-04-21 11:36:38 +00:00
|
|
|
|
|
|
|
return container;
|
2021-08-30 14:20:26 +00:00
|
|
|
};
|
2021-04-21 11:36:38 +00:00
|
|
|
|
2021-08-30 14:20:26 +00:00
|
|
|
export const Default = Template.bind({});
|