score:0
you can do something like this:
getdata.php
:
$dir = 'sqlite:/home/pi/aquasolar/sht30/log_db/db.sht.6.db';
$dbh = new pdo($dir) or die("cannot open the database");
$query = "select * from reading");
$r0 = array();
foreach ($dbh->query($query) as $row) {
$r0 = $row[0];
}
$dbh = null;
echo json_encode($r0);
index.html
<!doctype html>
<html lang="en">
..
<body>
<script>
// include jquery
$.ajax({
url: './getdata.php',
type: 'get',
success: (data) => {
const parsed = json.parse(data);
// use parsed to create your chart
},
error: (err) => {
alert(err);
}
});
</script>
</body>
</html>
this is just an example of the logic that i use to resolve the problem. maybe there are some sintax error
Source: stackoverflow.com
Related Query
- Use PHP to populate chart.js with data from an SQLite Database
- Use data from SQL database in .js file with PHP
- Chartjs random colors for each part of pie chart with data dynamically from database
- How to create chartjs chart with data from database C#
- Send data from php to chart with ajax
- Chart.js not rendering chart with data from mySQL database
- Live updating chart with data from database with Chart.js
- I need a PHP query to grab data from the database and use in my bar charts for results
- Changing chart data dynamically with C# from SQL database
- How to use data from database for chart.js (bubble chart) with Ajax/JSON method?
- Chart.js - Getting data from database using mysql and php
- How to use 'time' (data from database, data type: timestamp ) for plotting graph in Chart JS
- Chart.js with data from database
- Using data from API with Chart JS
- ChartJS (React) Line Chart - How to show single tooltip with data and labels from 3 (multiple) dataset?
- Grouped Bar Chart from mySQL database using ChartJS and PHP
- How to get chart from data points (arrays) with inconsistent time intervals and chart.js?
- How to use JSON data in creating a chart with chartjs?
- Initialize a Chart.js chart with data from an api
- How to create a chart with chartjs.org with data from an array?
- How to displays item names from the database using a monthly or yearly chart PHP MySQL
- The chart doesn't display the data from my call to the API with Axios
- Updating chart.js not working after recieved new data from database with ajax
- Calling chart JS with PHP Data (file structure)
- Displaying Chart with data retrieved from Entity Framework in Controller
- Chart.js dynamic updates with data from database
- Having trouble fetching data from database for chart in ASP .NET Core
- How to display data with percentage from database in pie chartjs?
- Data not displaying in Chart JS from PHP JSON
- Create Line Chart and populate with database information
More Query from same tag
- 2 Line Chart with different labels | Chart.js
- increase the label size of a line chart in chart.js
- Chart isn't updating with Response data (Chart.js 3.2.1, ng2-charts 3.0.0-beta.9)
- How to set minimal value for bar chart in Chart.js? (ver. 2.0.2)
- Chart.js Y axis label, reverse tooltip order, shorten X axis labels
- Chart.js color change of the data points
- How to make the x-axis start from zero in chartjs-plugin-streaming?
- How to make the whole <canvas> element in Chart.js V3.7.0 display cursor as pointer on hover?
- "export 'default' (imported as 'Chart') was not found in 'chart.js'
- how to change the label color and set y-axis values 1k intervals and hide y-axis?
- javascript : extrapolate an array of numbers
- Unexpected error when attempting to update chart data in Chart.js, in a Vue app
- Space between start and end of axis
- lazy loaded modules share same dependencies?
- automatic legend translation on chart.js
- Chart.js: Line chart with partial dashed line
- ChartJS 2 - Adding data to chart breaks after X number of items added
- Change font family of labels in piechart and linechart in chartjs
- Chart.JS changing the animations
- Chart js not display graph
- JavaScript ignore commas inside ChartJS data field pulled from csv that data has commas and is enclosed by double quotes
- Chart js doughnut box shadow
- Plot dataset from MySQL with Chart.js and PHP
- Chart.JS - Tooltips - Issue: 3 data points, all three individual tooltips showing for each data point
- Array of objects condensed into array of unique objects with nested array
- ChartJS plugin with live label update
- Chart.js Types of property 'type' are incompatible. Type 'string' is not assignable to type '"line" | "bar" | "scatter"
- Chart.js: Pie chart legend "onclick" gets overwritten by "options.onclick" if both are present
- Customize ChartJS Hover Data Format
- Chart.js Mouse Over Show Old Chart Data