---
title: "关于mxgraph中图形颜色显示控制"
author: "Chevy"
date: "2011-10-19T17:25:56Z"
tags: []
categories: ["Web前端"]
slug: "mxgraph"
draft: false
lastmod: "2011-10-19T17:25:56Z"
id: 1202141
url: "https://chevy.iteye.com/blog/1202141"
---

今天搞了一下ext、mxgraph的东西，之前都是同事在搞，今天也是小小的学习吧。

 

在mxgraph里如果要想让图形变色，需要这么几步，确定是哪个图形，然后就是变色的方式，我这里重点展示变色方式的代码。

 

graph.setSelectionCell(cell);

 

确定好图形后，

 第一种 的效果是：

 

graph.setCellStyles(mxConstants.STYLE\_FILLCOLOR,”#FF0000”);

 

                           

 

 

第二种的效果是：

 

graph.setCellStyles(mxConstants.STYLE\_STROKECOLOR,,”#FF0000”);

 

 

 

 

第三种的效果是：

 

graph.setCellStyles(mxConstants.STYLE\_GRADIENTCOLOR,,”#FF0000”);

 

 

 

 

第四种的效果是：

 

graph.setCellStyles(mxConstants.STYLE\_FONTCOLOR,”#FF0000”);

 

 

 

 

大致是上面的四种方式吧，其中上面的第二种方式适合于线的变色。