0
I have 2 appointments in the bank:
One returns the goals of the day until the last day of the month:
DIA META
1 3,23
2 6,45
3 9,68
4 12,9
5 16,13
6 19,35
7 22,58
8 25,81
9 29,03
10 32,26
11 35,48
12 38,71
13 41,94
14 45,16
15 48,39
16 51,61
17 54,84
18 58,06
19 61,29
20 64,52
21 67,74
22 70,97
23 74,19
24 77,42
25 80,65
26 83,87
27 87,1
28 90,32
29 93,55
30 96,77
31 100
The other shows the values achieved by the day of the consultation:
DIA REALIZADO
1 4,35
2 8,69
3 13,12
4 17,05
5 21,39
6 25,65
7 30,12
8 34,49
9 38,85
How can I unite them to popular the Chart combo as illustrated in the image below:
Being the first in the row as the goal and the second in the columns:
I am using the following Chart: combochart
I tried to put into an array only the other arrays more without success:
Array
(
[dados] => Array
(
[realizado] => Array
(
[0] => 4,35
[1] => 8,69
[2] => 13,12
[3] => 17,05
[4] => 21,39
[5] => 25,65
[6] => 30,12
[7] => 34,49
[8] => 38,85
)
[dias] => Array
(
[0] => 1
[1] => 2
[2] => 3
[3] => 4
[4] => 5
[5] => 6
[6] => 7
[7] => 8
[8] => 9
[9] => 10
[10] => 11
[11] => 12
[12] => 13
[13] => 14
[14] => 15
[15] => 16
[16] => 17
[17] => 18
[18] => 19
[19] => 20
[20] => 21
[21] => 22
[22] => 23
[23] => 24
[24] => 25
[25] => 26
[26] => 27
[27] => 28
[28] => 29
[29] => 30
[30] => 31
)
[meta] => Array
(
[0] => 3,23
[1] => 6,45
[2] => 9,68
[3] => 12,90
[4] => 16,13
[5] => 19,35
[6] => 22,58
[7] => 25,81
[8] => 29,03
[9] => 32,26
[10] => 35,48
[11] => 38,71
[12] => 41,94
[13] => 45,16
[14] => 48,39
[15] => 51,61
[16] => 54,84
[17] => 58,06
[18] => 61,29
[19] => 64,52
[20] => 67,74
[21] => 70,97
[22] => 74,19
[23] => 77,42
[24] => 80,65
[25] => 83,87
[26] => 87,10
[27] => 90,32
[28] => 93,55
[29] => 96,77
[30] => 100,00
)
)
)
Follow the consultations:
include 'conexao.php';
date_default_timezone_set('America/Sao_Paulo');
$hoje = date('d');
$loja = '5';
$mes = '3';
$ano = '2018';
$acumReal = '';
$acumMeta = '';
$data = array();
$consultaRealizadoLoja = "SELECT *,
DAY(rl_data) AS DIA,
MONTH(rl_data) AS MES
FROM realizado_loja
WHERE rl_loja = '$loja'
AND MONTH(rl_data) = '$mes'";
$consultaMetaMes = "SELECT
saz_loja_mes AS meta_mes
FROM
vi_sazo_energia_loja
WHERE
loja = '$loja'
AND mes = '$mes'";
$consultaMetaDia = "SELECT
saz_loja_dia AS meta_dia
FROM
vi_sazo_energia_loja
WHERE
loja = '$loja'
AND mes = '$mes'";
$consultaDiasMes = "SELECT
dias AS d
FROM
vi_sazo_anual
WHERE mes = '$mes'";
$resultRealizadoLoja = mysqli_query($conn, $consultaRealizadoLoja);
$resultMetaMes = mysqli_query($conn, $consultaMetaMes);
$resultMetaDia = mysqli_query($conn, $consultaMetaDia);
$resultDiasMes = mysqli_query($conn, $consultaDiasMes);
while($rowMetaMes = mysqli_fetch_assoc($resultMetaMes)) {
$metaMes = $rowMetaMes['meta_mes']."<br>";
}
while($rowMetaDia = mysqli_fetch_assoc($resultMetaDia)) {
$metaDiaria = $rowMetaDia['meta_dia']."<br>";
}
while($rowDiasMes = mysqli_fetch_assoc($resultDiasMes)) {
$diasMes = $rowDiasMes['d']."<br>";
}
// FAZ O ACUMULADO DO REALIZADO
while($rowRealizadoLoja = mysqli_fetch_assoc($resultRealizadoLoja)) {
$dia = $rowRealizadoLoja['DIA'];
$retorno = $rowRealizadoLoja['rl_valor'];
$acumReal = $retorno + $acumReal ;
$calculo = ( $acumReal / $metaMes * 100 );
$realizadoFinal = number_format($calculo,2,",",".");
$data['dados']['realizado'][] = $realizadoFinal;
}
//FAZ ACULADO DA META
for ($i=1; $i <= $diasMes ; $i++) {
$acumMeta = $metaDiaria + $acumMeta ;
$calculo2 = ( $acumMeta / $metaMes * 100 );
$acumuladoMeta = number_format($calculo2,2,",",".");
$data['dados']['dias'][] = $i;
$data['dados']['meta'][] = $acumuladoMeta;
}
The chart needs to return exactly this way: https://jsfiddle.net/j0x8wzaf/4/
To format select the code and press
CTRL+K
, use snippet for codes only HTML / Javascript. Take advantage and explain your answer!– NoobSaibot
https://pastebin.com/E7h7P9G8
– Lucas Moreira
I put a loop to take the days of the array and from it generate the data of every day. str_replace to change the commas to points. And the isset to check if you have the die, if you don’t have it puts as 0.00 . What I posted should be posted after his code and echo should be placed in the javascript that should be inline.
– Lucas Moreira
Put in the answer! Do Tour to learn how the community, read the topics How do I write a good answer?, Help with Markdown editing.
– NoobSaibot