Thanks Steve! Yes, correct. Labeling slices was not possible back then as well. The annotation layer was kind of a workaround.
Will give it a try with your code snippet. Thanks Nicol Am Donnerstag, den 01.08.2019, 18:29 +0000 schrieb Lime, Steve D (MNIT): > You weren't labeling slices with PHP from the looks of it, just the > underlying feature using an annotation layer. So setting up a layer > to behave like an annotation layer is doable... Here's a simple > snippet for the state of Minnesota polygon: > > LAYER > NAME bdry_statepy2 > STATUS DEFAULT > TYPE POLYGON > DATA ' bdry_statepy2' > CLASS > LABEL > TEXT 'Minnesota' > POSITION CC > SIZE LARGE > COLOR 0 0 0 > END > END > END > > Basically using a class with no styles. > > I don't recall the individual chart components (pies, bars, etc...) > as being labelable. It's not covered in the docs or the original RFC. > I will whip up a test case to confirm the behavior though. > > --Steve > > -----Original Message----- > From: Nicol Hermann [mailto:[email protected]] > Sent: Thursday, August 01, 2019 12:33 PM > To: Lime, Steve D (MNIT) <[email protected]>; > [email protected] > Subject: Re: [mapserver-users] labels for pie|bar charts > > This message may be from an external email source. > Do not select links or open attachments unless verified. Report all > suspicious emails to Minnesota IT Services Security Operations > Center. > > > > Hello Steve, > > you are right. With older versions of Mapserver I used 2 layers. > One for the chart (type=chart) and the other one to do the labeling > (type=annotation). > I used PHP Mapscript at that time. See the code snippet for the > annotation layer below. It uses the same data source like the > chartlayer. > > $layer = ms_newLayerObj($Map); > $layer -> set('status', MS_ON); > $layer -> set('labelcache', MS_ON); > $layer -> set('type', MS_LAYER_ANNOTATION ); > $layer -> set('data', $datapath); > $layer -> set('status', MS_ON); > $poClass = ms_newClassObj($layer); > $poClass-> set("name", "Beschrifung " ); > $felder= '('; > foreach( $chartLayer['fieldlist'] as $feld ){ > $felder .= sprintf('%s = [%s]-', $feld, $feld); > } > $felder .=sprintf(')'); > $poClass->settext($layer, "$felder"); > $poClass-> label -> set('font', "arial"); > $poClass-> label -> set('type', MS_TRUETYPE); > $poClass-> label -> set('size', 8); > $poClass-> label -> set('antialias', MS_TRUE); > $poClass-> label -> color -> setRGB ( 0, 0, 0 ); > $poClass-> label -> set ('wrap', 0x2d); // use '-' to do a line break > $poClass-> label ->set('position', MS_AUTO); > $poClass-> label ->set('partials', MS_FALSE); > $poClass-> label ->backgroundcolor->setRGB('240','240','240'); > > Unfortunately this approach do not work anymore as the annotation > type > is not longer supported. > > The MapFile which I am trying currently looks like this: > > LAYER > DATA > "/home/nicol/public_html/geoworld/gw2_1und1/data/brd/media.shp" > LABELITEM "NAME" > NAME "Staedtecharts" > PROJECTION > "init=epsg:4326" > END # PROJECTION > STATUS DEFAULT > TYPE CHART > # PROCESSING "CHART_SIZE_RANGE=bevzahl" > # PROCESSING "CHART_SIZE=130" # Fixe Groesse > PROCESSING "CHART_TYPE=pie" # pie, bar > PROCESSING "CHART_SIZE_RANGE = itemname minsize maxsize minval > maxval exponent" > PROCESSING "CHART_SIZE_RANGE=bevzahl 30 300 100000 2000000" > LABELITEM "NAME" > UNITS DD > CLASS > NAME "Maennlich" > TEXT 'Hallo' > LABEL > FONT "arial" > SIZE 30 > COLOR 255 0 0 > ENCODING "UTF-8" > MINFEATURESIZE AUTO > OFFSET 0 0 > POSITION AUTO > SHADOWSIZE 1 1 > END # LABEL > STYLE > COLOR 192 192 192 > OUTLINECOLOR 0 0 0 > SIZE [mann] > END # STYLE > END # CLASS > CLASS > NAME "Weiblich" > STYLE > SIZE [frau] > COLOR 255 255 0 > OUTLINECOLOR 0 0 0 > END > END > END # LAYER > > > My hope was that the chart type now also takes care of the labeling. > > Any idea how to realize the labeling for the individual slices now? > > Thanks > Nicol > > > Am Donnerstag, den 01.08.2019, 14:34 +0000 schrieb Lime, Steve D > (MNIT): > > Hi Nicol: Do you you have a sample mapfile that showed your > > approach? > > Since CHART and ANNOTATION are both layer types that implies > > multiple > > layers. --Steve > > > > -----Original Message----- > > From: mapserver-users [mailto: > > [email protected] > > ] On Behalf Of Nicol Hermann > > Sent: Wednesday, July 31, 2019 2:52 PM > > To: [email protected] > > Subject: [mapserver-users] labels for pie|bar charts > > > > This message may be from an external email source. > > Do not select links or open attachments unless verified. Report all > > suspicious emails to Minnesota IT Services Security Operations > > Center. > > > > > > > > Hello, > > > > I am trying to understand how labeling/annotation with layer type > > 'chart' for the individual slices e.g. of a PIE/BAR chart would > > work > > ( > > https://gcc01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmapserver.org%2Foutput%2Fdynamic_charting.html&data=02%7C01%7Csteve.lime%40state.mn.us%7Ca807c021ad0c41a044b308d716a64292%7Ceb14b04624c445198f26b89c2159828c%7C0%7C1%7C637002775647669862&sdata=2vmqPRuyR7SHIQIW%2BGwqRqDsvjeMsC8O6Jfcpu1lYJg%3D&reserved=0). > > I have tried to set a LABELITEM on layer level, a LABEL block > > within > > the CLASS section, a TEXT property in the CLASS block but none of > > my > > attempts show any labels. > > In earlier versions of Mapserver I have used the ANNOTATION layer > > type > > to get labels but this type is now deprecated for 7.x versions. > > Any ideas? > > Thank you very much. > > > > Nicol > > > > _______________________________________________ > > mapserver-users mailing list > > [email protected] > > https://gcc01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.osgeo.org%2Fmailman%2Flistinfo%2Fmapserver-users&data=02%7C01%7Csteve.lime%40state.mn.us%7Ca807c021ad0c41a044b308d716a64292%7Ceb14b04624c445198f26b89c2159828c%7C0%7C1%7C637002775647669862&sdata=SZmAGH61Yb2fD%2BEQ3mVLk7lv2qVVcyIG8WLI6JsHr%2BE%3D&reserved=0 _______________________________________________ mapserver-users mailing list [email protected] https://lists.osgeo.org/mailman/listinfo/mapserver-users
