score:0
forget what i told you in my first comment (about updating the run()
function). i just hadn't catched what you were precisely trying to do.
so you have an initial set of data in you php vars, that you feed to your chart. you want to update this set of data (which i guess you should do in your ajax success
callback). this answer and the link it provides should point you in the right direction.
in your success
callback, you can add something like that:
// update points in the datasets
// index in datasets[] can be 0, 1 or 2 (three datasets for barchart)
barchart2.datasets[0].points[0].value = data[0]['cpfsenviados'];
barchart2.datasets[1].points[0].value = data[0]['propostasfinalizadas'];
barchart2.datasets[2].points[0].value = data[0]['propostasaprovadas'];
barchart2.update();
// index in datasets[] can be 0 or 1 (two datasets for linechar)
linechart.datasets[0].points[0].value = data[0]['propostasfinalizadas'];
linechart.datasets[1].points[0].value = data[0]['propostasaprovadas'];
linechart.update();
let me know if it is what you were looking for. also, simple remark, in many javascript coding conventions you would avoid having the first letter of a variable as a capital. hence maybe you should rename your charts variables to barchart2
and linechart
.
Source: stackoverflow.com
Related Query
- Replacing data chart.js and reloading chart [PHP/Js/AJAX]
- Trying to load a chart with chart.js, through ajax and php
- Send data from php to chart with ajax
- Draw a Chart.js with ajax data and responsive. A few problems and questions
- Chart.js Timeseries chart - formatting and missing data values
- ng2-charts customize data and whole html content of tooltip displayed when hovering on bar chart
- Chart.js - Getting data from database using mysql and php
- How can I display the xAxes and yAxes data in the tooltip, Chart JS?
- Chart JS: Ignoring x values and putting point data on first available labels
- How to show data values in top of bar chart and line chart in chart.js 3
- ChartJS (React) Line Chart - How to show single tooltip with data and labels from 3 (multiple) dataset?
- Configure Pie Chart Colors Using Chart.js and PHP
- update chart data called through ajax via PHP, MySQL
- 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?
- Chart.js Bar Chart - grouping and mapping data
- Dynamic line chart with chart.js and PHP
- How do I customize y-axis labels and randomly pick the value from the data range for x-axis in Chart js
- Chart only prints out first value using jquery ajax php
- Doughnut Chart not displaying data with Chart Js and Backbone js
- Charts js and laravel: Render chart after passing in json data
- create Chart using Chartjs and PHP
- How to reuse a Chartjs Chart component in with different Data and get past the **Canvas is already in use** error?
- Chart js PHP and JSON wont diplsay
- Chartjs Bar Chart showing old data when hovering when use of ajax
- Real-time line chart with ChartJS using Ajax data
- Dynamically create chart with Chart.js and PHP
- Calling chart JS with PHP Data (file structure)
- Charts JS: Doughnut chart and hiding tooltip for specific data index within each dataset
- Resetting transform: rotate() by removing and appending canvas not showing data after appending and redrawing chart
More Query from same tag
- Laravel 5.6 using laracharts. Chart wont render
- Line chart with large number of labels on X axis
- Dynamically add charts with chart.js
- Remove/Hide (display:none) the graphical chart in small-mobile view - JS chart
- Chart js background color changes on click
- chart.js 3 and time axis displays wrong date data
- Updating chart.js based on selections from dropdown
- How to use variable for data in Charts.js Pie Chart?
- Chart.js not showing data when pass dynamic labels
- How to add symbols in angular charts?
- Execute script after loading server side rendered React component
- cannot read property 'yyyx' of undefined
- ChartJS set default axis
- Chart.js - displaying multiple line charts using multiple labels
- The title of my ChartJs on the chart is undefined, but I can't change it because my labels use a function: Object.keys(groupMedia)
- ChartJS does not render correctly
- "Type of import (".../charjs/types/indexsm" has no construct signatures issue on Vue3 and ChartJS?
- Chart.js Chart does not start at
- Chart.js updating data
- ChartJS 'Hello World' not animating
- How to decrease the barthickness in ng2-charts?
- Hiding xAxis labels when using Chart.js
- Chart JS Logarithmic x-axis
- Chartjs hide dataset legend v3
- How do I change the label and value like 500,000 to 500k in Chart.js?
- Chart.js chart won't animate inside of bootstrap carousel
- Chartjs: customise legend based on background color
- Stacked horizontal bar chart along total count with chart.js
- how can i remove the grid lines in chartJs
- chartjs: set default min for the line chart