apexcharts / apexcharts.js

📊 Interactive JavaScript Charts built on SVG
https://apexcharts.com
MIT License
14.03k stars 1.28k forks source link

CSV Export numberFormatter #4538

Closed ggrote closed 1 week ago

ggrote commented 2 weeks ago

New Pull Request

We needed the numbers in a csv export to be formatted correctly with a comma as a decimal separator. So I thought it would be a good way to implement a numberFormatter like the dateFormatter for the CSV Export.

Type of change

Please delete options that are not relevant.

Checklist:

Sorry, I don't know how to write unit tests.

junedchhipa commented 1 week ago

@ggrote Thanks for the contribution. Shouldn't you also set the numberFormatter here as well? ln#307 and ln#387

ggrote commented 1 week ago

I thought these lines are only for categories. But you are right they can be numbers too.

ggrote commented 1 week ago

I think that should be it. Any chance to integrate the changes? And maybe you can answer my question at vue3-apexcharts (https://github.com/apexcharts/vue3-apexcharts/issues/106)?

junedchhipa commented 1 week ago

@ggrote I am thinking of merging datetimeFormatter and numberFormatter together and provide a generic formatter. It is going to be a breaking change, so I am still thinking about it. Thanks for the contribution.

ggrote commented 1 week ago

Okay, how do you want to know which value should be formatted? By type? Anything I can help you with?

junedchhipa commented 3 days ago

instead of dateFormatter and numberFormatter, I have used the correct namings. The new properties will be categoryFormatter for x value and valueFormatter and y values

chart: {
   toolbar: {
       export: {
            csv: {
              categoryFormatter: (cat) => (cat),
              valueFormatter: (val) => (val),
            },
        },
    }
}

Docs will be updated after the new release