如何改变mxgraph中虚线的颜色

How change color of dotted line in mxgraph

我想在拖动顶点时将虚线的颜色从黑色更改为红色

问题:我想在拖动时将虚线颜色从黑色改为红色

这是它在拖动时的显示方式

我试图在 mxConstants 中找到拖动时的虚线颜色,但我没有找到它

function main(container)
        {
            // Checks if the browser is supported
            if (!mxClient.isBrowserSupported())
            {
                // Displays an error message if the browser is not supported.
                mxUtils.error('Browser is not supported!', 200, false);
            }
            else
            {
                // Disables the built-in context menu
                mxEvent.disableContextMenu(container);
                
                // Creates the graph inside the given container
                var graph = new mxGraph(container);

                // Enables rubberband selection
                new mxRubberband(graph);
                
                // Gets the default parent for inserting new cells. This
                // is normally the first child of the root (ie. layer 0).
                var parent = graph.getDefaultParent();
                                
                // Adds cells to the model in a single step
                graph.getModel().beginUpdate();
                try
                {
                    var v1 = graph.insertVertex(parent, null, 'Hello,', 20, 20, 80, 30);

                }
                finally
                {
                    // Updates the display
                    graph.getModel().endUpdate();
                }
            }
        };
<html>

<head>
    <title>Toolbar example for mxGraph</title>

    <script type="text/javascript">
        mxBasePath = 'https://jgraph.github.io/mxgraph/javascript/src';
    </script>
    <script src="https://jgraph.github.io/mxgraph/javascript/src/js/mxClient.js"></script>
    <script src="./app.js"></script>
</head>

<body onload="main(document.getElementById('graphContainer'))">


    <div id="graphContainer">

    </div>
</body>

</html>

请帮助我提前谢谢!!!

基于this,您可以通过以下代码实现:

mxGraphHandler.prototype.previewColor = 'red';

工作片段:

function main(container)
        {
      mxGraphHandler.prototype.previewColor = 'red';
    
            // Checks if the browser is supported
            if (!mxClient.isBrowserSupported())
            {
                // Displays an error message if the browser is not supported.
                mxUtils.error('Browser is not supported!', 200, false);
            }
            else
            {
                // Disables the built-in context menu
                mxEvent.disableContextMenu(container);
                
                // Creates the graph inside the given container
                var graph = new mxGraph(container);

                // Enables rubberband selection
                new mxRubberband(graph);
                
                // Gets the default parent for inserting new cells. This
                // is normally the first child of the root (ie. layer 0).
                var parent = graph.getDefaultParent();
                                
                // Adds cells to the model in a single step
                graph.getModel().beginUpdate();
                try
                {
                    var v1 = graph.insertVertex(parent, null, 'Hello,', 20, 20, 80, 30);

                }
                finally
                {
                    // Updates the display
                    graph.getModel().endUpdate();
                }
            }
        };
<html>

<head>
    <title>Toolbar example for mxGraph</title>

    <script type="text/javascript">
        mxBasePath = 'https://jgraph.github.io/mxgraph/javascript/src';
    </script>
    <script src="https://jgraph.github.io/mxgraph/javascript/src/js/mxClient.js"></script>
    <script src="./app.js"></script>
</head>

<body onload="main(document.getElementById('graphContainer'))">


    <div id="graphContainer">

    </div>
</body>

</html>