score:1
to get everything into a percentage. you're gonna need to compute them.
like so:
var total = session + total_yes + total_no;
session = (session / total) * 100;
total_yes = (total_yes / total) * 100;
total_no= (total_no / total) * 100;
then in your chartdata, just use them:
var chartdata = {
labels: ['session', 'yes', 'no'],
datasets: [
{
label: 'session',
backgroundcolor: ['#00a65a', '#ff00ff'],
highlight: '#00c0ef',
data: session
},
{
label: 'yes',
backgroundcolor: ['#00a65a', '#ff00ff'],
highlight: '#00c0ef',
data:total_yes
},
{
label: 'no',
backgroundcolor: ['#00a65a', '#ff00ff'],
highlight: '#00c0ef',
data:total_no
}
]
}
if you require to add more items just add it to the total variable them do the same to get the percentage and then add it to the chartdata. and so on.
Source: stackoverflow.com
Related Query
- How to display data with percentage from database in pie chartjs?
- How to implement doughnut ChartJS with CodeIgniter 3 and display data from database
- Chartjs random colors for each part of pie chart with data dynamically from database
- How to create chartjs chart with data from database C#
- How to display data labels outside in pie chart with lines in ionic
- ChartJS (React) Line Chart - How to show single tooltip with data and labels from 3 (multiple) dataset?
- How to display chart using Chartjs with JSON data in Laravel
- How to get Data from API to display chart using chartjs in Vuejs
- Laravel - How to Display both count and percentage (%) in chartjs pie chart
- How to Integrating Chart.js with Angular 7 with Data from database
- How to use data from database for chart.js (bubble chart) with Ajax/JSON method?
- How to display data from database into line graph using php and mysql?
- How do I fetch data from 2 tables and display into 1 chartjs
- ChartJs line chart - display permanent icon above some data points with text on hover
- How to work out Chartjs using TypeScript with Chartjs.definitelyTyped from github
- Chart.js with data from database
- ChartJS - how to display line chart with single element as a line? (not as a dot)
- ChartJS version 3 how to add percentage to pie chart tooltip
- How to display data from top to bottom in stacked bar-chart QuickChart?
- How to display timestamped data with PrimeFaces and ChartJs?
- How do I add time sourced from an external source as an X axis to a ChartJS graph?
- How to get chart from data points (arrays) with inconsistent time intervals and chart.js?
- how to display chart data as html table chartjs
- How can I load multiple Chartjs charts with different data on the same page?
- Chartjs not working with d3 from csv source
- Angular 2: How to pass my API data to graph and Display the Graph with data
- How can I show JSON data in Chart.js with Javascript if static values are working but dynamic from mySQL are not?
- How to prevent tick labels from "jumping" when drawn with ChartJS BeforeDraw
- How to create a custom tooltip for chartJS graph with data in JSON array in JavaScript?
- How to get percentage from data collected in ChartJS?
More Query from same tag
- React chartjs 2 - Type 'string' is not assignable to type '"timeseries"'
- Charts not showing in wicked pdf
- ChatJS 2.8 chaning x-Axis font style and color
- Customizing Chart.js
- Customize different tooltips of bar chart
- How to remove minuses in a tornado/bar chart
- Stacked Group Bar from Chart.js : Can I give each stack group a unique color?
- Integrating TideSDK with C *.dll
- chart.js animation loading
- Display Json from Node.js in Chart.js with React
- How to set default callback for tooltip title with chart.js
- How to make dynamic chart using Vue component with chart-js
- ChartsJS get value of Data/Dataset Label for Tooltip
- how to pass function variable from one file to another in react
- Angular chart how to show the legend data value by default along with legend name
- Periodically refresh placeholder and canvas tag in Django template
- Chartjs-plugin-zoom plugin does not change x axis labels
- Chart JS Not Displaying Chart
- Chart.js with Node.js
- Chart JS not working with Phonegap
- Chart.js - Unable to see tooltips on hover while using moment
- Laravel - production.ERROR: Undefined variable: department_chart_data in Chartjs barchart
- Use outside variables inside a TypeScript function.
- Resizing a Chart.js chart
- How can I hide tick marks on Chart.js?
- Why is my chart not working? What am I missing
- ChartJS - can't display all the items in the array
- Chartjs - Stacked bar chart blocking other values
- How to pass variable (list) to JavaScript in Django?
- How to get hundreds of JS object properties into arrays to use as chart.js axes/data