Using D3 or third party libraries with Polymer – simple example

Off late I have been exploring and working with Polymer a lot. One thing I tried recently was to create a custom element (a custom tag) that has a d3 chart integrated into it. So whenever I use this element in an application the chart renders.

For those who are not familiar with Polymer, let me tell you, it’s a game changer for the next generation of web applications. The web is getting componentized with the new standards that are coming along – Shadow DOM, custom elements, templating, HTML imports e.t.c. Polymer is a polyfill layer or as they call it a SUGARING layer on top of these web standards that allow you create custom web components easily. You do not need to go the the low level API’s to create a custom element. Just use the Polymer library and start creating your own components. Also it provides a heck of other features that can be used, such as two way data bindings. So go over to the Polymer site and check it out.

Coming back to our topic of discussion, one thing that can be a bit confusing to Polymer beginners is to use a third party javascript library with your polymer element. Here I have an example of using the D3 js charting library to create a custom chart component. Let’s call our custom element  my-custom-d3-chart. By the end of this discussion we will have a custom tag – <my-custom-d3-chart />. Yes a custom HTML tag. Our own tag. Yo!!!

Read More »

Adobe Shadow is now Adobe Edge Inspect

In a major move on the 24th of September, Adobe has renamed Shadow to Adobe Edge Inspect and now it has become a part of the Adobe Edge Tools and Services : http://html.adobe.com/edge/
Shadow had been a great success for mobile web developers and designers to remotely debug applications on the mobile device in real time. I had been using the preview version of Shadow for quite a time and has found it really useful, the last one being the Shadow Labs Release 4. So now the preview period of Shadow is ending on the 31st of October and after that Shadow will be invalid. Instead you have to download Edge Inspect and start using it.
You can get Edge Inspect by signing up for a free Creative Cloud membership subscription or a paid subscription. Get a account for yourself at: https://creative.adobe.com/join/starter. The free version allows only one device to be paired with your computer while the paid full version allows multiple devices to be paired simultaneously with your computer. Here’s a video demonstration on the new Edge Inspect release

Read More »

Use your own Weinre server with Adobe Shadow – Step by step

Now that Adobe has released version 4 of Shadow they have included a very nice feature of adding or using your own Weinre debug server with Shadow. What it does is that it fastens up the connection time and reduces the wait time when you are using the default Weinre debug server that Adobe has hosted on their servers. So if you have a local instance of the Weinre server running in your computer, you can use that as a debug server for Adobe Shadow instead of using the remote debug server hosted by Adobe at http://debug.shadow.adobe.com:8080/. So let’s see how to do it.

First of all you will need to have the Weinre server set up in your computer. For that you will need the weinre jar file and Java installed in your computer. I have a full detailed tutorial on setting up and using Weinre in one of my earlier post. So please have a look at it and set up the server. You can check out the “Configuring and running the Weinre debug server” section in the postAssuming that you have the server set it up on your computer, then you need to start it. You can check my previous post for that too. Its all there.

Then you can verify if the server has started. Open your browser and navigate to http://<yourip&gt;:port where <yourip> is your machine’s ip address and port is the port number where the Weinre debug server listens to. You can find out the port and the details from the command prompt after you have run the server. The screenshot below shows my instance,


Read More »

Adobe Shadow – another way of remote debugging mobile web apps in iOS and Android

Logo used from Adobe Labs site

Adobe has come out with the preview version of their new tool Adobe Shadow that allows front-end web developers and designers to work faster and more efficiently by streamlining the preview process, making it easier to customize websites for mobile devices. With shadow you can remotely preview your mobile web projects and also debug them. In fact Shadow uses the WEINRE debug/web inspector client to allow developers to remotely inspect HTML , view console logs and also make changes to the DOM. In the last post I have talked about WEINRE in details. You can refer it if you are new to WEINRE.

Shadow allows multiple devices (mobile devices) to connect wirelessly to your computer and as you browse in your computer all the target mobile devices will be in sync. So when you make changes to the HTML DOM in the computer you can see the changes instantly on all the target devices.

You need three things to configure Shadow and get started,

1) Shadow helper application. Install this in your computer. Shadow is not available for Windows XP so you need a Windows 7 machine or a Mac (OS X 10.6 and 10.7) machine. This helper application must keep running at the time of a debug session that you will carry.

2) Google Chrome browser extension for shadow. You need to install the extension. You will get the link to this in the downloads page below.

3) Shadow client app for iOS or Android. Whichever mobile device you have, go to the app market and search for Adobe Shadow, find it and then install it. For example go to Apple App Store and get the Shadow app and install it.

You can find all the downloads in the Adobe Labs site : http://labs.adobe.com/downloads/shadow.html

You can also find a very nice video demonstration to get started : http://tv.adobe.com/watch/adobe-technology-sneaks-2012/adobe-shadow.

Personally, after trying both Adobe Shadow and Weinre, I found Shadow easier to configure and get started with debugging mobile web applications remotely. For Weinre you have to install Java separately, use command line instructions and also inject javascript into the client code. This at times is a hassle and confusing for first timers.

This post was just a kind of teaser for you and in case you have not heard about Adobe Shadow you can give it a try. I also look forward to come out with a detailed tutorial on how to use Shadow with screenshots of my instance. Till then I am continuing to explore Shadow and similar tools.

Below are some of my previous tutorials that should help you.

  1. Debugging mobile web applications remotely with Weinrehttps://jbkflex.wordpress.com/2012/04/12/debug-mobile-web-applications-remotely-with-weinre/
  2. Use your own Weinre server with Adobe Shadow – Step by stephttps://jbkflex.wordpress.com/2012/08/28/use-your-own-weinre-server-with-adobe-shadow-step-by-step/
  3. WEINRE – Web Inspector Remote Video by Patrick Muellerhttps://jbkflex.wordpress.com/2012/09/18/weinre-web-inspector-remote-video-by-patrick-mueller/

Update
1) Now that Adobe has released version 4 of Shadow they have included a very nice feature of adding or using your own Weinre debug server with Shadow. What it does is that it fastens up the connection time, performance and keeps the remote traffic local. So if you have a local instance of the Weinre server running in your computer, you can use that as a debug server for Adobe Shadow instead of using the remote debug server hosted by Adobe at http://debug.shadow.adobe.com:8080/. Read how to do it here.

2) Adobe Shadow is now Adobe Edge Inspect: Read the post and find out what changes has been made : https://jbkflex.wordpress.com/2012/09/27/adobe-shadow-is-now-adobe-edge-inspect/

Creating dynamic SVG elements in JavaScript

While I was working on a HTML5 project I found this problem of creating SVG (Scalable Vector Graphics) elements
dynamically in JavaScript. For example creating vector circles inside a for loop and adding them to the page. HTML5
supports inline SVG, so you can directly use <svg>your code</svg> inside <body> to create vector graphics. But I had the task of creating them in the script. So I have put forward a small example and here is how to do it.

To create a vector circle of radius 50,

var svgNS = "http://www.w3.org/2000/svg";

var myCircle = document.createElementNS(svgNS,"circle");
myCircle.setAttributeNS(null,"id","mycircle");
myCircle.setAttributeNS(null,"cx",100);
myCircle.setAttributeNS(null,"cy",100);
myCircle.setAttributeNS(null,"r",50);
myCircle.setAttributeNS(null,"fill","black");
myCircle.setAttributeNS(null,"stroke","none");

Read More »