Write the <c:legend> element.
434158
def write_legend # :nodoc:
      position = @legend_position.sub(/^overlay_/, '')
      return if position == 'none' || (not position_allowed.has_key?(position))

      @delete_series = @legend_delete_series if @legend_delete_series.kind_of?(Array)
      @writer.tag_elements('c:legend') do
        # Write the c:legendPos element.
        write_legend_pos(position_allowed[position])
        # Remove series labels from the legend.
        # Write the c:legendEntry element.
        @delete_series.each { |i| write_legend_entry(i) } if @delete_series
        # Write the c:layout element.
        write_layout(@legend_layout, 'legend')
        # Write the c:txPr element.
        write_tx_pr(nil, @legend_font) if ptrue?(@legend_font)
        # Write the c:overlay element.
        write_overlay if @legend_position =~ /^overlay_/
      end
    end
315544
def write(self, char):
        
        char = str(char).lower()
        self.segments.write(self.font[char])
971462
def write_ser(series) # :nodoc:
      @writer.tag_elements('c:ser') do
        write_ser_base(series) do
          write_c_invert_if_negative(series.invert_if_negative)
        end
        # Write the c:cat element.
        write_cat(series)
        # Write the c:val element.
        write_val(series)
        # Write the c:smooth element.
        write_c_smooth(series.smooth) if ptrue?(@smooth_allowed)
      end
      @series_index += 1
    end
975262
def add_legend(self):
        """"""
        cuts = [tag for tag in self.tags if tag is not self._new_cut]
        self.cuts_plot.ax.legend(cuts, loc='best',
                                 shadow=True, fancybox=True,
                                 prop={'size': 8}, labelspacing=0.2)
1231166
def legend_item(label, x, color, options)
      size, symbol_padding, entry_padding = 5, 3, 12
      x -= @pdf.width_of(label, size: 7).ceil
      @pdf.text_box label, options.merge(at: [x, @pdf.bounds.height])
      x -= (symbol_padding + size)
      with fill_color: color do
        @pdf.fill_rectangle [x, @pdf.bounds.height - size], size, size
      end
      x - entry_padding
    end
1340314
def _writeText(self, image, text, pos):
        """"""
        offset = 0
        x, y = pos

        for c in text:
            # Write letter
            c_size = self.font.getsize(c)
            c_image = Image.new('RGBA', c_size, (0, 0, 0, 0))
            c_draw = ImageDraw.Draw(c_image)
            c_draw.text((0, 0), c, font=self.font, fill=(0, 0, 0, 255))

            # Transform
            c_image = self._rndLetterTransform(c_image)

            # Paste onto image
            image.paste(c_image, (x+offset, y), c_image)
            offset += c_size[0]
1315298
def store_legend(x, y, width, height, wType, wSpacing, grbit)  # :nodoc:
    record   = 0x1015     # Record identifier.
    length   = 0x0014     # Number of bytes to follow.
    # x                   # X-position.
    # y                   # Y-position.
    # width               # Width.
    # height              # Height.
    # wType               # Type.
    # wSpacing            # Spacing.
    # grbit               # Option flags.

    header = [record, length].pack('vv')
    data  = [x].pack('V')
    data += [y].pack('V')
    data += [width].pack('V')
    data += [height].pack('V')
    data += [wType].pack('C')
    data += [wSpacing].pack('C')
    data += [grbit].pack('v')

    append(header, data)
  end
771744
def WriteHeader(self):
    """"""
    xml_string = (
        '<?xml version="1.0" encoding="{0:s}"?>'
        '<kml xmlns="http://www.opengis.net/kml/2.2"><Document>'.format(
            self._output_mediator.encoding))
    self._output_writer.Write(xml_string)
634481
private void writeHeader()
    {
        out.println("<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>");
        out.println("<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 20010904//EN\" \"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd\">");
        out.println("<!-- Rendered by CSSBox http://cssbox.sourceforge.net -->");
        out.println("<svg xmlns=\"http://www.w3.org/2000/svg\"");
        out.println("     xmlns:xlink=\"http://www.w3.org/1999/xlink\" xml:space=\"preserve\"");
        out.println("         width=\"" + rootw + "\" height=\"" + rooth + "px\"");
        out.println("         viewBox=\"0 0 " + rootw + " " + rooth + "\"");
        out.println("         zoomAndPan=\"disable\" >");
    }
186695
def legend(self, values):
        
        if not isinstance(values, list):
            raise TypeError("legend must be a list of labels")

        self.options["legend"] = values
1320494
def write(self, handle):
        """"""
        handle.write(u"\t".join(self.columns))
        handle.write(u"\n")
        for row in self.rows:
            row.write(handle)
839832
def legend(self, txt=None):
        
        if txt:
            self._legend = txt
        else:
            return self._legend
        return self
1007824
function wrapText(text, legendWidth) {
            let fontSize = externalRadius / 5;

            textHelper.wrapText.call(null, 0, fontSize, legendWidth, text.node());
        }
31713
def write_graphic_frame(index, name = nil)
      macro  = ''

      attributes = [ ['macro', macro] ]

      @writer.tag_elements('xdr:graphicFrame', attributes) do
        # Write the xdr:nvGraphicFramePr element.
        write_nv_graphic_frame_pr(index, name)
        # Write the xdr:xfrm element.
        write_xfrm
        # Write the a:graphic element.
        write_atag_graphic(index)
      end
    end
