I've been attempting to render a ChartJS graph on pages a user loads with a Firefox add-on. I'm using the add-on SDK to insert a PageMod to every page:
pageMod.PageMod({
include: "*",
contentScriptFile: [data.url("jquery.js"),
data.url("Chart.js"),
data.url("onPageLoad.js")]
});
In my onPageLoad.js, I insert an HTML5 canvas element using jQuery, and then try to draw my graph on it:
var chartData = [{value:100,color:'#4C86B9',highlight:'#508CC2',label:'Blue Team'},{value:150,color:'#B9525C',highlight:'#C25660',label:'Red Team'}];
$(document).ready(function() {
var ctx = document.getElementById("chart-area").getContext("2d");
var myPieChart = new Chart(ctx).Pie(chartData, {responsive:true});
});
This only causes the canvas to expand in area (I can see its parent div element expanding), but no graph is rendered. Thus, I know that the libraries are indeed being loaded. The closest question I could find on SO is ChartJS is not rendered, but this is actually a completely different problem. I can trivially draw a rectangle to my canvas:
ctx.fillRect(10,20,200,100);
So if it's not a problem with the canvas itself, why is this ChartJS graph not rendering?
Are the jquery./js, chart.js and onpageload.js files located in your data folder? If that isnt the problem, then the problem may be cross domain thing, so youll have to get around by setting content script policies: How to add Content Security Policy to Firefox extension
Related
I am trying to do functional testing of a web app built using angular 5. The appln contains a lot of canvas js based charts. I have to check the mouse over values within the canvas images and also the inner text and compare it to the sql server query in the backend to see if they are properly populated. I am currently using protractor and able to hover over the element but not get the value within the hover. Can someone suggest a way to do this - using protractor or any other tool. I am wondering if this is even possible. There is no data populated in the DOM for the canvas object or the tool tip.the chart is similar to this- I need to get the inner textt value and the mouse over values. All these are dynamically generated based on a drop down selection in uienter image description here
<canvas _ngcontent-c13="" chartjs="" height="159" width="319" class="chartjs-render-monitor" style="display: block; height: 199px; width: 399px;">
</canvas>
added canvas html
Our product is used by many corporate and government bodies.
Many of them are only allowed use IE and have security policies applied to their IE which they are not allowed adjust.
One such setting is the disabling of downloading web fonts.
We have work around in place to check if the font can be downloaded.
If not, we replace all <i> on the page with <img>.
var haveFont = detectFontIcons();
//Iterate over each icon on the page and replace if necessary
if (!haveFont)
$('[class^="mce-i-"]').each( function(e) {
console.log("Found element = ", this);
// Replace all <i></i> with <img>
....
}
}
This works fine for all our custom Html.
The Problem:
For some reason it will not work for tinyMCE <i> tags.
I have adjusted the class prefeix to allow for the TinyMCE 'mce-i-'.
It finds no elements in the DOM with 'mce-i' even though I can see them using firebug.
I have even set a timeout on the call to do this check, incase it was an issue with the DOM not been fully rendered yet. No luck.
Questions:
1: Any ideas on why no TinyMCE elements are not been found?
2: How can I update tinyMCE to use images directly instead of web fonts?
Thanks
I can't take credit for this, but I found a font-free, custom skin that replaces the fonts with images. I added the skin, updated my init method and it appears to work as I'd hoped.
It can be found here:
- https://pollyshaw.wordpress.com/2014/02/03/a-font-free-skin-for-tinymce-version-4/
- https://bitbucket.org/pollyshaw1/tinymce-4-lightgray-no-fonts-skin
I am adding bing maps to one of our sites. I am able to show pushpins and infoboxes.
The problem I am facing now is the infobox content go out of the white box.
Is there a way to have autoadjusting infoboxes for bing maps or its CSS?
Fixed using Jquery:
function displayInfobox(e) {
pinInfobox.setOptions({description: e.target.Description, visible:true, offset: new Microsoft.Maps.Point(0,4)});
pinInfobox.setLocation(e.target.getLocation());
map.setView({center:e.target.getLocation(),zoom:4});
adjustHeightInfobox();
}
function adjustHeightInfobox() {
var newHeight = jQuery(".infobox-info").height();
pinInfobox.setOptions({height:newHeight+15});
}
Assuming that you're using the default infobox within the AJAX control, you will be able to use the infoboxOption class where you can easily specify the width and height of the infobox.
See the MSDN for all options available on this specific class: http://msdn.microsoft.com/en-us/library/gg675210.aspx
If you want to adapt the infobox to your own needs (i.e. dynamic size), you can use your own HTML content and customize is with your own CSS, see: http://www.bingmapsportal.com/isdk/ajaxv7#Infobox14
I have three pages in my portfolio website built on the Masonry plugin (http://www.
4pixels.co.uk/). On the first page fancybox works perfectly for a few of the images.
But when I use infiniteScroll to load page 2 at the bottom of the first page, the fancy box links stop working and just load the thick box image into a new page.
If I load page 2 (http://www.4pixels.co.uk/index2.html) directly into the browser it worked fine (with all the css/js). I've since stripped out the js and css from this page as it loads them from page 1, but it makes no difference and fancy box still doesn't work (The image to try it with is the Responsive screens for Winston Ellis website)
All the best
Andy
I have tried
$(document).ready(function() {
$("#tumblelog").on("focusin", function(){
$("a.example2").fancybox({
'overlayShow' : true,
'transitionIn' : 'elastic',
'transitionOut' : 'elastic'
});
});
});
but still not working. I see your example is working so I'll have to pull it apart as I can't see were I'm going wrong..
Fancybox v1.3.4 cannot be bound to dynamically added elements (like those added by infiniteScroll).
If you want to have fancybox bound to those new elements, you have two options:
1: upgrade to fancybox v2.x ... or
2: keep using fancybox v1.3.4 but change your script and use jQuery on(). follow this link to learn how to
I was looking for solutions, but most of it was outdated or doesn't work correctly.
At the of of my document (main file of FB application - index.php), I have added:
<script>
window.fbAsyncInit = function() {
$('#iframe_canvas').css({'overflow': 'hidden'});
FB.Canvas.setAutoResize();
}
</script>
I was also trying with setSize({width and height}).
As I see previous versions has "remove scrollbars" option within Canvas settings - which is now removed. I was trying to change iframe, iframe > html and iframe > body CSS to overflow: hidden, overflow-x: hidden and many others. Also with JavaScript without effect.
Could anyone point the right path? Previously solutions found on stackoverflow doesn't help either.
I would play with the two options in Advanced settings for your application called: Canvas width and Canvas height. And see if a particular combination of those work. Also the setAutoResize is being deprecated in favor of setAutoGrow(). See https://developers.facebook.com/docs/reference/javascript/FB.Canvas.setAutoResize/