react-native-pathjs-charts
Version:
Cross platform React Native charting library based on path-js and react-native-svg
127 lines (115 loc) • 2.83 kB
JavaScript
/*
Copyright 2016 Capital One Services, LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
SPDX-Copyright: Copyright (c) Capital One Services, LLC
SPDX-License-Identifier: Apache-2.0
*/
import React, { Component } from 'react';
import { View, Text, StyleSheet } from 'react-native';
import { StockLine } from 'react-native-pathjs-charts'
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#f7f7f7',
},
});
class StockLineChartStaticTickLabels extends Component {
static navigationOptions = ({ navigation }) => ({
title: `StockLine - Static Labels`,
});
render() {
let data = [
[{
"x": 0,
"y": 47782
}, {
"x": 1,
"y": 48497
}, {
"x": 2,
"y": 77128
}, {
"x": 3,
"y": 73413
}, {
"x": 4,
"y": 58257
}, {
"x": 5,
"y": 40579
}, {
"x": 6,
"y": 72893
}]
]
let options = {
width: 250,
height: 250,
color: '#2980B9',
margin: {
top: 10,
left: 35,
bottom: 30,
right: 10
},
animate: {
type: 'delayed',
duration: 200
},
axisX: {
showAxis: true,
showLines: true,
showLabels: true,
showTicks: true,
zeroAxis: false,
orient: 'bottom',
tickValues: [
{value:'name1'},
{value:'name2'},
{value:'name3'},
{value:'name4'},
{value:'name5'},
{value:'name6'},
{value:'name7'}
],
label: {
fontFamily: 'Arial',
fontSize: 8,
fontWeight: true,
fill: '#34495E'
}
},
axisY: {
showAxis: true,
showLines: true,
showLabels: true,
showTicks: true,
zeroAxis: false,
orient: 'left',
tickValues: [],
label: {
fontFamily: 'Arial',
fontSize: 8,
fontWeight: true,
fill: '#34495E'
}
}
}
return (
<View style={styles.container}>
<StockLine data={data} options={options} xKey='x' yKey='y' />
</View>
)
}
}
export default StockLineChartStaticTickLabels;