Skip to content

DataExtension API Graphs

Aurora Lahtela edited this page Oct 3, 2026 · 4 revisions

Plan Header

DataExtension API - Graphs

DataExtension Graph APIs require DATA_EXTENSION_GRAPH_API capability.


📈 @GraphProvider annotation

Speciality: Allows you to add sampled or historical data that's drawn as a line-graph.

Javadocs

Example use cases:

Usage:

@GraphProvider(
        displayName = "Balance over time", // Always required
        sampleInterval = 1, sampleIntervalUnit = TimeUnit.MINUTES,
        priority = 0,
        iconName = "chart-line",
        iconFamily = Family.SOLID,
        iconColor = Color.GREEN,
        xAxisType = XAxisType.DATE_MILLIS,
        xAxisSoftMin = 0, // Disabled if not given
        xAxisSoftMax = 2, // Disabled if not given
        yAxisSoftMin = 0,
        yAxisSoftMax = 2,
        supportsStacking = false,
        strategy = HistoryStrategy.NO_HISTORY,
        supportedAggregateFunctions = {MAX_PEAK, MAX_PEAK_OVER_TIME}
)
public PlayerGraphDataSource playerBalanceOverTime() {
    return new PlayerGraphDataSource() {
        @Override
        public Optional<DataPoint> getPoint(long currentTimestamp, UUID playerUUID, String playerName) {
            return Optional.of(new DataPoint(currentTimestamp, List.of(1.0)));
        }

        @Override // This method is called during registration and if DataPoint list increases length
        public List<SeriesMetadata> getSeriesMetadata() {
            return List.of(new SeriesMetadata(eco.currencyNamePlural(), "$", GraphFormatType.NONE, GraphColors.GREEN));
        }

        @Override // This method is not called (or required) with HistoryStrategy.NO_HISTORY
        public List<DataPoint> getPointHistory(long currentTimestamp, UUID playerUUID, String playerName) {
            return List.of();
        }
    };
}
@GraphProvider(...)
public ServerGraphDataSource serverGraph() {
    return new ServerGraphDataSource() {
        @Override
        public Optional<DataPoint> getPoint(long currentTimestamp) {
            return Optional.of(new DataPoint(currentTimestamp, List.of(1.0)));
        }

        @Override
        public List<SeriesMetadata> getSeriesMetadata() {
            return List.of(new SeriesMetadata("Example", "cm", GraphFormatType.NONE, GraphColors.GREEN));
        }

        @Override
        public List<DataPoint> getPointHistory(long currentTimestamp) {
            return List.of();
        }
    };
}

This page is still under construction.

Clone this wiki locally