score:0
Accepted answer
you have a syntax error here:
{
label : "write speed in mbps",
should be (add comma):
,{
label : "write speed in mbps",
please check your console output and maybe use vscode or atom to edit your javascript code as the editor would have told you about the syntax error as well.
make sure you use a recent version of chart.js (2.7.0 bundled up or with dependencies).
i cannot reproduce the error with fixed data so it is either a syntax error in your code, wrong json sent by php or wrong version of chart.js
var testid = [1,2,3,4,5];
var readspeed = [6,7,8,9,10];
var writespeed = [4,5,6,7,8];
var chartdata = {
labels : testid,
datasets : [
{
label : "read speed in gbps",
data : readspeed,
backgroundcolor : "blue",
bordercolor : "lightblue",
fill : false,
linetension : 0,
pointradius : 5
}
,{
label : "write speed in mbps",
data : writespeed,
backgroundcolor : "blue",
bordercolor : "darkblue",
fill : false,
linetension : 0,
pointradius : 5
}
]
};
var options = {
title : {
display : true,
position : "top",
text : "new test results",
fontsize : 18,
fontcolor : "#111"
},
legend : {
display : true,
position : "bottom"
}
};
if (chart) {
chart.destroy();
}
var ctx = $('#mycanvas');
var chart = new chart( ctx, {
type : "line",
data : chartdata,
options : options
});
<canvas id="mycanvas" width="400" height="400"></canvas>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/chart.js/2.7.0/chart.bundle.js"></script>
Source: stackoverflow.com
Related Query
- Unable to Draw Chart using ChartJS
- Can't Draw Horizontal Line on Graph Using ChartJS Annotation Plugin and Primevue Chart
- Can't draw pie chart using chartjs - TypeError: Cannot create property '_meta' on number '16'
- I am using chart js to draw a chart. I did everything right but i don't know why the x axis and y axis label is not comming in chart. code below
- Draw stacked horizontal bar chart with Average line using ChartJS
- Unable to get chartjs to draw a chart with dynamic data (variable not hardcoded)
- ChartJS - Draw chart with label by month, data by day
- Display line chart with connected dots using chartJS
- Dynamically update the options of a chart in chartjs using Javascript
- How to Draw Gantt chart using chart js or other libraries
- How to access labels array using chart plugin (Chart.pluginService.register) in Chartjs 2.x?
- Chartjs - show elements in all datasets on hover using bar chart
- Draw two plots using chartjs over one another with transparency
- How to draw Horizontal line on Bar Chart Chartjs
- Want to draw data using chartjs in django
- Multiple stacked bar chart using ChartJs
- unable to add background color to the canvas using jspdf and chartjs
- Create Chart using Reactjs Chartjs and axios
- How to draw outer labels for polar chart using ng2-charts and chart.js at fixed positions outside the rings?
- Grouped Bar Chart from mySQL database using ChartJS and PHP
- ChartJS / Chartjs-plugin-annotation How to draw multiple vertical lines using an array?
- I am using chartjs node canvas to render a chart however the graph options are being ignored
- How to display chart using Chartjs with JSON data in Laravel
- Pagination in Bar chart using ChartJS
- Do not draw line on condition in ChartJS line chart
- How to draw multiple color bar in a bar chart using chart.js
- How to update a chart using VueJS and ChartJS
- How to highlight single bar in bar chart using Chartjs
- Bar Chart Not Stacking When Using ChartJs
- create Chart using Chartjs and PHP
More Query from same tag
- Can i use crosshairs with OHLC/candlestick charts using ChartJS
- Add horizontal Line to my chart.js Barchart
- Django show Graphs with ChartJS
- Chart.js does not display stacked data with linear axis and fixed steps
- JavaScript ChartJS Array Issue
- charts.js tooltips on different data ranges
- Remove 0's (zeros) from x-axis of bar chart in Chart.js
- How to place extra text on canvas (not using HTML) beside chart?
- Change height of chartjs dynamically
- Chart.js Pie Chart: How to set background image for segment
- Chartjs: How to create padding between ticks and scale label
- Drawing chart with Chart.js filled with data gotten per JsonRPC
- Chart.JS Get Json data for chart and return dataset where a type equals a certain type
- ChartJS pie chart with simple parsing options doesn't render, only works when set as bar/line chart
- ChartJS v2: how to remove strange line in Line Chart
- Vertical line across multiple charts
- System.Collections.Generic.List`1[System.String] instead of data
- Chart.js - 2 does not display Axes labels
- How to use the tooltipTemplate on Chart.JS 2.0
- Legends in Chart Js don't appears
- Add value to horizontal bar in chart.js
- Using Chart.js with Pyramid Web Framework
- React-chartjs not working
- Chart.js: Can datasets be overlaid in a bar chart? (Not the same as stacked)
- Not drawing null values using chart.js
- Get X, Y onClick chart coordinates in ChartJS
- ChartJS tooltip label for pie cart being cut
- How to use chart.js in blazor?
- Draw a line around a single point in the linechart
- Getting x,y values from chart click event