triz-react-native-wordcloud
Advanced tools
Comparing version 1.0.11 to 1.0.12
@@ -5,3 +5,3 @@ import * as React from 'react'; | ||
wordList?: any[]; // ex) [{ word: 'Triz', size: 1 }, { word: 'Triz', size: 0 }, { word: 'Triz', size: 2 }, { word: 'Triz', size: 1 }] | ||
colorList?: string[]; // default ['#405de6', '#5851db', '#833ab4', '#c13584', '#e1306c', '#fd1d1d', '#f56040', '#f77737', '#fcaf45', '#ffdc80'] | ||
colorList?: string[]; // default [ '#405de6', '#833ab4', '#e1306c', '#f56040', '#fd1d1d' ] | ||
minFontSize?: number; // default 10 | ||
@@ -8,0 +8,0 @@ wordVerticalPadding?: number; // default 10, |
{ | ||
"name": "triz-react-native-wordcloud", | ||
"version": "1.0.11", | ||
"version": "1.0.12", | ||
"description": "React Native View for Word cloud", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -5,5 +5,5 @@ import * as React from 'react'; | ||
import fetch from 'node-fetch'; | ||
import data from './data.json'; | ||
const API_SERVER = 'https://6e9a75k68k.execute-api.ap-northeast-2.amazonaws.com/dev/wordclouds'; | ||
const MAX_SIZE = 9; | ||
const MAX_WORDLIST_CNT = 20; | ||
@@ -16,11 +16,20 @@ | ||
let dataIndex = Math.floor(Math.random() * data.wordClouds.length); | ||
this.state = { | ||
wordList: [], | ||
wordList: data.wordClouds[dataIndex], | ||
}; | ||
this.getWordList().then((wordList) => { | ||
/* this.getWordList().then((wordList) => { | ||
this.setState({ | ||
wordList: wordList, | ||
}); | ||
}); | ||
}); */ | ||
// 15초에 한 번 reload | ||
setInterval(() => { | ||
let dataIndex = Math.floor(Math.random() * data.wordClouds.length); | ||
this.setState({ | ||
wordList: data.wordClouds[dataIndex], | ||
}); | ||
}, 15000); | ||
} | ||
@@ -50,15 +59,12 @@ | ||
let WordStyle = {}; | ||
if (wordList[i].size > MAX_SIZE) { | ||
WordStyle = { | ||
fontSize: this.props.minFontSize + MAX_SIZE * 2, | ||
color: this.props.colorList[MAX_SIZE], | ||
}; | ||
} else { | ||
WordStyle = { | ||
fontSize: this.props.minFontSize + wordList[i].size * 2, | ||
color: this.props.colorList[wordList[i].size], | ||
}; | ||
if (wordList[i].size > 5) { | ||
wordList[i].size = 5; | ||
} | ||
let WordStyle = { | ||
fontSize: this.props.minFontSize + wordList[i].size * 2, | ||
color: this.props.colorList[wordList[i].size - 1], | ||
fontWeight: wordList[i].size > 3 ? 'bold' : '500', | ||
}; | ||
newWordCloud.push( | ||
@@ -131,3 +137,5 @@ <View key={i} style={WordContainerStyle}> | ||
wordList = resultJson.data.wordList; | ||
if (Array.isArray(resultJson.data.wordList)) { | ||
wordList = resultJson.data.wordList; | ||
} | ||
} catch (err) { | ||
@@ -174,14 +182,3 @@ console.log('getWordList', err); | ||
wordList: [], | ||
colorList: [ | ||
'#405de6', | ||
'#5851db', | ||
'#833ab4', | ||
'#c13584', | ||
'#e1306c', | ||
'#fd1d1d', | ||
'#f56040', | ||
'#f77737', | ||
'#fcaf45', | ||
'#ffdc80', | ||
], | ||
colorList: ['#405de6', '#833ab4', '#e1306c', '#f56040', '#fd1d1d'], | ||
minFontSize: 10, | ||
@@ -188,0 +185,0 @@ wordVerticalPadding: 10, |
6589
173