Class SparklineGraph


  • public class SparklineGraph
    extends Object

    Class for drawing sparkline graphics.

    Drawing settings are controlled with SparklineParameters class

    Use SparklineComponent class to easily include interactive sparklines in your GUI

    Author:
    Eduardo Ramos
    See Also:
    SparklineParameters
    • Constructor Detail

      • SparklineGraph

        public SparklineGraph()
    • Method Detail

      • draw

        public static BufferedImage draw​(Number[] values,
                                         SparklineParameters parameters)
        Draw a sparkline only providing y axis values (1 x tick per number assumed)
        Parameters:
        values - Y axis values
        parameters - Rendering parameters
        Returns:
        Image of the sparkline
      • draw

        public static BufferedImage draw​(Number[] xValues,
                                         Number[] yValues,
                                         SparklineParameters parameters)
        Draw a sparkline with x axis and y axis values. X values must be ordered and not repeated.
        Parameters:
        xValues - X axis values
        yValues - Y axis values
        parameters - Rendering parameters
        Returns:
        Image of the sparkline
      • draw

        public static BufferedImage draw​(Number[] yValues,
                                         Number yMinValue,
                                         Number yMaxValue,
                                         SparklineParameters parameters)
        Draw a sparkline only providing y axis values, and pre-calculated min and max of the y axis values. Use this when you already have min/max values calculated and want to avoid extra calculations by SparklineGraph
        Parameters:
        yValues - Y axis values
        yMinValue - Minimum value of the Y axis, should be correct
        yMaxValue - Maximum value of the Y axis, should be correct
        parameters - Rendering parameters
        Returns:
        Image of the sparkline
      • draw

        public static BufferedImage draw​(Number[] xValues,
                                         Number[] yValues,
                                         Number yMinValue,
                                         Number yMaxValue,
                                         SparklineParameters parameters)
        Draw a sparkline with x axis and y axis values, and pre-calculated min and max of the y axis values. Use this when you already have min/max values calculated and want to avoid extra calculations by SparklineGraph X values must be ordered and not repeated.
        Parameters:
        xValues - X axis values
        yValues - Y axis values
        yMinValue - Minimum value of the Y axis, should be correct
        yMaxValue - Maximum value of the Y axis, should be correct
        parameters - Rendering parameters
        Returns:
        Image of the sparkline
      • drawHighlight

        private static void drawHighlight​(Graphics2D g,
                                          float x,
                                          float y,
                                          Color highlightColor)
      • calculateMin

        private static float calculateMin​(Number[] yValues)
      • calculateMax

        private static float calculateMax​(Number[] yValues)