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

Chart lines look messed up on the analytics page #391

Open
Foretack opened this issue Oct 26, 2023 · 8 comments
Open

Chart lines look messed up on the analytics page #391

Foretack opened this issue Oct 26, 2023 · 8 comments
Assignees
Labels
🐜 bug Something isn't working ☑ kinda-fixed

Comments

@Foretack
Copy link

Describe the bug

image

image

Steps to reproduce

Enable analytics and go visit the web page, increase in channel points should reproduce this

Expected behavior

The lines should not be smoothed and should be completely straight horizontally and vertically instead

Operating system

Ubuntu 22.04

Python version

3.10.12

Miner version

latest (1.8.8)

Other relevant software versions

No response

Logs

no errors, logs are the standard claim & watchtime logs, nothing out of the ordinary

Additional context

No response

@rdavydov rdavydov changed the title Chart lines look fucked up on the analytics page Chart lines look messed up on the analytics page Oct 26, 2023
@rdavydov
Copy link
Owner

No foul language in the title, please maintain common decency.

@rdavydov
Copy link
Owner

Attach/upload your analytics/streamername.json file so this issue can be reproduced and investigated.

@Foretack
Copy link
Author

forsen.json
ohnepixel.json

@Le0Developer
Copy link

Le0Developer commented Oct 31, 2023

This seems to be a bug in an apexcharts update, replacing <script src="https://cdn.jsdelivr.net/npm/apexcharts"></script> with <script src="https://cdn.jsdelivr.net/npm/apexcharts@3.42.0"></script> in assets/charts.html fixes the issue for me.

@rdavydov rdavydov self-assigned this Oct 31, 2023
@rdavydov rdavydov added the 🐜 bug Something isn't working label Oct 31, 2023
@rdavydov
Copy link
Owner

apexcharts/apexcharts.js#1188

Regarding the staircase effect - this is due to the data points having the same x-values. When multiple data points share the same x-value, the line chart connects them vertically first and then horizontally, creating a step-like appearance.

@Le0Developer Indeed, 3.42.0 doesn't have this weird backspikes. Good find!

@rdavydov
Copy link
Owner

x is a timestamp:

    def __save_json(self, key, data={}, event_type="Watch"):
        # https://stackoverflow.com/questions/4676195/why-do-i-need-to-multiply-unix-timestamps-by-1000-in-javascript
        now = datetime.now().replace(microsecond=0)
        data.update({"x": round(datetime.timestamp(now) * 1000)})

@rdavydov
Copy link
Owner

in ohnepixel.json we can see:

        {
            "x": 1698253100000, // same timestamp
            "y": 58920,
            "z": "Watch"
        },
        {
            "x": 1698253100000, // same timestamp
            "y": 59370,
            "z": "Watch Streak"
        },

This is because we get WATCH and WATCH_STREAK points at the same time.

Same with the WATCH and CLAIM points. We get them simultaneously.

        {
            "x": 1698254603000, // same timestamp
            "y": 59470,
            "z": "Watch"
        },
        {
            "x": 1698254603000, // same timestamp
            "y": 59520,
            "z": "Claim"
        },

@rdavydov rdavydov reopened this Oct 31, 2023
@rdavydov
Copy link
Owner

function getStreamerData(streamer) {
    if (currentStreamer == streamer) {
        $.getJSON(`./json/${streamer}`, {
            startDate: formatDate(startDate),
            endDate: formatDate(endDate)
        }, function (response) {
            var data = response.series;

            // Adjust x-values to prevent staircase effect
            for (var i = 1; i < data.length; i++) {
                if (data[i].x === data[i - 1].x) {
                    data[i].x += 1000; // Increment by 1 second (1000 milliseconds)
                }
            }

            chart.updateSeries([{
                name: streamer.replace(".json", ""),
                data: data
            }], true);

            clearAnnotations();
            annotations = response.annotations;
            updateAnnotations();

            setTimeout(function () {
                getStreamerData(streamer);
            }, 300000); // 5 minutes
        });
    }
}

Tried incrementing x by 1s, but the staircase effect is still present. I guess this is just how the ApexCharts library works, no wonder that issue was closed with no fix.

lyw1217 pushed a commit to lyw1217/Twitch-Channel-Points-Miner-v2 that referenced this issue Nov 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐜 bug Something isn't working ☑ kinda-fixed
Projects
None yet
Development

No branches or pull requests

3 participants