admin管理员组文章数量:1416624
if(this.state.chartCategory == 'D3Chart'){
console.log("chartdata for d3 charts", this.state.d3line.chartData);
switch(this.state.chartType){
case 'area': return <div style={{width: 900, height:300}}><Areagraph data = {this.state.d3line.chartData} vars = {{x: this.state.d3line.x, y: this.state.d3line.y}} dispatch = {this.showFilter} title = {this.state.data.chartName}/></div>;
case 'pie': return <div style={{width: 900, height:500}}><Piegraph data = {this.state.d3line.chartData} vars = {{x: this.state.d3line.x, y: this.state.d3line.y}} dispatch = {this.showFilter} title = {this.state.data.chartName}/></div>;
case 'bar': return <div style={{width: 900, height:300}}><Bargraph data = {this.state.d3line.chartData} vars = {{x: this.state.d3line.x, y: this.state.d3line.y}} dispatch = {this.showFilter} title = {this.state.data.chartName}/></div>;
/*case 'column': return <div className = "graphContainer" style={{width: 900, height:300, overflow: "hidden", resize: "both", paddingBottom: "10px", border: "1px solid black"}}><Columngraph data = {this.state.d3line.chartData} vars = {{x: this.state.d3line.x, y: this.state.d3line.y}} dispatch = {this.showFilter} title = {this.state.data.chartName}/></div>;*/
case 'line' : return <div style={{width: 900, height:300}}><Linegraph data = {this.state.d3line.chartData} vars = {{x:this.state.d3line.x, y: this.state.d3line.y, group: this.state.d3line.x}} dispatch = {this.showFilter} title = {this.state.data.chartName}/></div>;
default: return null;
}
}
In the console I am printing the data which i want to convert from string to integerIf number, convert string to integer, number also taking as string, How to convert into number need to remove " "
If you check in the picture I need to convert, if it a number alone
if(this.state.chartCategory == 'D3Chart'){
console.log("chartdata for d3 charts", this.state.d3line.chartData);
switch(this.state.chartType){
case 'area': return <div style={{width: 900, height:300}}><Areagraph data = {this.state.d3line.chartData} vars = {{x: this.state.d3line.x, y: this.state.d3line.y}} dispatch = {this.showFilter} title = {this.state.data.chartName}/></div>;
case 'pie': return <div style={{width: 900, height:500}}><Piegraph data = {this.state.d3line.chartData} vars = {{x: this.state.d3line.x, y: this.state.d3line.y}} dispatch = {this.showFilter} title = {this.state.data.chartName}/></div>;
case 'bar': return <div style={{width: 900, height:300}}><Bargraph data = {this.state.d3line.chartData} vars = {{x: this.state.d3line.x, y: this.state.d3line.y}} dispatch = {this.showFilter} title = {this.state.data.chartName}/></div>;
/*case 'column': return <div className = "graphContainer" style={{width: 900, height:300, overflow: "hidden", resize: "both", paddingBottom: "10px", border: "1px solid black"}}><Columngraph data = {this.state.d3line.chartData} vars = {{x: this.state.d3line.x, y: this.state.d3line.y}} dispatch = {this.showFilter} title = {this.state.data.chartName}/></div>;*/
case 'line' : return <div style={{width: 900, height:300}}><Linegraph data = {this.state.d3line.chartData} vars = {{x:this.state.d3line.x, y: this.state.d3line.y, group: this.state.d3line.x}} dispatch = {this.showFilter} title = {this.state.data.chartName}/></div>;
default: return null;
}
}
In the console I am printing the data which i want to convert from string to integerIf number, convert string to integer, number also taking as string, How to convert into number need to remove " "
If you check in the picture I need to convert, if it a number alone
Share Improve this question edited Nov 24, 2017 at 9:17 siva asked Nov 24, 2017 at 8:40 sivasiva 451 gold badge4 silver badges12 bronze badges 3- have a look here – ztadic91 Commented Nov 24, 2017 at 8:48
- 3 Possible duplicate of How do I convert a string into an integer in JavaScript? – ztadic91 Commented Nov 24, 2017 at 8:49
- Possible duplicate of How to convert string to integer from json response in reactjs – Timothy Groote Commented Nov 24, 2017 at 10:35
1 Answer
Reset to default 1I'm not really sure if this really is different using ReactJs, but did you try to parseInt() the strings?
I'm not really understanding what you are trying to do, but the most simple way for type-conversion would be the native functions of Javascript!?
https://www.w3schools./jsref/jsref_parseint.asp
本文标签: javascriptConvert string to integer in reactjsStack Overflow
版权声明:本文标题:javascript - Convert string to integer in reactjs - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745252611a2649913.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论