Skip to content

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

@Gaming12846

Description

@Gaming12846

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;
        }));
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions