在图表上绘制js多个数据集

时间:2016-07-02 19:36:42

标签: javascript json charts

我有以下json:

[
{"periodo":"0","mes":"7","anio":"2015","montoIngreso":0,"monedaIngreso":"0","identifierIngreso":null,"montoGasto":0,"monedaGasto":"0","identifierGasto":null,"balance":0",
{"periodo":"1","mes":"8","anio":"2015","montoIngreso":0,"monedaIngreso":"0","identifierIngreso":null,"montoGasto":0,"monedaGasto":"0","identifierGasto":null,"balance":0},
{"periodo":"2","mes":"9","anio":"2015","montoIngreso":0,"monedaIngreso":"0","identifierIngreso":null,"montoGasto":0,"monedaGasto":"0","identifierGasto":null,"balance":0},
{"periodo":"3","mes":"10","anio":"2015","montoIngreso":0,"monedaIngreso":"0","identifierIngreso":null,"montoGasto":0,"monedaGasto":"0","identifierGasto":null,"balance":0},
{"periodo":"4","mes":"11","anio":"2015","montoIngreso":0,"monedaIngreso":"0","identifierIngreso":null,"montoGasto":0,"monedaGasto":"0","identifierGasto":null,"balance":0},
{"periodo":"5","mes":"12","anio":"2015","montoIngreso":0,"monedaIngreso":"0","identifierIngreso":null,"montoGasto":0,"monedaGasto":"0","identifierGasto":null,"balance":0},
{"periodo":"6","mes":"1","anio":"2016","montoIngreso":0,"monedaIngreso":"0","identifierIngreso":null,"montoGasto":0,"monedaGasto":"0","identifierGasto":null,"balance":0},
{"periodo":"7","mes":"2","anio":"2016","montoIngreso":0,"monedaIngreso":"0","identifierIngreso":null,"montoGasto":0,"monedaGasto":"0","identifierGasto":null,"balance":0},
{"periodo":"8","mes":"3","anio":"2016","montoIngreso":0,"monedaIngreso":"0","identifierIngreso":null,"montoGasto":0,"monedaGasto":"0","identifierGasto":null,"balance":0},
{"periodo":"9","mes":"4","anio":"2016","montoIngreso":0,"monedaIngreso":"0","identifierIngreso":null,"montoGasto":0,"monedaGasto":"0","identifierGasto":null,"balance":0},
{"periodo":"10","mes":"5","anio":"2016","montoIngreso":0,"monedaIngreso":"0","identifierIngreso":null,"montoGasto":0,"monedaGasto":"0","identifierGasto":null,"balance":0},
{"periodo":"11","mes":"6","anio":"2016","montoIngreso":3833.874,"monedaIngreso":"1","identifierIngreso":"ARS","montoGasto":175.56,"monedaGasto":"1","identifierGasto":"ARS","balance":3658.314},
{"periodo":"11","mes":"6","anio":"2016","montoIngreso":3833.874,"monedaIngreso":"1","identifierIngreso":"ARS","montoGasto":"460810","monedaGasto":"2","identifierGasto":"USD","balance":-456976.126},
{"periodo":"11","mes":"6","anio":"2016","montoIngreso":3833.874,"monedaIngreso":"1","identifierIngreso":"ARS","montoGasto":190.4448,"monedaGasto":"3","identifierGasto":"UYU","balance":3643.4292},
{"periodo":"11","mes":"6","anio":"2016","montoIngreso":"5000","monedaIngreso":"2","identifierIngreso":"USD","montoGasto":175.56,"monedaGasto":"1","identifierGasto":"ARS","balance":4824.44},
{"periodo":"11","mes":"6","anio":"2016","montoIngreso":"5000","monedaIngreso":"2","identifierIngreso":"USD","montoGasto":"460810","monedaGasto":"2","identifierGasto":"USD","balance":-455810},
{"periodo":"11","mes":"6","anio":"2016","montoIngreso":"5000","monedaIngreso":"2","identifierIngreso":"USD","montoGasto":190.4448,"monedaGasto":"3","identifierGasto":"UYU","balance":4809.5552},
{"periodo":"12","mes":"7","anio":"2016","montoIngreso":219.318,"monedaIngreso":"1","identifierIngreso":"ARS","montoGasto":15.444,"monedaGasto":"1","identifierGasto":"ARS","balance":203.874},
{"periodo":"12","mes":"7","anio":"2016","montoIngreso":219.318,"monedaIngreso":"1","identifierIngreso":"ARS","montoGasto":"105002","monedaGasto":"2","identifierGasto":"USD","balance":-104782.682},
{"periodo":"12","mes":"7","anio":"2016","montoIngreso":"324342","monedaIngreso":"2","identifierIngreso":"USD","montoGasto":15.444,"monedaGasto":"1","identifierGasto":"ARS","balance":324326.556},
{"periodo":"12","mes":"7","anio":"2016","montoIngreso":"324342","monedaIngreso":"2","identifierIngreso":"USD","montoGasto":"105002","monedaGasto":"2","identifierGasto":"USD","balance":219340}]

我有一个带有标签的var:

["2015-7", "2015-8", "2015-9", "2015-10", "2015-11", "2015-12", "2016-1", "2016-2", "2016-3", "2016-4", "2016-5", "2016-6", "2016-7"]

从第一个json开始,应该有三个数据集“montoIngreso”“montoGasto”和“balance”

问题是对于某些标签,我在json上有两个值,例如

anio:2016 mes:7有4条记录,所以我需要添加每条记录以形成3个独特的数据集

我该怎么做?

谢谢!

1 个答案:

答案 0 :(得分:0)

好吧,这不是幻想,但是:

< img src="{{ asset('path_to_the_image') }}" />