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

Exporting functionality removing duplicate datapoints in CSV/XLS/View Data Table #17639

Closed
Sushma58 opened this issue Aug 24, 2022 · 11 comments · Fixed by #17704
Closed

Exporting functionality removing duplicate datapoints in CSV/XLS/View Data Table #17639

Sushma58 opened this issue Aug 24, 2022 · 11 comments · Fixed by #17704

Comments

@Sushma58
Copy link

Problem: Hi Team, In my case I am visualizing some forecasts in the form of hourly chart - 24 data points for a day per hour, the chart works fine for normal scenario.

But when it is a daylight saving day e.g 31st Oct 2021 we receive 25 data points, 2 duplicate data points for 2 am. The visualization works fine on the chart but when I click on Download CSV/XLS/ Data Table the duplicate value is removed which we would like to have.

Let me know if you need more information.

@pawellysy
Copy link
Contributor

Hello @Sushma58, thanks for creating this ticket!
You might want to parse the xValues to be expressed in timestamp because those 2 "duplicate" points should have different timestamp values. Let me know if that works for you! If not, please share the demo, and we will try to search for some new workaround.

@Sushma58
Copy link
Author

Hi @pawellysy thanks for the suggestion, as attached below both the data points belongs to same timestamp value which is a daylight saving hour. Please suggest what needs to be done here.
image

@pawellysy
Copy link
Contributor

Indeed this is a bug in my opinion. What I could advise you to do, is to slightly change one of the points by 1 millisecond, which would make those points not equal. There would not be a lot of difference in rendering, and both points will be preserved.

We will try to fix this bug soon, thanks for reporting!

Minimal demo, where the issue is reproduced: https://jsfiddle.net/BlackLabel/9b1p5vkn/227/

@Sushma58
Copy link
Author

@pawellysy thanks, for the time being I will use this workaround. Can you please also help me with the approximate SLA when your team is planning to release this?

@pawellysy
Copy link
Contributor

Sorry, we have no ETA right now, but you can follow this issue, as all info will be posted here! In case of any further questions feel free to contact us via our dedicated support channels!
https://www.highcharts.com/blog/support/

@Sushma58
Copy link
Author

Hi @pawellysy, I am now using below code to add 1 extra millisecond to the duplicate timestamp. Although it fixes the issue in CSV/DataTable/Excel but does not generate any data in "PNG/JPEG/SVG/PDF" which I believe is a new bug in HighCharts.

var chart = $('#' + divName).highcharts();
var temp = [];
for (var j = 0; j < chart.series.length; j++) {
temp = [];
for (var x = 0; x < chart.series[j].data.length; x++) {
var yValue = chart.series[j].data[x].y;
var xValue = chart.series[j].data[x].x;

        if ($.inArray(xValue, temp) === -1) {
            temp.push(xValue);
        } else {
            chart.series[j].data[x].x = parseInt(xValue) + 1;
            console.log('x value ' + xValue + ' y value ' + yValue + " is a duplicate value");
            console.log('changed value ' + chart.series[j].data[x].x);
            chart.series[j].setData(chart.series[j].data, true);
        }
    }
}

I am attaching screenshots of CSV file working but the jpeg/png not working with the same data. Please suggest what needs to be done here as it is affecting our production environment.

CSV Working
image

JEPG/PNG/PDF broken
image

@pawellysy
Copy link
Contributor

Hello again @Sushma58, could you please share the demo, where the issue is reproduced? You can use this demo as an initial one: https://jsfiddle.net/BlackLabel/9b1p5vkn/227/

@Sushma58
Copy link
Author

Hello @pawellysy have added the reproducible issue at https://jsfiddle.net/1zntymkq/7/ , let me know if you need more information. Thanks

@karolkolodziej
Copy link
Contributor

Please don't edit the chart.series[j].data, this might introduce unnecessary complication.
Instead, create a separate array with that data.

Demo: https://jsfiddle.net/BlackLabel/efmhv1np/

@Sushma58
Copy link
Author

Sushma58 commented Sep 1, 2022

Hi @karolkolodziej thanks the fix worked :)

@hubertkozik
Copy link
Member

Workaround with overriding HC core function:
Demo: https://jsfiddle.net/BlackLabel/o51cL724/
The plugin is inside the IIFE function.

A similar solution will be used in the HC core.

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

Successfully merging a pull request may close this issue.

4 participants