在reactjs

时间:2017-11-24 08:40:51

标签: javascript reactjs

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;
       }   

    }

在控制台中,我打印要从字符串转换为整数If number, convert string to integer, number also taking as string, How to convert into number need to remove " "

的数据

如果您签入我需要转换的图片,如果只是一个数字

1 个答案:

答案 0 :(得分:0)

我不确定使用ReactJs是否真的有所不同,但你是否尝试将字符串parseInt()?

我并不是真正理解你想要做什么,但是最简单的类型转换方式是Javascript的原生功能!?

https://www.w3schools.com/jsref/jsref_parseint.asp