Good afternoon.
I have the following PHP code, somewhat simple:
<?
include("conexao.php");
$sql = mysql_query("select top 1 * from grafico_tb order by data_referencia desc");
$dados = mysql_fetch_assoc($sql);
$dados['perc1'];
$dados['perc2'];
?>
And I have the following code in javascript: grafico.js
initSparklineCharts: function() {
if (!jQuery().sparkline) {
return;
}
$("#sparkline_bar").sparkline([8, 9], {
type: 'bar',
width: '100',
barWidth: 5,
height: '55',
barColor: '#f36a5b',
negBarColor: '#e02222'
});
};
Instead of "8" and "9", I intended to play variables created within the .php
document.
I have already tried to create this same graph inside the <script></script>
tag in a .php
as follows:
initSparklineCharts: function() {
if (!jQuery().sparkline) {
return;
}
$("#sparkline_bar").sparkline([<? $dados['perc1'].','.$dados['perc2']?>], {
type: 'bar',
width: '100',
barWidth: 5,
height: '55',
barColor: '#f36a5b',
negBarColor: '#e02222'
});
};
And also with echo
in front of variables but did not work. Any solution?
The graph works with the values "8" and "9" without being variables and the variables in php also work.
Thank you!