Want to know more about us? Visit 2general.com »

Creating stacked bar charts with Flot

Flot is a powerful JavaScript plotting library for jQuery. It uses <canvas> tag for creating beautiful graphical plots. Out of the box it supports lines, points, filled areas, bars and any combinations of these. With plugins you get pie charts, stacked charts and more.

Today we’ll take a look at Flot’s stacked charts support. The first thing you must notice is that you have to pass the data in the right format. Also, Flot has a bug in creating stacked charts that may require some tinkering with Flot’s code. Luckily there’s a patch available.


Compiling Dust.js templates with django-mediagenerator

Here at 2General we’ve used django-mediagenerator as the asset manager in many of our latest projects. It combines the best parts of Django’s own staticfiles implementation and the older django-compressor app.

Dust.js is a fast, asynchronous JavaScript-based templating engine which runs both in browsers and on Node.js. We haven’t used Dust.js extensively yet, but we immediately noticed that if we’re planning to use it, we need to compile Dust.js templates during our normal build process, i.e. be able to add them in our mediagenerator bundles.


How to install Node.js packages and Ruby gems in virtualenv

Virtualenv is a superb tool for creating isolated environments for development with Python. However, if your project requires libraries in other languages, you may want to install them in your virtual environment as well. Here’s how to do it with Node.js packages and Ruby gems.

If you’re using virtualenvwrapper (and you should), you can put this in your postactivate script. Otherwise make sure some other way that these variables are set:

# node.js packages
export npm_config_prefix=$VIRTUAL_ENV

# ruby gems
export GEM_PATH=""