PDA

View Full Version : Custom colormap for time series heatmap



rwbta
04-06-2011, 08:22 AM
How can I create a custom colormap for time series heatmap?

rwbta
04-08-2011, 12:06 PM
The heatmap.cs file in the charting demo has code. I was able to convert it to VB.NET with the help of Stephane (great guy; really helpful) at RogueWave.

Add the class (see below) and then assign it as follows:

Dim Cmap As Colormap = New MavaColormap


Public Class MavaColormap : Implements Imsl.Chart2D.Colormap

Private c As Integer() = New Integer() {10157607, 10092070, 10092070, 10026534, 10026534, 10026534, _
9960998, 9960998, 9895462, 9895462, 9895462, 9829926, _
9829926, 9764390, 9764390, 9764390, 9698854, 9698854, _
9633318, 9633318, 9633318, 9567782, 9567782, 9502246, _
9502246, 9502502, 9436709, 9371172, 9305635, 9305634, _
9240097, 9174561, 9108768, 9108767, 9043230, 8977693, _
8912157, 8912156, 8846619, 8780826, 8780825, 8715289, _
8649752, 8584215, 8584214, 8518421, 8452885, 8387348, _
8387347, 8321810, 8256273, 8256273, 8124944, 8059152, _
7993359, 7927567, 7861774, 7795982, 7730189, 7664397, _
7533068, 7467276, 7401483, 7335691, 7269898, 7204106, _
7138313, 7072521, 6941192, 6875400, 6809607, 6743815, _
6678022, 6612230, 6546437, 6480645, 6415109, 6283013, _
6151173, 6084869, 5953029, 5886725, 5754885, 5688325, _
5556485, 5490181, 5358341, 5292037, 5160197, 5093894, _
4961798, 4829958, 4763654, 4631814, 4565510, 4433670, _
4367110, 4235270, 4168966, 4037126, 3970822, 3838982, _
3772679, 3640070, 3507718, 3375366, 3242758, 3110406, _
2978054, 2845446, 2713094, 2580742, 2448134, 2315782, _
2183430, 2051078, 1852934, 1786118, 1653766, 1521158, _
1388806, 1256454, 1123846, 991494, 859142, 726534, _
594182, 461830, 329478, 656902, 984582, 1377799, _
1705479, 2098695, 2426376, 2754056, 3147272, 3474953, _
3868169, 4195849, 4523530, 4916746, 5244427, 5637643, _
5965323, 6293004, 6686220, 7013900, 7407117, 7734797, _
8062477, 8455694, 8783374, 9176591, 9241870, 9372942, _
9504014, 9569550, 9700622, 9831694, 9962766, 10028302, _
10159374, 10290446, 10421518, 10487054, 10618126, 10748941, _
10814477, 10945549, 11076621, 11207693, 11273229, 11404301, _
11535373, 11666445, 11731981, 11863053, 11994125, 12125197, _
12124940, 12190476, 12256012, 12321548, 12387084, 12452620, _
12518156, 12583692, 12649228, 12714764, 12780300, 12845836, _
12845580, 12911116, 12976652, 13042188, 13107724, 13173260, _
13238796, 13304332, 13369868, 13435404, 13500940, 13566476, _
13632012, 13697548, 13828620, 13894156, 14025229, 14156301, _
14221837, 14352910, 14418446, 14549518, 14680591, 14746127, _
14877199, 15008272, 15073808, 15204880, 15270416, 15401489, _
15532561, 15598097, 15729170, 15794706, 15925778, 16056851, _
16122387, 16253459, 16384532, 16384533, 16384534, 16384791, _
16384792, 16385049, 16385050, 16450843, 16450844, 16450845, _
16451102, 16451103, 16451360, 16516897, 16517154, 16517155, _
16517412, 16517413, 16517414, 16583207, 16583208, 16583465, _
16583466, 16583723, 16583724, 16649517}

Private Const adjustAlpha As Integer = 256 * 256 * 256

Public Function GetColor(t As Double) As Color Implements Colormap.GetColor
Dim i As Integer = CInt(Math.Truncate(t * 255))
Return Color.FromArgb(c(i) - adjustAlpha)
End Function
End Class