我正在尝试使用Marrisjs生成图表,而我之前已经做过几次,没有问题。但是由于某种原因,这真让人讨厌!有什么想法我要去哪里吗?
<h4 class="card-title">Pedigree Chart</h4>
<div id="morris-line-chart"></div>
$(function () {
"use strict";
// LINE CHART
Morris.Line({
element: 'morris-line-chart'
, resize: true
, data: [
{y: 'April',pedigrees_added: 1},
{y: 'March',pedigrees_added: 0},
{y: 'February',pedigrees_added: 3},
{y: 'January',pedigrees_added: 0},
{y: 'December',pedigrees_added: 0},
{y: 'November',pedigrees_added: 0},
{y: 'October',pedigrees_added: 0},
{y: 'September',pedigrees_added: 0},
{y: 'August',pedigrees_added: 0},
{y: 'July',pedigrees_added: 0},
{y: 'June',pedigrees_added: 0},
{y: 'May',pedigrees_added: 0},]
, xkey: 'y'
, ykeys: ['pedigrees_added']
, labels: ['New added']
, gridLineColor: '#eef0f2'
, lineColors: ['#009efb']
, lineWidth: 1
, hideHover: 'auto'
});
});
问题是该信息似乎无法正确显示。我猜某处有语法错误。
答案 0 :(得分:1)
此库仅适用于日期x轴。 (https://morrisjs.github.io/morris.js/lines.html)像这样更改您的数据:
data: [
{y: '2019-04',pedigrees_added: 1},
{y: '2019-03',pedigrees_added: 0},
{y: '2019-02',pedigrees_added: 3},
{y: '2019-01',pedigrees_added: 0},
{y: '2018-12',pedigrees_added: 0},
{y: '2018-11',pedigrees_added: 0},
{y: '2018-10',pedigrees_added: 0},
{y: '2018-09',pedigrees_added: 0},
{y: '2018-08',pedigrees_added: 0},
{y: '2018-07',pedigrees_added: 0},
{y: '2018-06',pedigrees_added: 0},
{y: '2018-05',pedigrees_added: 0}]