{"id":15366771,"url":"https://github.com/erkkah/margaid","last_synced_at":"2025-04-15T12:33:25.924Z","repository":{"id":57513936,"uuid":"237844110","full_name":"erkkah/margaid","owner":"erkkah","description":"An SVG plotting library for golang","archived":false,"fork":false,"pushed_at":"2023-03-06T20:53:36.000Z","size":92,"stargazers_count":36,"open_issues_count":1,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-28T20:12:11.742Z","etag":null,"topics":["charting","diagram","golang","no-dependencies","plotting","svg"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/erkkah.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-02-02T22:06:19.000Z","updated_at":"2024-12-13T08:49:48.000Z","dependencies_parsed_at":"2024-06-19T02:46:00.258Z","dependency_job_id":"a72e14c8-d18a-4885-bd1c-95727d47f3fb","html_url":"https://github.com/erkkah/margaid","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erkkah%2Fmargaid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erkkah%2Fmargaid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erkkah%2Fmargaid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erkkah%2Fmargaid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/erkkah","download_url":"https://codeload.github.com/erkkah/margaid/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249072239,"owners_count":21208142,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["charting","diagram","golang","no-dependencies","plotting","svg"],"created_at":"2024-10-01T13:19:48.042Z","updated_at":"2025-04-15T12:33:25.900Z","avatar_url":"https://github.com/erkkah.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Margaid ⇄ diagraM\n\nThe world surely doesn't need another plotting library.\nBut I did, and that's why Margaid was born.\n\nMargaid is a small, no dependencies Golang library for plotting 2D data to SVG images. The idea is to create nice charts with a few lines of code and not having to bring in heavy machinery.\n\n\"Margaid\" is an old name meaning \"pearl\", which seemed fitting for something shiny and small.\nIt's also the word \"diagraM\" spelled backwards.\n\n## Features\n\nMargaid plots series of data to an SVG image. Series can be capped by size or time to simplify realtime data collection.\n\nPlots are drawn using straight lines, smooth lines or bars.\n\nEach axis has a fixed or automatic range, linear or log projection, configurable labels and optional grid lines.\n\nPlot colors are automatically picked for each new plot, trying to spread them in hue and saturation to get a good mix.\n\nThere is no clever layout or layering going on. Each new command draws on top of the results from previous commands.\n\n## Getting started\n\n### Minimal example\n\n![Minimal plot](example/minimal.svg)\n\nThese are the minimal steps needed to create a Margaid plot:\n* Import the library\n```go\nimport \"github.com/erkkah/margaid\"\n```\n* Create a series and add some values\n```go\nseries := margaid.NewSeries()\nseries.Add(margaid.MakeValue(10, 3.14), margaid.MakeValue(90, 93.8))\n// et.c.\n```\n\n* Create the diagram:\n```go\ndiagram := margaid.New(800, 600)\n```\n\n* Plot the series\n```go\ndiagram.Line(series)\n```\n\n* Add a frame and X axis\n```go\ndiagram.Frame()\ndiagram.Axis(series, margaid.XAxis, diagram.ValueTicker('f', 2, 10), false, \"Values\")\n```\n\n* Render to stdout\n```go\ndiagram.Render(os.Stdout)\n```\n\n### Example showing more features\n\n![Example plot](example/example.svg)\n\nTo generate the diagram above from the code shown below:\n```sh\n\u003e go run -tags example ./example \u003e example.svg\n```\n\n```go\n// example/example.go\npackage main\n\nimport (\n    \"math/rand\"\n    \"os\"\n    \"time\"\n\n    m \"github.com/erkkah/margaid\"\n)\n\nfunc main() {\n\n    randomSeries := m.NewSeries()\n    rand.Seed(time.Now().Unix())\n    for i := float64(0); i \u003c 10; i++ {\n        randomSeries.Add(m.MakeValue(i+1, 200*rand.Float64()))\n    }\n\n    testSeries := m.NewSeries()\n    multiplier := 2.1\n    v := 0.33\n    for i := float64(0); i \u003c 10; i++ {\n        v *= multiplier\n        testSeries.Add(m.MakeValue(i+1, v))\n    }\n\n    diagram := m.New(800, 600,\n        m.WithAutorange(m.XAxis, testSeries),\n        m.WithAutorange(m.YAxis, testSeries),\n        m.WithAutorange(m.Y2Axis, testSeries),\n        m.WithProjection(m.YAxis, m.Log),\n        m.WithInset(70),\n        m.WithPadding(2),\n        m.WithColorScheme(90),\n    )\n\n    diagram.Line(testSeries, m.UsingAxes(m.XAxis, m.YAxis), m.UsingMarker(\"square\"), m.UsingStrokeWidth(1))\n    diagram.Smooth(testSeries, m.UsingAxes(m.XAxis, m.Y2Axis), m.UsingStrokeWidth(3.14))\n    diagram.Smooth(randomSeries, m.UsingAxes(m.XAxis, m.YAxis), m.UsingMarker(\"filled-circle\"))\n    diagram.Axis(testSeries, m.XAxis, diagram.ValueTicker('f', 0, 10), false, \"X\")\n    diagram.Axis(testSeries, m.YAxis, diagram.ValueTicker('f', 1, 2), true, \"Y\")\n\n    diagram.Frame()\n    diagram.Title(\"A diagram of sorts 📊 📈\")\n\n    diagram.Render(os.Stdout)\n}\n```\n\n## Documentation\nFor more details, check the [reference documentation](https://pkg.go.dev/github.com/erkkah/margaid).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferkkah%2Fmargaid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ferkkah%2Fmargaid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferkkah%2Fmargaid/lists"}