Skip to content

Can't hide legend #71

@sdmcallister

Description

@sdmcallister

showlegend doesn't seem to get set in the output.

import plotly
import random
import json
import strutils

proc doPlot*(): string =
  let
    d1 = Trace[int](`type`: PlotType.Histogram, opacity: 0.8, name:"values 1")
    d2 = Trace[int](`type`: PlotType.Histogram, opacity: 0.8, name:"values 2")

  # using ys will make a horizontal bar plot
  # using xs will make a vertical.
  d1.ys = newSeq[int](200)
  d2.ys = newSeq[int](200)

  for i, x in d1.ys:
    d1.ys[i] = rand(20)
    d2.ys[i] = rand(30)

  for i in 0..40:
    d1.ys[i] = 12

  let
    layout = Layout(
                    yaxis: Axis(title:"values"),
                    xaxis: Axis(title: "count"),
                    # barmode: BarMode.Stack,
                    showlegend: false,
                    barmode: BarMode.Overlay,
                    autosize: true)
    p = Plot[int](layout: layout, traces: @[d1, d2])

  result = """<script>
                  var config = {responsive: true}
                  Plotly.newPlot('plot0', $1, $2, config)
              </script>""" % [parseTraces(p.traces), $(%p.layout)]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions