-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set axes color and added AxesTextColor property #3316
base: ucr
Are you sure you want to change the base?
Changes from all commits
71b291d
c1c63ff
810581c
a2bc8c9
415bda0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,7 @@ open class AxisChartView : ChartView { | |
(chart as? BarLineChartViewBase)?.leftAxis.granularity = 1 | ||
} | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We probably don't need an extra blank line. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please reset this file as mentioned. |
||
|
||
// sets whether the X origin should be fixed to 0 | ||
public func setXMinimum (zero: Bool) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,11 +52,14 @@ import DGCharts | |
var _gridEnabled = true | ||
var _labels = [String]() | ||
var _dataComponents: Array<ChartDataBase> = [] | ||
|
||
var _axesTextColor: UIColor | ||
|
||
@objc public override init(_ parent: ComponentContainer) { | ||
XFromZero = false | ||
YFromZero = false | ||
_backgroundColor = parent.form?.isDarkTheme == true ? UIColor.black : UIColor.white | ||
_backgroundColor = parent.form?.isDarkTheme == true ? UIColor.white : UIColor.black | ||
_axesTextColor = parent.form?.isDarkTheme == true ? UIColor.white : UIColor.black | ||
super.init(parent) | ||
setDelegate(self) | ||
parent.add(self) | ||
|
@@ -112,6 +115,21 @@ import DGCharts | |
_chartView?.backgroundColor = _backgroundColor | ||
} | ||
} | ||
|
||
@objc open var AxesTextColor: Int32 { | ||
get { | ||
return colorToArgb(_axesTextColor) | ||
} | ||
set { | ||
_axesTextColor = argbToColor(newValue) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make sure to appropriately handle if |
||
print("changing label color to") | ||
print(_axesTextColor) | ||
if let chartView = _chartView?.chart as? BarLineChartViewBase { | ||
chartView.xAxisRenderer.axis.labelTextColor = _axesTextColor | ||
chartView.leftYAxisRenderer.axis.labelTextColor = _axesTextColor | ||
} | ||
} | ||
} | ||
|
||
@objc open var Description: String { | ||
get { | ||
|
@@ -287,6 +305,8 @@ import DGCharts | |
Labels = _labels | ||
LegendEnabled = _legendEnabled | ||
PieRadius = _pieRadius | ||
|
||
AxesTextColor = colorToArgb(_axesTextColor) | ||
} | ||
|
||
func addDataComponent(_ dataComponent: ChartDataBase) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,8 @@ import DGCharts | |
var _color: Int32 = AIComponentKit.Color.black.int32 | ||
var _colors: [UIColor] = [] | ||
var _label: String? | ||
|
||
var _dataLabelColor: Int32 = AIComponentKit.Color.black.int32 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to make this conditional on dark theme similar to what you did in Chart.swift? |
||
|
||
var dataFileColumns: Array<String> = [] | ||
var _lineType = AIComponentKit.LineType.Linear | ||
|
@@ -54,6 +56,7 @@ import DGCharts | |
ElementsFromPairs = elements | ||
} | ||
_chartDataModel?.setColor(argbToColor(_color)) | ||
_chartDataModel?.setDataLabelColor(argbToColor(_dataLabelColor)) | ||
if !_colors.isEmpty { | ||
_chartDataModel?.setColors(_colors) | ||
} | ||
|
@@ -94,6 +97,18 @@ import DGCharts | |
onDataChange() | ||
} | ||
} | ||
|
||
@objc open var DataLabelColor: Int32 { | ||
get { | ||
return _dataLabelColor | ||
} | ||
set { | ||
_dataLabelColor = newValue | ||
_chartDataModel?.dataset?.valueTextColor = argbToColor(newValue) | ||
print("changing data text color", _dataLabelColor) | ||
refreshChart() | ||
} | ||
} | ||
|
||
func initChartData() { | ||
print("in initChartData") | ||
|
@@ -102,6 +117,7 @@ import DGCharts | |
// set default values | ||
_chartDataModel?.setColor(argbToColor(_color)) | ||
_chartDataModel?.setLabel(_label ?? "") | ||
_chartDataModel?.setDataLabelColor(argbToColor(_dataLabelColor)) | ||
} | ||
|
||
@objc open var LineType: LineType { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We will need to reset this since the change is already in ucr. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,8 @@ | |
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import com.github.mikephil.charting.data.ChartData; | ||
|
||
/** | ||
* Base class for Chart Data components. Contains functionality common | ||
* to any Chart Data component. The component corresponds to a single | ||
|
@@ -45,6 +47,8 @@ public abstract class ChartDataBase extends DataCollection<Chart, ChartDataModel | |
private int color; | ||
private YailList colors; | ||
|
||
private int dataLabelColor; | ||
|
||
/** | ||
* Creates a new Chart Data component. | ||
*/ | ||
|
@@ -57,6 +61,8 @@ protected ChartDataBase(Chart chartContainer) { | |
Color(Component.COLOR_BLACK); | ||
DataSourceKey(""); | ||
Label(""); | ||
|
||
DataLabelColor(Component.COLOR_BLACK); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See my note on the iOS version about whether we need to adjust this for dark theme. |
||
} | ||
|
||
/** | ||
|
@@ -160,6 +166,31 @@ public void Colors(YailList colors) { | |
onDataChange(); | ||
} | ||
|
||
/** | ||
* Returns the data label color as an alpha-red-green-blue integer. | ||
* | ||
* @return background RGB color with alpha | ||
*/ | ||
@SimpleProperty( | ||
category = PropertyCategory.APPEARANCE) | ||
public int DataLabelColor() { | ||
return dataLabelColor; | ||
} | ||
|
||
/** | ||
* Specifies the data points label color as an alpha-red-green-blue integer. | ||
* | ||
* @param argb background RGB color with alpha | ||
*/ | ||
@DesignerProperty(editorType = PropertyTypeConstants.PROPERTY_TYPE_COLOR, | ||
defaultValue = Component.DEFAULT_VALUE_COLOR_BLACK) | ||
@SimpleProperty | ||
public void DataLabelColor(int argb) { | ||
dataLabelColor = argb; | ||
dataModel.setDataLabelColor(argb); | ||
onDataChange(); | ||
} | ||
|
||
/** | ||
* Returns the label text of the data series. | ||
* | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,6 +99,7 @@ public void setColor(int argb) { | |
} | ||
} | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please reset this file since this is a whitespace only change. |
||
@Override | ||
public void setColors(List<Integer> colors) { | ||
super.setColors(colors); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,8 @@ | |
import com.github.mikephil.charting.charts.BarLineChartBase; | ||
import com.github.mikephil.charting.data.BarLineScatterCandleBubbleData; | ||
import com.github.mikephil.charting.data.Entry; | ||
import com.github.mikephil.charting.renderer.XAxisRenderer; | ||
import com.github.mikephil.charting.renderer.YAxisRenderer; | ||
|
||
import com.github.mikephil.charting.interfaces.datasets.IBarLineScatterCandleBubbleDataSet; | ||
|
||
|
@@ -51,4 +53,14 @@ protected void initializeDefaultSettings() { | |
public View getView() { | ||
return chart; | ||
} | ||
/** | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Code style: Include a blank line before the Javadoc to visually separate it from the previous function body. |
||
* Sets the color of the axes text of the Point Chart. | ||
* | ||
* @param color color to set text to. | ||
*/ | ||
public void setAxesTextColor(int color){ | ||
System.out.println("the color is" + color); | ||
XAxisRenderer xAxisRenderer = chart.getRendererXAxis(); | ||
xAxisRenderer.getPaintAxisLabels().setColor(color); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like you need to add the function for upgrading the ChartData2D component.