Skip to content

Problem with negative values for barchart #95

Description

@boon-wego

I am having problem displaying barchart with negative values.

I tried to see if anyone has already reported this issue. But judging from #91 it seems negative values is supported all along.

I'm using Contex version 0.5.0

Code

data = [
      ["A", -10.0],
      ["B", 20.0],
      ["C", -50.0]
    ]

    dataset = Contex.Dataset.new(data, ["X", "Y"])

    options = [
      mapping: %{category_col: "X", value_cols: ["Y"]},
      type: :stacked,
      data_labels: true,
      orientation: :vertical
    ]

    chart =
      Contex.Plot.new(dataset, Contex.BarChart, 600, 400, options)
      |> Contex.Plot.titles("", "")
      |> Contex.Plot.axis_labels("", "")
      |> Contex.Plot.plot_options(%{})
      |> Contex.Plot.to_svg()

Result

Screenshot 2024-04-17 at 7 17 14 PM

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions