Turning bank result into JSON into Amcharts pattern

1

I'm using the Code Igniter framework. I have the following model:

public function getVendasVendedor() {
        $query = $this->db->query("SELECT * FROM vendas_vendedor");

        return $query->result();    
}

My Controller:

public function retornaJsonVendasVendedor() {
    echo json_encode($this->vendasm->getVendasVendedor());
}

Returning JSON from the controller:

[{
    "anomes":"201601",
    "totven":"1218000.0000",
    "codven":"117285",
    "nomeven":"JOAO FELIPE RIBAS"
},
{
    "anomes":"201701",
    "totven":"78000.0000",
    "codven":"117285",
    "nomeven":"JOAO FELIPE RIBAS"
},
{
    "anomes":"201602",
    "totven":"2800.0000",
    "codven":"109959",
    "nomeven":"JIAN LEANDRO FERMINO"
}]

Debug the result of the Model:

Array
(
[0] => stdClass Object
    (
        [anomes] => 201601
        [totven] => 1218000.0000
        [codven] => 117285
        [nomeven] => JOAO FELIPE RIBAS
    )

[1] => stdClass Object
    (
        [anomes] => 201701
        [totven] => 78000.0000
        [codven] => 117285
        [nomeven] => JOAO FELIPE RIBAS
    )

[2] => stdClass Object
    (
        [anomes] => 201602
        [totven] => 2800.0000
        [codven] => 109959
        [nomeven] => JIAN LEANDRO FERMINO
    )
)

I need to generate a JSON, in the following pattern, which would be for a chart using amcharts:

[{
  "category": "2013-08-24",
  "value1": 417,
  "value2": 127
}, {
  "category": "2013-08-25",
  "value1": 417,
  "value2": 356
}]

My question is how to distribute the bank information to generate the JSON. To have the result more or less as below:

    
asked by anonymous 31.07.2018 / 19:01

0 answers