Posts

Showing posts from May, 2013

Generating aesthetically pleasing colours that go well together

So the other day at work, my boss had another request for me, he wanted me to write some code that auto-generates a bunch of colours that go well together such that they could be used in a chart i.e something similar to what Google uses for their Google visualization API . So i wrote some code that generated decent enough colours and showed it to him, to which he responded, "is this what Google uses?" i was like no this is something we wrote, but he insisted that he wants exactly what Google uses and that is it. Now this was interesting as, Google provides a charting API for generating charts, but they don't exactly give access to the their colour generating algorithm. So to keep my boss happy, i came up with a little hack which solved our problem. You see the way to do this would be to generate a mock chart using the Google Visualization API and then extract the colours out of the chart itself. You see the chart is an SVG object and with the use of JQuery ( I assume ...

Transpose of a Google Visualization data table object

Since i spend a lot of time at my day job working with the Google Visualization  tools for the charting needs of my work, i figured it is inevitable that i will be requested to draw a chart with transposed data. ok...let us backtrack a little. So to draw a chart using the Google Visualization tools, the first step is to prepare a DataTable , which is a data structure provided by Google. The DataTable as the name suggests is simple table of rows and columns, hence it can be thought of a 2D matrix . Obviously now once you start to perceive your data as a matrix, what you can do with a matrix is only limited by the type of data stored in it. In this case the matrix operation of interest to me, was the transpose . Transpose is one of the simpler concepts of linear algebra, where by in a given matrix , rows become columns and columns become rows. Ok so now onto business? FYI, this is a quick and dirty solution and is in no way optimal. Since my need was to transpose a table that h...