morrisjs javascript有什么问题? http://jsbin.com/dituriheje/edit?html,js,output)

<!DOCTYPE html>
<html>
<head>
<script src="http://cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js"></script>
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
  <script src="http://cdn.oesmith.co.uk/morris-0.4.1.min.js"></script>
<meta charset=utf-8 />
<title>Morris.js Line Chart Example</title>
</head>
<body>
  <div id="js_stats"></div>
  <script>
    Morris.Line({
  element: 'js_stats',
  data: [
    {y: "Context 1", E: 0.0247578, D: 0.0250694, A: 0.00205555, B: 0.00445085, C: 0.011262},
    {y: "Context 2", E: 0.025153150000000003, D: 0.02422775, A: 0.0020365, B: 0.0044665, C: 0.01137645},
    {y: "Context 3", E: 0.0254322, D: 0.024671699999999998, A: 0.0022679, B: 0.0045135, C: 0.0114602},
    {y: "Context 4", E: 0.02603472, D: 0.0249791, A: 0.00192968, B: 0.00437542, C: 0.01089924},
    {y: "Context 5", E: 0.025053799999999998, D: 0.0255343, A: 0.002256, B: 0.0043565, C: 0.0118452}
  ],
  xkey: 'y',
  ykeys: ["A", "B", "C", "D", "E"],
  labels: ["Strategy 1", "Strategy 2", "Strategy 3", "Strategy 4", "Strategy 5"]
});
  </script>
</body>
</html>

如果我在y轴上设置int值(如y: "1"),则莫里斯可以工作。但是我想要String值,该怎么做?

最佳答案

莫里斯图通常会尝试将字符串解释为日期(Docs)。
为了防止这种情况,请使用parseTime : false作为Morris.line的选项。

然后由您决定是否有足够的空间容纳标签。您可以使用xLabelAngle使其适应。

07-24 09:55