我正在研究morris.js折线图。我的json是
[
{"uma":"34","time":"2017-05-11 12:30","mahes":"23","karan":"56"},
{"uma":"45","time":"2017-05-11 12:35","mahes":"45","karan":"56"},
{"uma":"34","time":"2017-05-11 12:38","mahes":"54","karan":"56"}
]
来自上面的json,我确信xkey和ykeys。所以我可以实现以下代码。
var stringify=JSON.stringify(abovejson);
var data =stringify,
config = {
data: JSON.parse(data),
xkey: 'time',
ykeys: ['uma','mahes','karan'],
labels: ['temperature'],
fillOpacity: 0.6,
hideHover: 'auto',
behaveLikeLine: true,
resize: true,
pointFillColors:['#ffffff'],
pointStrokeColors: ['black'],
lineColors:['green']
};
config.element = 'morris-area-chart-exm';
Morris.Line(config);`
如果我的json可能有超过2个ykeys,这将基于来自数据库的数据。我将如何将其绘制到ykeys?请指教。
示例JSON将是
[
{"uma":"34","time":"2017-05-11 12:30","mahes":"23","karan":"56","janu":"23",....},
{"uma":"45","time":"2017-05-11 12:35","mahes":"45","karan":"56","janu":"56",....},
{"uma":"34","time":"2017-05-11 12:38","mahes":"54","karan":"56","janu":"67",....}
]