782804
public static void writeNode(Node node, List<BelTerm> supportingTerms,
            PrintWriter writer) {
        int x = new Random().nextInt(200);
        int y = new Random().nextInt(200);

        StringBuilder sb = new StringBuilder();
        sb.append("  <node label='");
        sb.append(node.label);
        sb.append("' id='");
        sb.append(node.id.toString());
        sb.append("'>\n");
        sb.append("    <att name='function type'");
        sb.append(" value='");
        sb.append(node.function.getDisplayValue());
        sb.append("' />\n");
        sb.append("    <att name='parameters'");
        sb.append(" value='");

        String params = "";
        for (BelTerm t : supportingTerms) {
            if (hasLength(params)) {
                params = params.concat("&#10;");
            }
            String label = t.getLabel();
            label = label.replaceAll("&", "&amp;");
            label = label.replaceAll("'", "&quot;");
            params = params.concat(label);
        }
        sb.append(params);
        sb.append("' />\n");

        // Graphics type and fill color
        String graphics = format(NODE_GRAPHICS, type(node.function),
                color(node.function), x, y, params);
        sb.append(graphics);

        sb.append("  </node>\n");
        writer.write(sb.toString());
    }
1345862
def _legend(self):
        """"""
        if not self.show_legend:
            return
        truncation = self.truncate_legend
        if self.legend_at_bottom:
            x = self.margin_box.left + self.spacing
            y = (
                self.margin_box.top + self.view.height + self._x_title_height +
                self._x_labels_height + self.spacing
            )
            cols = self.legend_at_bottom_columns or ceil(sqrt(self._order)
                                                         ) or 1

            if not truncation:
                available_space = self.view.width / cols - (
                    self.legend_box_size + 5
                )
                truncation = reverse_text_len(
                    available_space, self.style.legend_font_size
                )
        else:
            x = self.spacing
            y = self.margin_box.top + self.spacing
            cols = 1
            if not truncation:
                truncation = 15

        legends = self.svg.node(
            self.nodes['graph'],
            class_='legends',
            transform='translate(%d, %d)' % (x, y)
        )

        h = max(self.legend_box_size, self.style.legend_font_size)
        x_step = self.view.width / cols
        if self.legend_at_bottom:
            secondary_legends = legends  # svg node is the same
        else:

            # draw secondary axis on right
            x = self.margin_box.left + self.view.width + self.spacing
            if self._y_2nd_labels:
                h, w = get_texts_box(
                    cut(self._y_2nd_labels), self.style.label_font_size
                )
                x += self.spacing + max(
                    w * abs(cos(rad(self.y_label_rotation))), h
                )

            y = self.margin_box.top + self.spacing

            secondary_legends = self.svg.node(
                self.nodes['graph'],
                class_='legends',
                transform='translate(%d, %d)' % (x, y)
            )

        serie_number = -1
        i = 0

        for titles, is_secondary in ((self._legends, False),
                                     (self._secondary_legends, True)):
            if not self.legend_at_bottom and is_secondary:
                i = 0

            for title in titles:
                serie_number += 1
                if title is None:
                    continue
                col = i % cols
                row = i // cols

                legend = self.svg.node(
                    secondary_legends if is_secondary else legends,
                    class_='legend reactive activate-serie',
                    id="activate-serie-%d" % serie_number
                )
                self.svg.node(
                    legend,
                    'rect',
                    x=col * x_step,
                    y=1.5 * row * h + (
                        self.style.legend_font_size - self.legend_box_size
                        if self.style.legend_font_size > self.legend_box_size
                        else 0
                    ) / 2,
                    width=self.legend_box_size,
                    height=self.legend_box_size,
                    class_="color-%d reactive" % serie_number
                )

                if isinstance(title, dict):
                    node = decorate(self.svg, legend, title)
                    title = title['title']
                else:
                    node = legend

                truncated = truncate(title, truncation)
                self.svg.node(
                    node,
                    'text',
                    x=col * x_step + self.legend_box_size + 5,
                    y=1.5 * row * h + .5 * h + .3 * self.style.legend_font_size
                ).text = truncated

                if truncated != title:
                    self.svg.node(legend, 'title').text = title

                i += 1
1337152
def write_bar_chart(params)   # :nodoc:
      if ptrue?(params[:primary_axes])
        series = get_primary_axes_series
      else
        series = get_secondary_axes_series
      end
      return if series.empty?

      subtype = @subtype
      subtype = 'percentStacked' if subtype == 'percent_stacked'

      # Set a default overlap for stacked charts.
      if @subtype =~ /stacked/
        @series_overlap_1 = 100 unless @series_overlap_1
      end

      @writer.tag_elements('c:barChart') do
        # Write the c:barDir element.
        write_bar_dir
        # Write the c:grouping element.
        write_grouping(subtype)
        # Write the c:ser elements.
        series.each {|s| write_ser(s)}

        # write the c:marker element.
        write_marker_value

        if ptrue?(params[:primary_axes])
          # Write the c:gapWidth element.
          write_gap_width(@series_gap_1)
          # Write the c:overlap element.
          write_overlap(@series_overlap_1)
        else
          # Write the c:gapWidth element.
          write_gap_width(@series_gap_2)
          # Write the c:overlap element.
          write_overlap(@series_overlap_2)
        end

        # write the c:overlap element.
        write_overlap(@series_overlap)

        # Write the c:axId elements
        write_axis_ids(params)
      end
    end