From c0be1b784885cc0dcc0a92d048d56da570d688e6 Mon Sep 17 00:00:00 2001 From: Julia Friesel Date: Wed, 21 Nov 2018 13:44:29 +0100 Subject: [PATCH] Replace svg with ART in chart --- components/chart/chart.js | 10 ++++---- components/chart/day-column.js | 43 +++++++++++++++++++------------- components/chart/dot-and-line.js | 26 +++++++++++-------- components/chart/styles.js | 14 ++++------- 4 files changed, 50 insertions(+), 43 deletions(-) diff --git a/components/chart/chart.js b/components/chart/chart.js index 74f3ae1..635cef3 100644 --- a/components/chart/chart.js +++ b/components/chart/chart.js @@ -2,7 +2,7 @@ import React, { Component } from 'react' import { View, FlatList, ActivityIndicator } from 'react-native' import range from 'date-range' import { LocalDate } from 'js-joda' -import Svg, { G } from 'react-native-svg' +import { Surface, Group as G } from 'react-native/Libraries/ART/ReactNativeART' import { makeYAxisLabels, makeHorizontalGrid } from './y-axis' import nfpLines from './nfp-lines' import DayColumn from './day-column' @@ -151,7 +151,7 @@ export default class CycleChart extends Component { height={this.symptomRowHeight / this.symptomRowSymptoms.length} > - {symptomIcons[symptomName].icon} - + })} @@ -168,7 +168,7 @@ export default class CycleChart extends Component { {makeYAxisLabels(this.columnHeight)} - - + ) columnElements.push(ltlLine) @@ -80,12 +80,12 @@ export default class DayColumn extends Component { if (this.fhmAndLtl.drawFhmLine) { const x = styles.nfpLine.strokeWidth / 2 - const fhmLine = () columnElements.push(fhmLine) @@ -123,11 +123,18 @@ export default class DayColumn extends Component { ) + const colWidth = config.columnWidth + const colHeight = this.props.chartHeight const column = ( - { columnElements } @@ -235,9 +242,9 @@ export default class DayColumn extends Component { })} - + {column} - + {cycleDayLabel} diff --git a/components/chart/dot-and-line.js b/components/chart/dot-and-line.js index 4d49008..21e9eeb 100644 --- a/components/chart/dot-and-line.js +++ b/components/chart/dot-and-line.js @@ -1,5 +1,5 @@ import React, { Component } from 'react' -import { Circle, Line } from 'react-native-svg' +import { Path, Shape } from 'react-native/Libraries/ART/ReactNativeART' import styles from './styles' import config from '../../config' @@ -27,11 +27,15 @@ export default class DotAndLine extends Component { } const dotStyle = exclude ? styles.curveDotsExcluded : styles.curveDots + const radius = dotStyle.r const dot = ( - ) @@ -42,12 +46,12 @@ export default class DotAndLine extends Component { function makeLine(currY, middleY, x, excludeLine) { const lineStyle = excludeLine ? styles.curveExcluded : styles.curve - return } \ No newline at end of file diff --git a/components/chart/styles.js b/components/chart/styles.js index d537116..2b2bc61 100644 --- a/components/chart/styles.js +++ b/components/chart/styles.js @@ -3,10 +3,10 @@ import { shadesOfRed, cycleDayColor } from '../../styles/index' const colorTemperature = '#765285' const colorTemperatureLight = '#a67fb5' -const dotRadius = 5 +export const dotRadius = 5 const lineWidth = 1.5 const colorLtl = '#feb47b' -const gridColor = 'lightgrey' +const gridColor = '#d3d3d3' const gridLineWidth = 0.5 const numberLabelFontSize = 13 @@ -41,13 +41,9 @@ const styles = { textAlign: 'center', } }, - rect: { - x:'0', - y:'0', - width: config.columnWidth, - stroke: gridColor, - strokeWidth: gridLineWidth, - fill: 'transparent' + stroke: { + color: gridColor, + width: gridLineWidth, } }, symptomIcon: {