y 轴 morris 中的字符串值 javascript

String value in y axis morris javascript

这个 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 值,Morris 工作,比如 y: "1"。但是我想要字符串值,怎么办?

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

的选项

然后由您来确保标签有足够的空间。您可以玩 xLabelAngle 使其适合。