-
-
Notifications
You must be signed in to change notification settings - Fork 9k
General Chart Settings & Styling
Philipp Jahoda edited this page Sep 17, 2016
·
4 revisions
This section focuses on settings and styling of this library applicable for all Chart
types.
Refreshing
-
invalidate()
: Calling this method on the chart will refresh (redraw) it. This is needed in order to make changes performed on the chart take effect. -
notifyDataSetChanged()
: Lets the chart know it's underlying data has changed and performs all necessary recalculations (offsets, legend, maxima, minima, ...). This is needed especially when adding data dynamically.
Logging
-
setLogEnabled(boolean enabled)
: Setting this to true will activate chart logcat output. Enabling this is bad for performance, keep disabled if not necessary.
General Chart Styling
Here are some general styling methods you can directly use on the chart:
-
setBackgroundColor(int color)
: Sets the background color that will cover the whole chart-view. In addition, a background-color can be set via.xml
in the layout file. -
setDescription(String desc)
: Set a description text that appears in the bottom right corner of the chart. -
setDescriptionColor(int color)
: Sets the color of the description text. -
setDescriptionPosition(float x, float y)
: Sets a custom position for the description text in pixels on the screen. -
setDescriptionTypeface(Typeface t)
: Sets theTypeface
used for drawing the description text. -
setDescriptionTextSize(float size)
: Sets the size of the description text in pixels, min 6f, max 16f. -
setNoDataText(String text)
: Sets the text that should appear if the chart is empty. -
setDrawGridBackground(boolean enabled)
: If enabled, the background rectangle behind the chart drawing-area will be drawn. -
setGridBackgroundColor(int color)
: Sets the color the grid-background should be drawn with. -
setDrawBorders(boolean enabled)
: Enables / disables drawing the chart borders (lines surrounding the chart). -
setBorderColor(int color)
: Sets the color of the chart border lines. -
setBorderWidth(float width)
: Sets the width of the chart border lines in dp. -
setMaxVisibleValueCount(int count)
: Sets the number of maximum visible drawn value-labels on the chart. This only takes affect whensetDrawValues()
is enabled.