Mapinfo - Difference label colour based on value in a table

573 views
Skip to first unread message

Matt H

unread,
Jun 30, 2020, 12:44:49 AM6/30/20
to MapInfo-L
Hi, 

I've not been using Mapinfo very long and still learning, so please go easy on me if I'm asking a stupid or impossible question. 

I have a table with asset numbers in the first column and a category in the 2nd. Each category needs to be a certain color C=Red, 5=Green, 4=Orange 3= Blue, Unknown=Pink.  


 (White text size 9 and the colored box of the category color. Position Right offset 5 points, Allow overlapping and label partial objects  )   


Is there a way to change the label style based on the category in the table? I can change the symbol color very quickly by creating a thematic map based on category, but cannot find a way to get the text label to do the same.  What I have to do at the moment is split the excel sheet into 5 tables import all of them to MapInfo and then change the font color and box for each table/layer. 


I have to do this every time I make a pack and I could be doing up to 10 packs a day so I am trying to find a faster way of doing it like pasting some code into Mapbasic or an expression. to save my keep importing 5 tables just to change the text color.


mapinfo cat.PNG



Here's an example map of how I need it to look. Any help with this would be brilliant. Thanks for your time. Matty


mapinfo ex.PNG


mapinfo cat.PNG
mapinfo ex.PNG

Peter Moller

unread,
Jun 30, 2020, 3:25:31 AM6/30/20
to mapi...@googlegroups.com

Hi Matty

 

I would suggest this approach using conditional labels.

 

It uses kind of the same approach as you are using now but you don’t have to split your table into 5 separate tables.

 

0. Add the table to the map

1. Keep using the thematic layer to give the point the right style.

2. For the label expression use this: IIf(CorrectedCategory="C", SPN, ""). This will only show the red labels so make the style of this labed red and set the other label settings.

3. Add the layer to the map again and set the style to an invisible point. You can place this one under the first layer. This time use a similar expression to label the points for category 5: IIf(CorrectedCategory="5", SPN, ""). Set the label settings for this one too.

4. Repeat step 3 for the remaining 3 categories.

 

Once you are done, save this as a workspace.

Now whenever you want to refresh your table, just reimport the Excel file into MapInfo Pro and then open the workspace to get the theme and the colored labels.

 

PS: The IIf() function I’m using in my expression was added to MapInfo Pro v17.0. If you have an older version, we need a more complicated label expression.

 

Peter Horsbøll Møller

www.precisely.com

 

Peter Moller

--
--
You received this message because you are subscribed to the
Google Groups "MapInfo-L" group.To post a message to this group, send
email to mapi...@googlegroups.com
To unsubscribe from this group, go to:
http://groups.google.com/group/mapinfo-l/subscribe?hl=en
For more options, information and links to MapInfo resources (searching
archives, feature requests, to visit our Wiki, visit the Welcome page at
http://groups.google.com/group/mapinfo-l?hl=en

---
You received this message because you are subscribed to the Google Groups "MapInfo-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mapinfo-l+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mapinfo-l/20019a38-12a6-4aca-b624-593e373c3d69o%40googlegroups.com.

Matt H

unread,
Jul 4, 2020, 7:53:05 AM7/4/20
to MapInfo-L
Thanks for the quick reply and for taking the time to reponed.   

Unfortunately, the version I have is 15. I'll keep looking and if I can find a solution I'll look at the upgrade option so I can use the IIf function. 

thanks again. 

Matty
Reply all
Reply to author
Forward
0 new messages