+ Start a Discussion
TapasviniTapasvini 

How to create heat map

I have a sample data and based on that I want to create a simple heat map that has color representation.How can I do that?

Best Answer chosen by Admin (Salesforce Developers) 
nickwick76nickwick76

Ok, I might understand what you are doing now. If you are populating one cell with the value "#FF0000" and hoping for it to turn red I am afraid that won't work. You will have to work with CSS and the style attribute.

Use something like style="background-color:#{!your_color_value}" in the tag displaying the cell that should have that background color.

 

style might not be accurate in this case. Check the Visualforce Component Reference to manipulate the right component. http://www.salesforce.com/us/developer/docs/pages/index_Left.htm#StartTopic=Content/pages_compref.htm

All Answers

nickwick76nickwick76

Hi,

You mean that you want to create a map in Apex?

 

See this page for explanation and examples:

http://www.salesforce.com/us/developer/docs/apexcode/Content/langCon_apex_collections_maps.htm

 

// Niklas

TapasviniTapasvini

yes, I want to create using apex.

nickwick76nickwick76

Well, then the provided link should give you a start. But for example you can do like this:

 

Map<String,String> theMap = new Map<String,String>();

 

theMap.put('Green','##00FF00'>;

theMap.put('Red','#FF0000'>

 

and so on. Then you can get either keys or values from the map.See all map methods here:

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_map.htm

 

 

// Niklas

 

 

TapasviniTapasvini

I want to create the heat map based on report data.

 

nickwick76nickwick76

Sorry, you have to be more specific than that on what you want to accomplish.

 

// Niklas

TapasviniTapasvini

I am creating a report and based on that I want create a heatmap. eg. like this,

nickwick76nickwick76

Don't think it's possible to do that. There is no report object that I know of that can be used in Apex. Reports are just querying data so the best thing to do here is probably to create a SOQL query and put the resultset directly in to a map.

TapasviniTapasvini

Ok. But I am not getting the color in table.It displays the value that I pass.I have used this code.

Map<String, String> hm = new Map<String, String>();

hm.put('P1','##0000A0');

 

It shows me ##0000A0 in table.

nickwick76nickwick76

When using a map to get data from it, you will get the value using a key.

So if you call the map like this hm.get('P1') you will get the value of the key 'P1', i.e. '##0000A0'.

 

I am not sure I understand how your table is generated. You say it displays '##0000A0' in the table. How is this table generated? What do you want it to display?

TapasviniTapasvini

I am creating table in pageblocktable and getting the value from the controoler in which I have created the MAP. My table should be:

P1

This cell shpuld be filled with RED color but it shows me the color value.

P2

 This cell shpuld be filled with BLUE color

nickwick76nickwick76

Ok, I might understand what you are doing now. If you are populating one cell with the value "#FF0000" and hoping for it to turn red I am afraid that won't work. You will have to work with CSS and the style attribute.

Use something like style="background-color:#{!your_color_value}" in the tag displaying the cell that should have that background color.

 

style might not be accurate in this case. Check the Visualforce Component Reference to manipulate the right component. http://www.salesforce.com/us/developer/docs/pages/index_Left.htm#StartTopic=Content/pages_compref.htm

This was selected as the best answer
TapasviniTapasvini

Ok, thanks its working.

Yashita Goyal 12Yashita Goyal 12
Hi @Tapasvini,

Can you please help to get me started with heat map implementation.

Thanks.
Homes For Cash FastHomes For Cash Fast
You can do that with Google Fusion Tables: Generating a Geographic Heat Map with your Salesforce Account Data (http://cjhudson.com/generating-geographic-heat-map-salesforce-account/)