Package com.storedobject.chart
Class GaugeChart
java.lang.Object
com.storedobject.chart.AbstractPart
com.storedobject.chart.Chart
com.storedobject.chart.AbstractChart
com.storedobject.chart.SelfPositioningChart
com.storedobject.chart.GaugeChart
- All Implemented Interfaces:
Component,ComponentPart,ComponentProperty,HasAnimation,HasData,HasEmphasis,HasPolarProperty,HasPosition
Gauge chart.
- Author:
- Syam
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAxis line used inGaugeChart.static classNeedle property of the gauge chart.Nested classes/interfaces inherited from class com.storedobject.chart.Chart
Chart.Emphasis, Chart.Label, Chart.LabelPosition -
Constructor Summary
ConstructorsConstructorDescriptionConstructor with a single needle for the gauge.GaugeChart(int needles) Constructor with number of needles for the gauge.GaugeChart(String valueName) Constructor with a single needle for the gauge. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDialZone(int percentage, AbstractColor color) Add a zone to the dial that should show in a different color.protected AbstractDataProvider<?> Get the data to embed.voidEncode the JSON string with the properties of this.getAxisLabel(boolean create) Get the axis label for this gauge.getAxisLine(boolean create) Get the axis line for this gauge.protected StringGet the label name for encoding label if exists.intGet number of needles.final PolarPropertygetPolarProperty(boolean create) Get the polar property.getValue()Get the current value.getValue(int needle) Get value of a given needle.voidsetDivisions(int divisions) Set number of divisions on the dial.voidsetEndAngle(int endAngle) Set the ending angle of the gauge.voidSet maximum value on the dial.voidSet minimum value on the dial.final voidsetPolarProperty(PolarProperty polarProperty) Set the polar property.voidsetStartAngle(int startAngle) Set the starting angle of the gauge.voidSet the current value.voidSet value of a given needle.voidshowNeedle(boolean showNeedle) Set whether needle should be shown or not.voidshowProgress(boolean showProgress) Set whether to show progress on the dial or not. typically, you may set this if the needle is hidden.Methods inherited from class com.storedobject.chart.SelfPositioningChart
getPosition, setPositionMethods inherited from class com.storedobject.chart.AbstractChart
setData, setData, setType, validateMethods inherited from class com.storedobject.chart.Chart
addParts, dataValue, dataValueIndex, declareData, getAnimation, getCoordinateSystem, getData, getEmphasis, getItemStyle, getLabel, getMarkArea, getMax, getMin, getName, getTooltip, getType, mainData, plotOn, plotOn, setAnimation, setColors, setCustomRenderer, setEmphasis, setItemStyle, setLabel, setMarkArea, setName, setTooltip, typeValueMethods inherited from class com.storedobject.chart.AbstractPart
equals, getId, getLabelTag, getSerial, getZ, hashCode, hasId, setSerial, setZMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.storedobject.chart.ComponentPart
className, getId, getRenderingIndex, getSerial, setRenderingIndex, setSerialMethods inherited from interface com.storedobject.chart.HasPolarProperty
setHoleRadius, setRadius
-
Constructor Details
-
GaugeChart
public GaugeChart()Constructor with a single needle for the gauge. -
GaugeChart
Constructor with a single needle for the gauge.- Parameters:
valueName- Name of the value for this gauge.
-
GaugeChart
public GaugeChart(int needles) Constructor with number of needles for the gauge.- Parameters:
needles- Number of needles for the gauge.
-
-
Method Details
-
showNeedle
public void showNeedle(boolean showNeedle) Set whether needle should be shown or not.Note: If you set this to
false, "progress" (SeeshowProgress(boolean)) will be switched on. If you don't want to display both needle and progress too, invokeshowProgress(boolean)after this.- Parameters:
showNeedle- True/false.
-
showProgress
public void showProgress(boolean showProgress) Set whether to show progress on the dial or not. typically, you may set this if the needle is hidden.- Parameters:
showProgress- True/false
-
dataToEmbed
Description copied from class:ChartGet the data to embed. This is useful only for those special charts that embed data in the chart itself rather than pointing to the dataset. Example:TreeChart,GaugeChartetc. If null is returned from this method, no data will be embedded.- Overrides:
dataToEmbedin classChart- Returns:
- Data to embed.
-
setValue
Set the current value. If there are more than one needle, value for the first needle will be set.- Parameters:
value- Value to set.
-
getValue
Get the current value. If there are more than one needle, value for the first needle will be returned.- Returns:
- Value.
-
setValue
Set value of a given needle. (Used when more than one needle is used).- Parameters:
value- Value to set.needle- Needle index.
-
getValue
Get value of a given needle. (Used when more than one needle is used).- Parameters:
needle- Needle index.- Returns:
- Value.
-
getNumberOfNeedles
public int getNumberOfNeedles()Get number of needles.- Returns:
- Number of needles.
-
getLabelName
Description copied from class:ChartGet the label name for encoding label if exists.- Overrides:
getLabelNamein classChart- Returns:
- Label name. Default is "label".
-
encodeJSON
Description copied from interface:ComponentPropertyEncode the JSON string with the properties of this.- Specified by:
encodeJSONin interfaceComponentProperty- Overrides:
encodeJSONin classChart- Parameters:
sb- Encoded JSON string to be appended to this.
-
getPolarProperty
Description copied from interface:HasPolarPropertyGet the polar property. (Iftrueis passed as the parameter, a new polar property will be created if not already exists).- Specified by:
getPolarPropertyin interfaceHasPolarProperty- Parameters:
create- Whether to create it or not.- Returns:
- Polar property.
-
setPolarProperty
Description copied from interface:HasPolarPropertySet the polar property.- Specified by:
setPolarPropertyin interfaceHasPolarProperty- Parameters:
polarProperty- Polar property to set. It could benull.
-
setStartAngle
public void setStartAngle(int startAngle) Set the starting angle of the gauge.- Parameters:
startAngle- Starting angle.
-
setEndAngle
public void setEndAngle(int endAngle) Set the ending angle of the gauge.- Parameters:
endAngle- Ending angle.
-
setDivisions
public void setDivisions(int divisions) Set number of divisions on the dial.- Parameters:
divisions- Number of divisions.
-
setMin
-
setMax
-
addDialZone
Add a zone to the dial that should show in a different color. You can add multiple zones and each zone should specify the percentage of the dial to which a given color can be used. So, if you want to show the first 20% in "yellow", the next 50% in "green" and the last 30% in "red", you should call this method as follows:addDialZone(20, new Color("yellow")); // First 20% addDialZone(70, new Color("green")); // Next 50% (that means, show up to 20 + 50 = 70%) addDialZone(100, new Color("red")); // Last 30% (that means, show up to 20 + 50 + 30 = 100%)- Parameters:
percentage- Percentage of the dial to which the given color should be used.color- Color.
-
getAxisLine
Get the axis line for this gauge.- Parameters:
create- If passed true, it will be created if not exists.- Returns:
- Axis Line instance
-
getAxisLabel
Get the axis label for this gauge.- Parameters:
create- If passed true, it will be created if not exists.- Returns:
- Label instance
-