Topic
  • 2 replies
  • Latest Post - ‏2013-12-13T02:34:46Z by UchihaItachi
Dynamo76
Dynamo76
25 Posts

Pinned topic Bullet graph

‏2012-03-28T11:27:42Z |
Hi,

Is it possible to create bullet graph(chart) in SPSS using vizml, gpl or r-code?

I attach one example graph here.

BR,
Dynamo
Updated on 2012-12-11T20:23:10Z at 2012-12-11T20:23:10Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    266 Posts

    Re: Bullet graph

    ‏2012-12-11T20:23:10Z  
    Alittle late I know - but figured I would answer anyway (avoiding other work at the moment!)

    This is pretty simple with superimposing the "bullets" in seperate ELEMENT statements in inline GPL. I assume you can make the stacked bar graph, but you just want to know how to include the bullet interval and point location. I show an example making a seperate dataset with the bullets externally defined.

    
    set seed = 10. input program. loop #i = 0 to 10. loop #j = 0 to 4. compute group = #j. compute stack = TRUNC(RV.UNIFORM(1,4)). compute stack_value = RV.UNIFORM(0,1). end case. end loop. end loop. end file. end input program. dataset name sim. execute.   *usual stacked bar chart.   * Chart Builder. GGRAPH /GRAPHDATASET NAME=
    "graphdataset" VARIABLES=group[LEVEL=NOMINAL] SUM( stack_value)[name=
    "SUM_stack_value"] stack[LEVEL=NOMINAL] MISSING= LISTWISE REPORTMISSING=NO /GRAPHSPEC SOURCE=INLINE. BEGIN GPL SOURCE: s=userSource(id(
    "graphdataset")) DATA: group=col(source(s), name(
    "group"), unit.category()) DATA: SUM_stack_value=col(source(s), name(
    "SUM_stack_value")) DATA: stack=col(source(s), name(
    "stack"), unit.category()) GUIDE: axis(dim(1), label(
    "group")) GUIDE: axis(dim(2), label(
    "Sum stack_value")) GUIDE: legend(aesthetic(aesthetic.color.interior), label(
    "stack")) SCALE: cat(dim(1)) SCALE: linear(dim(2), include(0)) SCALE: cat(aesthetic(aesthetic.color.interior)) ELEMENT: interval.stack(position(group*SUM_stack_value), color.interior( stack), shape.interior(shape.square)) END GPL.     *now adding bullets to the chart. data list free / group bullet line. begin data 0 6 7 1 4 3 2 5 5 3 2 3 4 6 3 end data. dataset name bullets.   GGRAPH /GRAPHDATASET dataset = 
    "sim" NAME=
    "sim" VARIABLES=group[LEVEL=NOMINAL] SUM( stack_value)[name=
    "SUM_stack_value"] stack[LEVEL=NOMINAL] /GRAPHDATASET dataset = 
    "bullets" NAME=
    "bullets" VARIABLES = group bullet line /GRAPHSPEC SOURCE=INLINE. BEGIN GPL SOURCE: s=userSource(id(
    "sim")) DATA: group=col(source(s), name(
    "group"), unit.category()) DATA: SUM_stack_value=col(source(s), name(
    "SUM_stack_value")) DATA: stack=col(source(s), name(
    "stack"), unit.category()) SOURCE: s2=userSource(id(
    "bullets")) DATA: group2=col(source(s2), name(
    "group"), unit.category()) DATA: line=col(source(s2), name(
    "line")) DATA: bullet=col(source(s2), name(
    "bullet")) GUIDE: axis(dim(1), label(
    "group")) GUIDE: axis(dim(2), label(
    "Sum stack_value")) GUIDE: legend(aesthetic(aesthetic.color.interior), label(
    "stack")) SCALE: cat(dim(1)) SCALE: linear(dim(2), include(0)) SCALE: cat(aesthetic(aesthetic.color.interior)) ELEMENT: interval.stack(position(group*SUM_stack_value), color.interior( stack), shape.interior(shape.square)) ELEMENT: interval(position(group2*bullet), shape.interior(shape.line)) ELEMENT: point(position(group2*line), shape.interior(shape.cross), size(size.large)) END GPL.
    


    Andy W
    http://andrewpwheeler.wordpress.com
  • UchihaItachi
    UchihaItachi
    1 Post

    Re: Bullet graph

    ‏2013-12-13T02:34:46Z  

    What above seems to be very correct. I didn't figure out how to make bullet chart with those language. I only found how to make a bullet chart in C#. There are many chart types of the chart control. Not easy to make them for specified performance.

     

    The code seems to ? a chart:

    PieDataPoint point = series.DataPoints[3] <span class="kwrd">as</span> PieDataPoint;
    <span class="kwrd">if</span> (point != <span class="kwrd">null</span>)
    {
        point.OffsetFromCenter = 0.1;
    }
    
    Updated on 2013-12-13T14:04:39Z at 2013-12-13T14:04:39Z by JonPeck