Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NM Various Enhancements #285

Merged
merged 5 commits into from
May 14, 2023
Merged

NM Various Enhancements #285

merged 5 commits into from
May 14, 2023

Conversation

neomantra
Copy link
Collaborator

Description

Please share your ideas and awesome changes.

I've been loving this library -- such a great integration of Golang <> JSON <> eCharts. It took me a while to isolate my changes, but I finally rebased them for a PR. Since one has a breaking change, maybe you want to separate it and I will if you ask me to.

Three changes, one adds some missing fields:

   * Tooltip.ValueFormatter
   * AxisPointer.Show
   * AxisPointer.Label
   * AxisLabel.BackgroundColor
   * XAxis.AxisPointer
   * YAxis.AxisPointer
   * DataZoom.LabelFormatter

Another strips // comments from JavaScript code, while still having FuncNoStripOpts if somehow that's not wanted. But most JavaScript code will. This makes using go:embed much easier (which I'll add a PR to examples about).

The last adds support for multiple datasets. This is great for issues like It has #169 with multiple charts. This has one breaking change, but in my opinion it adds so much power and harmonizes the syntax:

    // old
    chart.Dataset = opts.Dataset{Source: test}
    // new
    chart.AddDataset(opts.Dataset{Source: test})

Type of change

  • Bug fix (Non-breaking change which fixes an issue)
  • New feature (Non-breaking change which adds functionality)
  • Breaking change (Would cause existing functionality to not work as expected)
  • Others

Examples:

  • Yes, I am willing to submit a PR on Examples!

A multi-dataset example would be super useful. I don't have much time but hope to get to it.

I also want to make an example using go:embed since it is so powerful (also needs go 1.16 whereas examples only uses go 1.15). But I won't have time for a while too. Here's the idea:

// go:embed js/tooltip.js
var tooltipFormatter string
....
charts.WithTooltipOpts(opts.Tooltip{
	Show:    true,
	Trigger: "axis",
	Formatter: opts.FuncOpts(tooltipFormatter),
}

js/tooltip.js

function (params) {
    // here's a comment!
    console.log(params);
}

eCharts supports Chart's `dataset` as an array and indexing it
in a Series with `datasetIndex`.

This replaces the `Dataset` Chart config field with the
function `AddDataset`.  It also adds `WithDatasetIndex` as
an option for `SeriesOpts`

The `DatasetList` is JSON rendered as a single object, as
before.  But multiple Datasets are rendered as Array.

This is a breaking change:

```
// old
chart.Dataset = opts.Dataset{Source: test}
// new
chart.AddDataset(opts.Dataset{Source: test})
```
Also some whitespace changes per go fmt for doc comments

   * Tooltip.ValueFormatter
   * AxisPointer.Show
   * AxisPointer.Label
   * AxisLabel.BackgroundColor
   * XAxis.AxisPointer
   * YAxis.AxisPointer
   * DataZoom.LabelFormatter
opts/global.go Outdated Show resolved Hide resolved
@Koooooo-7 Koooooo-7 added attention Attention may include breaking changes enhancement New feature or request awesome labels May 10, 2023
Copy link
Member

@Koooooo-7 Koooooo-7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@Koooooo-7 Koooooo-7 merged commit 5762dc7 into go-echarts:master May 14, 2023
2 checks passed
@neomantra neomantra deleted the nm-pr1 branch May 17, 2023 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
attention Attention may include breaking changes awesome enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants