Chartjs-Is it possible to use Chart.js in web2py?

1πŸ‘

βœ…

<script src='static/Chart.bundle.js'></script>

Check the network tab of the browser developer tools to see if Chart.bundle.js is loading. Likely you are getting a 404 response, as the above URL is a relative URL and will be appended to the URL of the parent page. You should instead use the web2py URL helper to generate all internal URLs:

<script src="{{=URL('static', 'Chart.bundle.js')}}"></script>

The above should generate a URL like /appname/static/Chart.bundle.js (appname will be excluded if you have routing configured to default to this app).

0πŸ‘

You are trying to create it on a wrong way, you can’t just specify chart id and use it. What you need is ctx, context of your canvas element. See how you can use it:

$("#chartjs-radar").get(0).getContext('2d');

or

document.getElementById('chartjs-radar').getContext('2d');

Use this instead of id while creating chart. (Then you can use just chart.js, not bundle)

Leave a comment