public final class

ChartUtils

extends Object
java.lang.Object
   ↳ com.shinobicontrols.charts.ChartUtils

Class Overview

Utility class to provide useful helper methods for drawing and updating the chart elements.

Summary

Public Methods
static void drawCrosshair(ShinobiChart chart, Canvas canvas, Rect drawingBoundary, float pixelXValue, float pixelYValue, float targetCircleRadius, Paint paint)
Draws a crosshair which focuses on specified x and y pixel coordinates, within the chart plot area.
static void drawText(Canvas canvas, String labelText, int x, int y, Paint labelPaint)
Draws text to the canvas, including multi-line text.
static void drawTextBackground(Canvas canvas, Rect backgroundLabelRect, Paint backgroundLabelPaint)
Draws a background Rect to the canvas, which is generally used for label backgrounds.
static void drawTickMarkLine(Canvas canvas, TickMark tickMark)
Draws a tick mark line to the canvas.
static void updateTooltipContent(Tooltip tooltip, DataPoint<?, ?> dataPoint)
Updates the tooltip's content with the given data point.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public static void drawCrosshair (ShinobiChart chart, Canvas canvas, Rect drawingBoundary, float pixelXValue, float pixelYValue, float targetCircleRadius, Paint paint)

Draws a crosshair which focuses on specified x and y pixel coordinates, within the chart plot area. Specifically the crosshair comprises of a circle, a horizontal line and a vertical line. The circle is drawn with its center point on the (x, y) pixel coordinates. The lines are drawn from the circle to the edge of the drawingBoundary.

Parameters
chart the ShinobiChart that the crosshair belongs to.
canvas the canvas on which to draw the crosshair
drawingBoundary the boundary, relative to the canvas, which the crosshair lines are drawn to, anything drawn beyond the bounds of the plotArea will not be visible
pixelXValue the x coordinate, in pixels, of the focus point for the crosshair, relative to the canvas
pixelYValue the y coordinate, in pixels, of the focus point for the crosshair, relative to the canvas
targetCircleRadius the radius of the circle to be drawn, in pixels
paint the Paint that will be used to draw the crosshair

public static void drawText (Canvas canvas, String labelText, int x, int y, Paint labelPaint)

Draws text to the canvas, including multi-line text.

Parameters
canvas The canvas on which to draw the text label.
labelText The text to draw.
x The x-coordinate of the text to draw.
y The y-coordinate of the text to draw. If the text spans more than 1 line then this coordinate will be where the center point (on the Y axis) will lie. '\n' is the delimiter.
labelPaint The Paint to use when drawing the text.

public static void drawTextBackground (Canvas canvas, Rect backgroundLabelRect, Paint backgroundLabelPaint)

Draws a background Rect to the canvas, which is generally used for label backgrounds.

Parameters
canvas The canvas on which to draw the background Rect.
backgroundLabelRect The Rect to draw.
backgroundLabelPaint The Paint to use when drawing the Rect.

public static void drawTickMarkLine (Canvas canvas, TickMark tickMark)

Draws a tick mark line to the canvas.

Parameters
canvas The canvas on which to draw the tick mark line.
tickMark The tick mark of which we require to draw the line.

public static void updateTooltipContent (Tooltip tooltip, DataPoint<?, ?> dataPoint)

Updates the tooltip's content with the given data point.

Parameters
tooltip the tooltip whose content is to be updated
dataPoint the data point from which to take values to display in the tooltip