score:2
Accepted answer
using json_encode
would mean that you are encoding the data in json format. this format,may not be acceptable by chartjs
,as chartjs
requires strings for labels, and numbers for data.
here is what you can do (only the required section of the code)
(please note):- copy and paste this in label
tag in chartjs
. you can do this exact same thing for data
tag as well.
labels: [
<?php
for($i=0;$i<count($getdates);$i++){
echo $getdates[$i];
echo ',';
}
?>
],
also, make sure to send the data as an array from the backend, if you want to use this method.
as for the random color thing, i suggest you check out this github repository. you can search for other options for random colors as well.
Source: stackoverflow.com
Related Query
- Show dynamic data with dynamic colours in chartjs
- Updating chartJS with dynamic data
- ChartJS (React) Line Chart - How to show single tooltip with data and labels from 3 (multiple) dataset?
- How can I show JSON data in Chart.js with Javascript if static values are working but dynamic from mySQL are not?
- Unable to get chartjs to draw a chart with dynamic data (variable not hardcoded)
- Chartjs random colors for each part of pie chart with data dynamically from database
- ChartJS - Draw chart with label by month, data by day
- Show bar with zero value in ChartJs v2
- ChartJS show gaps in time data
- Show data dynamically in line chart - ChartJS
- Chartjs - data format for bar chart with multi-level x-axes
- How to show data values or index labels in ChartJs (Latest Version)
- ChartJs line chart - display permanent icon above some data points with text on hover
- Show Data labels on Bar in ChartJS
- Show "No Data" message for Pie chart with no data
- ChartJS bar chart fixed width for dynamic data sets
- chart js with angular2 loading dynamic data only after zoomin
- Dynamic colours in chartJS based on entries in the array
- Angular chart how to show the legend data value by default along with legend name
- How to create chartjs chart with data from database C#
- Graph streaming real-time data with react and chartjs
- How to show dynamic dates with month name of current month and previous month in momentjs?
- How can I load multiple Chartjs charts with different data on the same page?
- Django show Graphs with ChartJS
- Chartjs not working with d3 from csv source
- ChartJS datasets with one data value
- How to display chart using Chartjs with JSON data in Laravel
- Force ChartJS to show Doughnut chart with null values
- How to create a custom tooltip for chartJS graph with data in JSON array in JavaScript?
- How to plot Firebase data with Chartjs in angular
More Query from same tag
- Cannot import chart.js-plugins-annotations
- ChartJS automatically scaled chart has undefined min and max
- Reduce spacing between bars in horizontal bar chart (chart.js)
- Chart.js - Remove empty space in pie chart
- How to change the fontFamily of the labels and remove the grid in chart.js
- highlightFill for radar charts in chartJS
- Chart.js remove zero value sector in pie chart
- How to remove x axis scale labels Chart.Js
- chart.js - line chart - can I visualize positive/negative change somehow?
- Is it possible to create context menu with chart.js?
- Add text before time in tooltip
- chart js when hover shows old values
- Angular 9 chartJs is not updating view after data update
- Chart.js: grid lines only on dataset points
- Chart.js isn't being updated once an update call is made
- Chart.js - mixing bar and line graphs - can I get the lines to fill the full column?
- How to loop over Chart.js with Django list view
- How to define chart.js time scale date formats
- Chart.js - Connect two datasets in a line chart at same y value
- Foreground chart by mouse
- How to separete chart series into different pane (Chart.js)
- Chat js with respose ajax
- Grouped bar charts, in chart.js
- Convert charts from vue-chartjs to a PDF
- How to make interactive a chart with chart.js
- Remove specific label
- Chart.js line graph doesn't show up most of the time
- chart.js stacked graph that overlaps
- Populating a chartJS with data from API through axios (VueJS)
- A chart Js error issue are occured in my Laravel other page?