|
| 1 | +/* |
| 2 | +Copyright 2016 Capital One Services, LLC |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and limitations under the License. |
| 14 | +
|
| 15 | +SPDX-Copyright: Copyright (c) Capital One Services, LLC |
| 16 | +SPDX-License-Identifier: Apache-2.0 |
| 17 | +*/ |
| 18 | + |
| 19 | +'use strict' |
| 20 | + |
| 21 | +import React, { Component } from 'react'; |
| 22 | +import { View, Text, StyleSheet } from 'react-native'; |
| 23 | + |
| 24 | +import { Pie } from 'react-native-pathjs-charts' |
| 25 | + |
| 26 | +const styles = StyleSheet.create({ |
| 27 | + container: { |
| 28 | + |
| 29 | + flex: 1, |
| 30 | + justifyContent: 'center', |
| 31 | + alignItems: 'center', |
| 32 | + backgroundColor: '#f7f7f7', |
| 33 | + }, |
| 34 | +}); |
| 35 | + |
| 36 | +class PieChartBasicAnimation extends Component { |
| 37 | + static navigationOptions = ({ navigation }) => ({ |
| 38 | + title: `Pie - Basic - Animation`, |
| 39 | + }); |
| 40 | + render() { |
| 41 | + let data = [{ |
| 42 | + "name": "Washington", |
| 43 | + "population": 7694980 |
| 44 | + }, |
| 45 | + { |
| 46 | + "name": "Oregon", |
| 47 | + "population": 2584160 |
| 48 | + }, { |
| 49 | + "name": "Minnesota", |
| 50 | + "population": 6590667, |
| 51 | + "color": {'r':223,'g':154,'b':20} |
| 52 | + }, { |
| 53 | + "name": "Alaska", |
| 54 | + "population": 7284698 |
| 55 | + } |
| 56 | + ] |
| 57 | + |
| 58 | + let options = { |
| 59 | + margin: { |
| 60 | + top: 20, |
| 61 | + left: 20, |
| 62 | + right: 20, |
| 63 | + bottom: 20 |
| 64 | + }, |
| 65 | + width: 350, |
| 66 | + height: 350, |
| 67 | + color: '#2980B9', |
| 68 | + r: 50, |
| 69 | + R: 150, |
| 70 | + legendPosition: 'topLeft', |
| 71 | + animate: { |
| 72 | + enabled: true, |
| 73 | + type: 'oneByOne', |
| 74 | + duration: 200, |
| 75 | + fillTransition: 3 |
| 76 | + }, |
| 77 | + label: { |
| 78 | + fontFamily: 'Arial', |
| 79 | + fontSize: 8, |
| 80 | + fontWeight: true, |
| 81 | + color: '#ECF0F1' |
| 82 | + } |
| 83 | + } |
| 84 | + |
| 85 | + return ( |
| 86 | + <View style={styles.container}> |
| 87 | + <Pie data={data} |
| 88 | + |
| 89 | + options={options} |
| 90 | + accessorKey="population" |
| 91 | + margin={{ top: 20, left: 20, right: 20, bottom: 20 }} |
| 92 | + color="#2980B9" |
| 93 | + pallete={ |
| 94 | + [ |
| 95 | + { 'r': 25, 'g': 99, 'b': 201 }, |
| 96 | + { 'r': 24, 'g': 175, 'b': 35 }, |
| 97 | + { 'r': 190, 'g': 31, 'b': 69 }, |
| 98 | + { 'r': 100, 'g': 36, 'b': 199 }, |
| 99 | + { 'r': 214, 'g': 207, 'b': 32 }, |
| 100 | + { 'r': 198, 'g': 84, 'b': 45 } |
| 101 | + ] |
| 102 | + } |
| 103 | + r={50} |
| 104 | + R={150} |
| 105 | + legendPosition="topLeft" |
| 106 | + label={{ |
| 107 | + fontFamily: 'Arial', |
| 108 | + fontSize: 8, |
| 109 | + fontWeight: true, |
| 110 | + color: '#ECF0F1' |
| 111 | + }} |
| 112 | + /> |
| 113 | + </View> |
| 114 | + ) |
| 115 | + } |
| 116 | +} |
| 117 | + |
| 118 | +export default PieChartBasicAnimation; |
0 commit comments