Skip to content

Commit

Permalink
fix pieEntryLabelColor & pieEntryLabelTextSize for iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
wuxudong committed Apr 23, 2017
1 parent 9460af0 commit e306389
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 9 deletions.
14 changes: 8 additions & 6 deletions Example/app/PieChartScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ class PieChartScreen extends React.Component {
label: 'Pie dataset',
config: {
colors: [processColor('#C0FF8C'), processColor('#FFF78C'), processColor('#FFD08C'), processColor('#8CEAFF'), processColor('#FF8C9D')],

valueTextSize: 20,
valueTextColor: processColor('green'),
sliceSpace: 5,
selectionShift: 13
}
Expand Down Expand Up @@ -71,10 +72,15 @@ class PieChartScreen extends React.Component {
style={styles.chart}
logEnabled={true}
chartBackgroundColor={processColor('pink')}
description={this.state.description}
chartDescription={this.state.description}
data={this.state.data}
legend={this.state.legend}

entryLabelColor = {processColor('black')}
entryLabelTextSize = {20}


rotationEnabled={false}
drawSliceText={true}
usePercentValues={false}
centerText={'Pie center text!'}
Expand All @@ -83,10 +89,6 @@ class PieChartScreen extends React.Component {
holeColor={processColor('#f0f0f0')}
transparentCircleRadius={45}
transparentCircleColor={processColor('#f0f0f088')}

entryLabelColor={processColor('black')}
entryLabelTextSize={8}

maxAngle={350}
onSelect={this.handleSelect.bind(this)}
/>
Expand Down
2 changes: 1 addition & 1 deletion Example/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use_frameworks!

target 'Example' do
pod 'SwiftyJSON', '3.1.4'
pod 'Charts', '3.0.1'
pod 'Charts', '3.0.2'
end

post_install do |installer|
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.facebook.react:react-native:0.20.+'
compile 'com.github.PhilJay:MPAndroidChart:v3.0.1'
compile 'com.github.PhilJay:MPAndroidChart:v3.0.2'
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ public static void commonConfig(DataSet dataSet, ReadableMap config) {
dataSet.setValueTextSize((float) config.getDouble("valueTextSize"));
}

if (BridgeUtils.validate(config, ReadableType.Number, "valueTextColor")) {
dataSet.setValueTextColor(config.getInt("valueTextColor"));
}

if (BridgeUtils.validate(config, ReadableType.String, "valueFormatter")) {
String valueFormatter = config.getString("valueFormatter");

Expand Down
11 changes: 10 additions & 1 deletion ios/ReactNativeCharts/pie/RNPieChartView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@ class RNPieChartView: RNChartViewBase {
}

func setRotationEnabled(_ enabled: Bool) {
_chart.rotationEnabled = enabled
chart.rotationEnabled = enabled
}

override func didSetProps(_ changedProps: [String]!) {
super.didSetProps(changedProps);
let pieChartDataSet = chart.data?.dataSets[0] as? PieChartDataSet

pieChartDataSet?.entryLabelColor = chart.entryLabelColor
pieChartDataSet?.entryLabelFont = chart.entryLabelFont
}

}
4 changes: 4 additions & 0 deletions ios/ReactNativeCharts/utils/ChartDataSetConfigUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ class ChartDataSetConfigUtils: NSObject {
dataSet.valueFont = dataSet.valueFont.withSize(CGFloat(config["valueTextSize"].numberValue))
}

if config["valueTextColor"].int != nil {
dataSet.valueTextColor = RCTConvert.uiColor(config["valueTextColor"].intValue)
}

if config["visible"].bool != nil {
dataSet.visible = config["visible"].boolValue
}
Expand Down
1 change: 1 addition & 0 deletions lib/ChartDataSetConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const chartDataSetConfig = {
highlightEnabled:PropTypes.bool,
drawValues: PropTypes.bool,
valueTextSize:PropTypes.number,
valueTextColor:PropTypes.number,
visible:PropTypes.bool,
valueFormatter: PropTypes.oneOfType([
PropTypes.oneOf(['largeValue', 'percent']),
Expand Down

0 comments on commit e306389

Please sign in to comment.