Use Chartjs-Annotation-Plugin without using "import" - charts

Is there a way to use the newest version of the chart-annotation-plugion as an inline plugin?
How I currently do it:
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.1.0/chart.min.js" ></script>
<script src="https://cdn.jsdelivr.net/npm/chartjs-plugin-annotation#1.0.0-rc/dist/chartjs-plugin-annotation.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/chartjs-plugin-datalabels/2.0.0-beta.1/chartjs-plugin-datalabels.min.js" ></script>
But in newer versions of ChartJS you need to register your plugins, but I dont think the plugin has a global property to register it, like the datalabel plugin (https://chartjs-plugin-datalabels.netlify.app/guide/getting-started.html#installation) has.
Here are the docs for the annotation plugin: https://www.chartjs.org/chartjs-plugin-annotation/guide/integration.html.
Any help is greatly appreciated.

Late to the party but I don't see a response yet and I was also having trouble figuring it out.
Simply include
<script>
Chart.register('chartjs-plugin-annotation');
Chart.register('chartjs-plugin-datalabels');
// ... rest of your code
</script>
somewhere near the top of your scripts after your CDN imports.
As per the Chartjs plugin documentation, this will work with any plugin that follows the naming convention chartjs-plugin-*
Edit:
Adding a working example; credit to #dennis-bauszus for most of the chart layout.
https://codepen.io/jarrilla/pen/OJjMVEo

Related

updated sharethis plugin is not working on ajax

Recently sharethis plugin is updated. i have successfully installed and it was working fine. but i am unable to load the buttons on ajax calls.
I have added this script
<script type="text/javascript" src="//platform-api.sharethis.com/js/sharethis.js#property=propertystring&product=inline-share-buttons"></script>
Old code using the following
stButtons.locateElements();
is not working any more.
Please note i am using custom share button.
I actually found the solution for this, at least it worked for me. Run this after the template has loaded:
__sharethis__.initialize()

SAPUI5 creating, but not running preload files

I have set up the following bootstap, with data-sap-ui-preload set to "auto"
<!-- Bootstrap the UI5 core library -->
<script id="sap-ui-bootstrap"
src="resources/sap-ui-core.js"
data-sap-ui-libs="sap.m, sap.ushell, sap.collaboration"
data-sap-ui-theme="sap_bluecrystal"
data-sap-ui-compatVersion="edge"
data-sap-ui-preload="auto"
data-sap-ui-xx-bindingSyntax="complex"
data-sap-ui-resourceroots='xxxxxxxxxxx'>
</script>
This creates a Component-preload.js file in all of my 3 separate apps.
Unfortunately, when I run it, the files aren't minified, and I can access the controller etc directly.
Has anyone else came across this issue?
if I understand correctly you are expecting that "data-sap-ui-preload" creates additional files and also minifies the code. Is that correct?
If i read the documentation correctly this is not what this parameter is used for.
If you are looking of ways on how to "minify" your could you should look into GruntJS. There is also a UI5 Grunt task runner that is used by SAP itself.

Mobile Chrome Apps and handling of JS refs

New at Chrome Apps. Using cca and CADT for mobile development.
In the following code, why is jQuery not immediately available? Is there some async magic being auto-applied?
I don't have this behavior in a vanilla cordova project.
<script type="text/javascript" src="js/jquery-2.1.1.min.js"></script>
<script type="text/javascript">
setTimeout(function()
{
console.log($); // $ is jQuery
}, 1000);
console.log($); // $ is undefined
</script>
Our current bootstrap code will not load the html of your chrome app windows in a way you typically expect from a browser. The reasons are long, but the short story is that we have to bootstrap to set up the environment, then inject the content around the bootstrap.
One of the consequences is that scripts do not block dom content loading. I guess another consequence is that inline script execution is not delayed until preceding scripts have loaded.
We may be able to fix this bug, I'll take a look. I've filed: https://github.com/MobileChromeApps/mobile-chrome-apps/issues/482
Thanks for reporting the issue!

Is it possible to use Super Scrollorama with Zurb Foundation 4?

I'm pretty new at this. I'm trying to use Super Scrollorama with Zurb Foundation 4. According to:
http://johnpolacek.github.io/superscrollorama/
First, link to the jQuery CDN and then embed TweenMax.js and SuperScrollorama.
However, I can't seem to get past the first step? When I try to add Super Scrollorama to a Foundation 4 project, just importing JQuery seems to break Foundation 4. TweenMax.js links just fine.
I'm using this code to link it:
<script src="js/superscrollorama/greensock/TweenMax.min.js" type="text/javascript">
</script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" type="text/javascript"></script>
Any ideas? Is this possible? I did a search on Google and there doesn't seem to be any tutorials showing how to use Super Scrollorama with Zurb Foundation 4.
I finally figured it out.
This script link:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" type="text/javascript"></script>
Muse appear BEFORE the Zurb Foundation 4 script link:
<script src="js/foundation.min.js"></script
So, the correct implementation would look like this:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" type="text/javascript"></script>
<script src="js/foundation.min.js"></script>
Such a crazy small, stupid detail cause such a huge waste of time!
If you add the link AFTER, then Zurb Foundation 4 WILL NOT WORK.

Is is possible to load .coffee script file to browser and execute?

I am trying to load coffee script inside a sample.coffee file along with the coffee-script.js file and perform some simple operations on the HTML. But i am not able to load the sample.coffee file.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script src="sample.coffee" type="text/coffeescript"></script>
<script src="coffee-script.js" type="text/javascript"></script>
</head>
<body>
</body>
</html>
Here is the coffeescript code inside sample.coffee
message = "Welcome to Coffeescript"
alert message
I referred the blog http://forgivingworm.wordpress.com/2010/09/27/running-coffeescript-in-browser/
I trying to run this in MVC4 project on .cshtml. So I am running under MS world.
I am not sure if this is possible or not? any insight into this would be greatly appreciated.
I am able to solve this issue by using the CoffeeSharp http://tomlokhorst.github.com/CoffeeSharp/ It gives handler for .coffee files also converts the coffeescript to javascript on the browser.
Also I am able to compile the coffeescript to javascript during the build event itself which solves deployment and performance related issues.
I dont think this will work like you tried it.
You will need something like requirejs and the coffeescript loader
at https://github.com/jrburke/require-cs.
However I would strongly discourage this and rather have it compiled before loading into the browser (require.js is encouraged though). You might find grunt.js helpful for "building" your app before deploying.
That html works fine for me. I used the coffee-script.js found here: https://cdn.rawgit.com/jashkenas/coffeescript/1.11.1/extras/coffee-script.js and my sample.coffee is:
x = ->
alert("hi")
x()
If you open the Javascript console, do you see any errors?