[mapserver-users] labels for pie|bar charts
Lime, Steve D (MNIT)
steve.lime at state.mn.us
Thu Aug 1 16:32:01 PDT 2019
MapServer now supports multiple labels per feature so perhaps it’s a reasonable addition. Will take a peek...
________________________________
From: Nicol Hermann <mapserver at geoworld.de>
Sent: Thursday, August 1, 2019 1:37:13 PM
To: Lime, Steve D (MNIT) <steve.lime at state.mn.us>; mapserver-users at lists.osgeo.org <mapserver-users at lists.osgeo.org>
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.
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:mapserver at geoworld.de]
> Sent: Thursday, August 01, 2019 12:33 PM
> To: Lime, Steve D (MNIT) <steve.lime at state.mn.us>;
> mapserver-users at lists.osgeo.org
> 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:
> > mapserver-users-bounces at lists.osgeo.org
> > ] On Behalf Of Nicol Hermann
> > Sent: Wednesday, July 31, 2019 2:52 PM
> > To: mapserver-users at lists.osgeo.org
> > 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%7Ccace70b998234f92de2c08d716af1ff6%7Ceb14b04624c445198f26b89c2159828c%7C0%7C1%7C637002813718604608&sdata=JvGoeC2vO3kV5lqINPV%2Fk%2B98er56HGVlKy2uQXVHKa0%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
> > mapserver-users at lists.osgeo.org
> > 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%7Ccace70b998234f92de2c08d716af1ff6%7Ceb14b04624c445198f26b89c2159828c%7C0%7C1%7C637002813718604608&sdata=s2q0tY0kyxRSrOWxsAbjSsRo7WawWMPe2woZmTx0vZE%3D&reserved=0
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20190801/2d3495d0/attachment.htm>
More information about the MapServer-users
mailing list