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

Issue with custom chart data: "No data to display" #175

Open
Gaming12846 opened this issue Sep 30, 2024 · 0 comments
Open

Issue with custom chart data: "No data to display" #175

Gaming12846 opened this issue Sep 30, 2024 · 0 comments

Comments

@Gaming12846
Copy link

Gaming12846 commented Sep 30, 2024

Hello,
I’ve integrated bStats into my plugins, and everything seems to be working fine, except for one issue. When I try to add a custom chart, it doesn’t refresh on the bStats website and always displays “No data to display.”
I suspect it might be a code issue on my end, so I’m sharing the relevant portion of my code below. I’ve also added the drilldownPie chart on the bStats website for my plugin, with the ID "server_locale".
I’m aware that data updates on the bStats website every 30 minutes and isn’t sent immediately upon first start, so I’ve restarted my server several times and let it run for a few hours on each occasion. Unfortunately, I still encounter the same issue, even when trying it with a different plugin of mine.

Any guidance or insight into what might be causing this would be greatly appreciated.

   // Initializes the bStats metrics for the plugin
    private void initializeMetrics() {
        if (getConfig().getBoolean(ConfigConstants.METRICS_ENABLED, true)) {
            getLoggingHelper().info(getConfigHelperLanguage().getString(LangConstants.METRICS_ENABLED));
            Metrics metrics = new Metrics(this, 11761);

            // Add custom server locale chart to the bStats metrics
            addServerLocaleChart(metrics);
        }
    }

   // Add custom server locale chart to the bStats metrics
    private void addServerLocaleChart(Metrics metrics) {
        // Debug logger message
        getLoggingHelper().debug("Add custom server_locale drilldown pie chart");

        metrics.addCustomChart(new DrilldownPie("server_locale", () -> {
            Map<String, Map<String, Integer>> map = new HashMap<>();
            Map<String, Integer> entry = new HashMap<>();
            String language = getConfigHelper().getString(ConfigConstants.LANGUAGE);
            entry.put(language, 1);
            switch (language) {
                case "custom" -> map.put("Custom", entry);
                case "de" -> map.put("German", entry);
                case "es" -> map.put("Spanish", entry);
                case "fr" -> map.put("French", entry);
                case "nl" -> map.put("Dutch", entry);
                case "zh-cn" -> map.put("Simplified Chinese", entry);
                case "zh-tw" -> map.put("Traditional Chinese", entry);
                default -> map.put("English", entry);
            }
            return map;
        }));
    }
@Gaming12846 Gaming12846 changed the title Issue with custom chart data on bStats Issue with custom chart data: "No data to display" Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant