FusionCharts flash中文问题,X 轴正常,Y轴不能显示中文

来源:互联网 发布:太原电脑网络培训机构 编辑:程序博客网 时间:2024/04/29 13:40

         最近在项目中遇到了使用FusionCharts发现报表的Y轴只要是中文就不显示,X轴没有问题,最后终于解决了此问题:

         出现此问题的原因是因为FusionCharts不支持Y轴中文竖写,所以最简单的办法把中文横写就可以了。当然目前最新版本的FusionCharts可能已经解决此问题,鉴于项目中使用老版本的可能比较多!

         1、如果是FusionCharts付费版则可以直接加入rotateYAxisName=‘0’属性即可让Y轴的中文横写。

chart.setDataXML("<chart rotateYAxisName='0' baseFont='宋体' baseFontSize='14' palette='10'  caption='标题' xAxisName='X轴' yAxisName='Y轴' showValues='0' decimals='0' formatNumberScale='0' useRoundEdges='1'><set label='1月' value='462' /><set label='Feb' value='857' /><set label='Mar' value='671' /><set label='Apr' value='494' /><set label='May' value='761' link='javascript:myJS()'/><set label='Jun' value='960' link='n-DemoLinkPages/DemoLink1.html'/></chart>")

        2、如果是FusionCharts Free版本的需要破解flash的源文件。可以使用sothink swf decompiler工具修改falsh的源代码,下载地址如下:

 下载地址:   http://www.swf-decompiler.com/

找到yAxisName的相关代码

Js代码if (this.Params.xAxisName != "")       {           createText(this.getLevel(), this.Params.xAxisName, this.Objects.Canvas.xPos + this.Objects.Canvas.width / 2, this.Objects.Canvas.height + this.Objects.xAxisName.yPos, this.Params.outCnvBaseFont, this.Params.outCnvBaseFontSize, this.Params.outCnvBaseFontColor, true, "center", "center", null, true);       } // end if       if (this.Params.yAxisName != "")       {           createText(this.getLevel(), this.Params.yAxisName, this.Objects.yAxisName.xPos, this.Objects.Canvas.yPos + this.Objects.Canvas.height / 2, "Verdana", Number(this.Params.outCnvBaseFontSize) + 1, this.Params.outCnvBaseFontColor, false, "center", "center", 270, true);       } // end if if (this.Params.xAxisName != "") { createText(this.getLevel(), this.Params.xAxisName, this.Objects.Canvas.xPos + this.Objects.Canvas.width / 2, this.Objects.Canvas.height + this.Objects.xAxisName.yPos, this.Params.outCnvBaseFont, this.Params.outCnvBaseFontSize, this.Params.outCnvBaseFontColor, true, "center", "center", null, true); } // end if if(this.Params.yAxisName != "") { createText(this.getLevel(), this.Params.yAxisName, this.Objects.yAxisName.xPos, this.Objects.Canvas.yPos + this.Objects.Canvas.height / 2, "Verdana", Number(this.Params.outCnvBaseFontSize) + 1, this.Params.outCnvBaseFontColor, false, "center", "center", 270, true); } // end if

注意看倒数第五 和倒数第二个参数 输出x轴和y轴有什么不同,改成一样就可以了,编译好把flash替换了刷新页面 横向输出的y轴坐标已经出来了。还有点不完美的就是第一个字显示了一半被截掉了一样,看着不舒服,解决办法: 输出的xml根节点加上chartLeftMargin=‘30’属性。ok大功告成

修改后如下图所示:

原创粉丝点击