Código PHP:
sql = "SELECT fechaVenta,montoVenta FROM ventas Order by fechaVenta";
$result = mysqli_query($conexion, $sql);
$valoresY = array(); //montos
$valoresX = array(); //fecha
while ($ver = mysqli_fetch_row($result)) {
$valoresY[] = $ver[1];
$valoresX[] = $ver[0];
}
$datosX = json_encode($valoresX);
$datosY = json_encode($valoresY);
?>
Código HTML:
<div id="graficaBarras" class=""></div> <script type="text/javascript"> function crearCadenaBarras(json) { var parsed = JSON.parse(json) var arr = []; for (var x in parsed) { arr.push(parsed[x]) } return arr; } </script>
element.style {
}
.panel-primary {
border-color: #337ab7;
}
.panel {
margin-bottom: 20px;
background-color: #fff;
border: 1px solid transparent;
border-radius: 4px;
-webkit-box-shadow: 0 1px 1px rgb(0 0 0 / 5%);
box-shadow: 0 1px 1px rgb(0 0 0 / 5%);
}
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
user agent stylesheet
div {
display: block;
}
body {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 14px;
line-height: 1.42857143;
color: #333333;
background-color: #fff;
}
html {
font-size: 10px;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
html {
font-family: sans-serif;
-ms-text-size-adjust: 100%;
-webkit-text-size-adjust: 100%;
}
*:before, *:after {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
*:before, *:after {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
cmuch.mx/:1 Uncaught SyntaxError: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at crearCadenaBarras (<anonymous>:3:27)
at <anonymous>:3:14
at b (jquery-3.6.0.min.js:2)
at He (jquery-3.6.0.min.js:2)
at S.fn.init.append (jquery-3.6.0.min.js:2)
at S.fn.init.<anonymous> (jquery-3.6.0.min.js:2)
at $ (jquery-3.6.0.min.js:2)
at S.fn.init.html (jquery-3.6.0.min.js:2)
at Object.<anonymous> (jquery-3.6.0.min.js:2)
Agradezco su ayuda