By Chris R. Chapman at November 26, 2009 06:40
Filed Under: javascript, web20

Problem:  You want to render data that’s contained in a Javascript associative array on the client.

Solution:  Use jQuery and Flot, a jQuery charting plug-in.

jQuery is a Javascript library that makes writing client-side code extremely easy and quick through a “shorthand” syntax that is geared toward accessing page DOM elements and actions.  Flot is, according to its developers, an “attractive Javascript plotting library for jQuery”.  Looking over their gallery of samples, I’d have to agree:

1) Obtain jQuery from the jquery.com site and reference into your page:

<script type="text/javascript" src="/Scripts/jquery-1.3.2.min.js" mce_src="/Scripts/jquery-1.3.2.min.js"></script>

2) Obtain Flot from its Google Source repository:  http://code.google.com/p/flot/ and reference into your page. 

There’s a lot of files in there, but the ones you will want to use are jquery.flot.min.js and excanvas.min.js.  Reference these libraries into your page (after copying them into your Scripts folder) as follows:

<script type="text/javascript" src="/Scripts/jquery.flot.min.js" mce_src="/Scripts/jquery.flot.min.js"></script>

<!--[if IE]><script language="javascript" type="text/javascript" src="/Scripts/excanvas.min.js"></script><![endif]-->

Note that the excanvas.min.js library is needed for IE browsers to render the chart because it lacks a native “canvas” object.

3) Add a <DIV> element to the page that will host your chart:

<div id="chartPlaceholder" style="width:600px; height:300px”></div>

Note that the id of the DIV element will be referenced by the Flot code, so name it appropriately to keep your code readable and maintainable.

4) Build an associative array in Javascript to contain your data, eg:

var _dataArray = new Array();

Populate the array accordingly.

5) Create a method to build a Flot bar chart from your associative array data:

  function plotMyChart()

  {

  

      $.plot($("#chartPlaceholder"), [

      {

          data: _dataArray,

          bars: { show: true },

          color: "rgb(131,176,236)"

      }],

      {

          xaxis: {

          ticks: [[0.5, "Q3"], [1.5, "Q6"], [2.5, "Q9"], [3.5, "Q12"],

              [4.5, "Q15"], [5.5, "Q18"], [6.5, "Q21"], [7.5, "Q24"],

              [8.5, "Q27"], [9.5, "Q30"], [10.5, "Q33"], [11.5, "Q36"],

              [12.5, "Q39"], [13.5, "Q42"], [14.5, "Q45"], [15.5, "Q47"]]

          },

          yaxis: {

              tickSize: 5

          }

      }

    );

  

  }

6) Behold your new chart:

Flot_chart

By Chris R. Chapman at January 18, 2008 23:58
Filed Under: alt.net, javascript

Just noticed this podcast interview with David Laribee today - it's a concise description from the founder of the ALT.NET on what it's all about and where it's headed.  With the mail list careening this way and that, it's worth going back to first principles with Dave for the the gestalt:

ALT.NET is a community that is forming up from within the developer ranks around .NET technologies, but around more values and principles rather than products...

We are a self-organizing, ad-hoc community of developers bound by a desire to improve ourselves, challenge assumptions, and help each other pursue excellence in the practice of software development.

This message really resonates with me as it identifies the convictions I've always held as a developer - not the other way 'round.

For more info on ALT.NET, check out the AltNetPedia - there's a lot of resources there, even if you're not sure whether you're ALT.NET, a Mort or a 501.

By Chris R. Chapman at August 22, 2007 10:54
Filed Under: javascript, css
Update:  The "private beta" site I describe below is actually in public beta now - it can be found at http://toronto.ourfaves.com/.  Astute web travellers will recognize similarities with another site, Qype, which predates OurFaves in concept by over a year.
 
I'll be posting an update on why there's been a rather lengthy lag since my last post (almost a month!), but in the interim here's some interesting controls and tools that I've gleaned during my recent hops around the 'net for folks wanting to jazz up their sites.
 
10 CSS/Javascript/DHTML Calendars
 
I had a small chuckle when I came across this item and the following one below for charts because they made me think back to a rather errant project I was tasked with last year to develop a Windows Vista Gadget that was way overblown in terms of features - the two most time-consuming being a calendar and chart.
 
The DHTML Site has this collection of 10 calendars that you can source for your next web project, from the mundane to the uber cool.
 
 
10 CSS/Javascript/DHTML Charts
 
Again, from the DHTML Site, here's a collection of 10 charts that can add some gloss to your site - they range from the simple to the MySQL + PHP variety.
 
 
Javascript/DHTML Tooltips
 
One of the other features that my errant Vista Gadget required was tooltips.  For expediency, we used the standard OOTB web tool tips that you get for anchor tags (alt text).  BoxOvers would have been infinitely more cool.  There's really only one downside:  The code is released under GNU/GPL, so you effectively become a drone in Richard Stallman's Open Source Army by using it.
 
 
Simultaneous CSS Editing in IE & FireFox
 
In June 2006 I was working on a "Web 2.0" site that to my knowledge has *still* to escape the confines of a private beta that revolves around creating a social network for tagging and sharing favourite places to hang out, eat, party, etc.  A large part of the early problems with the site revolved around having a layout that remained consistent in both IE and FireFox.
 
Our CSS guru had a hell of a time keeping things straight as she had to continually tweak the site CSS while checking it in IE then FireFox.
 
If we'd had a copy of CSSVista, we'd likely have shed about 1/3 of the time that was invested.  This util is a standalone app that sports CSS editing panes with two stacked browser panes that display your site in IE and FireFox.
 
 
Still in beta, so it's not 100% yet - but it's the first of its kind that I've seen!

By Chris R. Chapman at July 28, 2005 06:52
Filed Under: .net, asp.net, javascript

Quick post on some thoughts-du-jour I'm researching surrounding the implmentation of asynchronous requests in ASP.NET 2.0 and web-based applications in general.  I've come across some resources that I want to keep track of and share with others:

From what I'm reading, 2.0 is going to be a quantum-leap forward for managing asynch operations at the page level, especially web service requests.  My last project would have benefitted from these advances -- at least it's on the horizon for the next version of SharePoint which will be built on top of 2.0.

About Me

I am a Toronto-based software consultant specializing in SharePoint, .NET technologies and agile/iterative/lean software project management practices.

I am also a former Microsoft Consulting Services (MCS) Consultant with experience providing enterprise customers with subject matter expertise for planning and deploying SharePoint as well as .NET application development best practices.  I am MCAD certified (2006) and earned my Professional Scrum Master I certification in late September 2010, having previously earned my Certified Scrum Master certification in 2006. (What's the difference?)