draw_data (SVG::Graph::Pie)

    # File temp/Graph/Pie.rb, line 187
          def draw_data
            @graph = @root.add_element( "g" )
            background = @graph.add_element("g")
            midground = @graph.add_element("g")

            diameter = @graph_height > @graph_width ? @graph_width : @graph_height
            diameter -= expand_gap if expanded or expand_greatest
            diameter -= datapoint_font_size if show_data_labels
            diameter -= 10 if show_shadow
            radius = diameter / 2.0

            xoff = (width - diameter) / 2
            yoff = (height - @border_bottom - diameter)
            yoff -= 10 if show_shadow
            @graph.attributes['transform'] = "translate( #{xoff} #{yoff} )"

            wedge_text_pad = 5
            wedge_text_pad = 20 if show_percent and show_data_labels

            total = 0
            max_value = 0
            @data.each {|x|
              max_value = max_value < x ? x : max_value
              total += x
            }
            percent_scale = 100.0 / total

            prev_percent = 0
            rad_mult = 3.6 * RADIANS
            @config[:fields].each_index { |count|
              value = @data[count]
              percent = percent_scale * value

              radians = prev_percent * rad_mult
              x_start = radius+(Math.sin(radians) * radius)
              y_start = radius-(Math.cos(radians) * radius)
              radians = (prev_percent+percent) * rad_mult
              x_end = radius+(Math.sin(radians) * radius)
              x_end -= 0.00001 if @data.length == 1
              y_end = radius-(Math.cos(radians) * radius)
              path = "M#{radius},#{radius} L#{x_start},#{y_start} "+
                "A#{radius},#{radius} "+
                "0, #{percent >= 50 ? '1' : '0'},1, "+
                "#{x_end} #{y_end} Z"

              wedge = @foreground.add_element( "path", {
                "d" => path,
                "class" => "fill#{count+1}"
              })

              translate = nil
              tx = 0
              ty = 0
              half_percent = prev_percent + percent / 2
              radians = half_percent * rad_mult

              if show_shadow
                shadow = background.add_element( "path", {
                  "d" => path,
                  "filter" => "url(#dropshadow)",
                  "style" => "fill: #ccc; stroke: none;"
                })
                clear = midground.add_element( "path", {
                  "d" => path,
                  "style" => "fill: #fff; stroke: none;"
                })
              end

              if expanded or (expand_greatest && value == max_value)
                tx = (Math.sin(radians) * expand_gap)
                ty = -(Math.cos(radians) * expand_gap)
                translate = "translate( #{tx} #{ty} )"
                wedge.attributes["transform"] = translate
                clear.attributes["transform"] = translate if clear
              end

              if show_shadow
                shadow.attributes["transform"] =
                  "translate( #{tx+shadow_offset} #{ty+shadow_offset} )"
              end

              if show_data_labels and value != 0
                label = ""
                label += @config[:fields][count] if show_key_data_labels
                label += " ["+value.to_s+"]" if show_actual_values
                label += " "+percent.round.to_s+"%" if show_percent

                msr = Math.sin(radians)
                mcr = Math.cos(radians)
                tx = radius + (msr * radius)
                ty = radius -(mcr * radius)

                if expanded or (expand_greatest && value == max_value)
                  tx += (msr * expand_gap)
                  ty -= (mcr * expand_gap)
                end
                @foreground.add_element( "text", {
                  "x" => tx.to_s,
                  "y" => ty.to_s,
                  "class" => "dataPointLabel",
                  "style" => "stroke: #fff; stroke-width: 2;"
                }).text = label.to_s
                @foreground.add_element( "text", {
                  "x" => tx.to_s,
                  "y" => ty.to_s,
                  "class" => "dataPointLabel",
                }).text = label.to_s
              end

              prev_percent += percent
            }
          end