xcharts X轴排序无效问题

gongweixin 发布于 2013/11/21 17:09
阅读 370
收藏 0
 


<html>

<head> <meta charset="utf-8"> <title>A Basic xChart</title> <script src="d3.v3.min.js"></script> <script src="xcharts.js"></script> <link rel="stylesheet" href="styles.css"> <link rel="stylesheet" href="xcharts.css"> </head> <body> <figure id="myChart"></figure> <script> var data = { "xScale": "ordinal", "yScale": "linear", "main": [ { "className": ".pizza", "data": [ { "x": "一", "y": 4 }, { "x": "二", "y": 4 }, { "x": "三", "y": 4 }, { "x": "四", "y": 4 }, { "x": "五", "y": 8 } ] } ] }; chart = new xChart('bar', data, '#myChart',{ "sortX" : function(a,b){ var a1; if(a.x=="一"){a1 = 1;} if(a.x=="二"){a1 = 2;} if(a.x=="三"){a1 = 3;} if(a.x=="四"){a1 = 4;} if(a.x=="五"){a1 = 5;} var b1; if(b.x=="一"){b1 = 1;} if(b.x=="二"){b1 = 2;} if(b.x=="三"){b1 = 3;} if(b.x=="四"){b1 = 4;} if(b.x=="五"){b1 = 5;} return a1==b1?0:(a1 < b1)?-1:1; }}); </script> </body> </html>

结果如图:

请问 @王振威 @赵紫川 @陈达  为什么X轴排序不是按照一二三四五来的? 感谢回答。



加载中
返回顶部
顶部