public class GraphView
extends View
Modifier and Type | Field and Description |
---|---|
protected SecondScale |
mSecondScale
feature to have a second scale e.g.
|
Constructor and Description |
---|
GraphView(Context context)
Initialize the GraphView view
|
GraphView(Context context,
AttributeSet attrs)
Initialize the GraphView view.
|
GraphView(Context context,
AttributeSet attrs,
int defStyle)
Initialize the GraphView view
|
Modifier and Type | Method and Description |
---|---|
void |
addSeries(Series s)
Add a new series to the graph.
|
void |
clearSecondScale()
clears the second scale
|
void |
computeScroll() |
protected void |
drawGraphElements(Canvas canvas)
draw all the stuff on canvas
|
protected void |
drawTitle(Canvas canvas)
Draws the Graphs title that will be
shown above the viewport.
|
CursorMode |
getCursorMode() |
int |
getGraphContentHeight() |
int |
getGraphContentLeft() |
int |
getGraphContentTop() |
int |
getGraphContentWidth() |
GridLabelRenderer |
getGridLabelRenderer() |
LegendRenderer |
getLegendRenderer() |
SecondScale |
getSecondScale()
creates the second scale logic and returns it
|
java.util.List<Series> |
getSeries()
important: do not do modifications on the list
object that will be returned.
|
java.lang.String |
getTitle() |
int |
getTitleColor() |
protected int |
getTitleHeight()
Calculates the height of the title.
|
float |
getTitleTextSize() |
Viewport |
getViewport() |
protected void |
init()
initialize the internal objects.
|
boolean |
isCursorMode() |
protected void |
loadStyles()
loads the font
|
void |
onDataChanged(boolean keepLabelsSize,
boolean keepViewport)
call this to let the graph redraw and
recalculate the viewport.
|
protected void |
onDraw(Canvas canvas)
will be called from Android system.
|
protected void |
onSizeChanged(int w,
int h,
int oldw,
int oldh)
Called by Android system if the size
of the view was changed.
|
boolean |
onTouchEvent(MotionEvent event)
will be called from Android system.
|
void |
removeAllSeries()
Removes all series of the graph.
|
void |
removeSeries(Series<?> series)
Remove a specific series of the graph.
|
void |
setCursorMode(boolean b) |
void |
setLegendRenderer(LegendRenderer mLegendRenderer)
use a specific legend renderer
|
void |
setTitle(java.lang.String mTitle)
Set the title of the graph that will
be shown above the graph's viewport.
|
void |
setTitleColor(int titleColor)
Set the title's font color
|
void |
setTitleTextSize(float titleTextSize)
Set the title's font size
|
Bitmap |
takeSnapshot()
takes a snapshot and return it as bitmap
|
void |
takeSnapshotAndShare(Context context,
java.lang.String imageName,
java.lang.String title)
takes a snapshot, stores it and open the share dialog.
|
protected SecondScale mSecondScale
public GraphView(Context context)
context
- public GraphView(Context context, AttributeSet attrs)
context
- attrs
- public GraphView(Context context, AttributeSet attrs, int defStyle)
context
- attrs
- defStyle
- protected void init()
protected void loadStyles()
public GridLabelRenderer getGridLabelRenderer()
public void addSeries(Series s)
s
- the series to be addedpublic java.util.List<Series> getSeries()
removeSeries(com.jjoe64.graphview.series.Series)
and addSeries(com.jjoe64.graphview.series.Series)
public void onDataChanged(boolean keepLabelsSize, boolean keepViewport)
BaseSeries.appendData(com.jjoe64.graphview.series.DataPointInterface, boolean, int)
or BaseSeries.resetData(com.jjoe64.graphview.series.DataPointInterface[])
.keepLabelsSize
- true if you don't want
to recalculate the size of
the labels. It is recommended
to use "true" because this will
improve performance and prevent
a flickering.keepViewport
- true if you don't want that
the viewport will be recalculated.
It is recommended to use "true" for
performance.protected void drawGraphElements(Canvas canvas)
canvas
- protected void onDraw(Canvas canvas)
canvas
- Canvasprotected void drawTitle(Canvas canvas)
canvas
- Canvasprotected int getTitleHeight()
protected void onSizeChanged(int w, int h, int oldw, int oldh)
w
- h
- oldw
- oldh
- public int getGraphContentLeft()
public int getGraphContentTop()
public int getGraphContentHeight()
public int getGraphContentWidth()
public boolean onTouchEvent(MotionEvent event)
event
- public void computeScroll()
public LegendRenderer getLegendRenderer()
LegendRenderer
public void setLegendRenderer(LegendRenderer mLegendRenderer)
mLegendRenderer
- the new legend rendererpublic java.lang.String getTitle()
public void setTitle(java.lang.String mTitle)
mTitle
- the titleto set the font color
,
to set the font size
public float getTitleTextSize()
public void setTitleTextSize(float titleTextSize)
titleTextSize
- font sizesetTitle(String)
public int getTitleColor()
public void setTitleColor(int titleColor)
titleColor
- font color of the titlesetTitle(String)
public SecondScale getSecondScale()
public void clearSecondScale()
public void removeAllSeries()
public void removeSeries(Series<?> series)
onDataChanged(boolean, boolean)
manually.series
- public Bitmap takeSnapshot()
public void takeSnapshotAndShare(Context context, java.lang.String imageName, java.lang.String title)
context
- imageName
- title
- public void setCursorMode(boolean b)
public CursorMode getCursorMode()
public boolean isCursorMode()