refact: rename groupByValue to report value
This commit is contained in:
		
							parent
							
								
									36156d7284
								
							
						
					
					
						commit
						c5fc68efb6
					
				@ -11,7 +11,7 @@ class CreateTableController {
 | 
				
			|||||||
      label: chart.label,
 | 
					      label: chart.label,
 | 
				
			||||||
      type: chart.type,
 | 
					      type: chart.type,
 | 
				
			||||||
      table: chart.table,
 | 
					      table: chart.table,
 | 
				
			||||||
      groupByValue: chart.groupByValue,
 | 
					      reportValue: chart.reportValue,
 | 
				
			||||||
    })
 | 
					    })
 | 
				
			||||||
    document.dispatchEvent(this.updatedChartsEvent)
 | 
					    document.dispatchEvent(this.updatedChartsEvent)
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										12
									
								
								src/Models/Chart/Chart.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										12
									
								
								src/Models/Chart/Chart.js
									
									
									
									
										vendored
									
									
								
							@ -6,7 +6,7 @@ class Chart {
 | 
				
			|||||||
    this.label = props.label
 | 
					    this.label = props.label
 | 
				
			||||||
    this.table = props.table
 | 
					    this.table = props.table
 | 
				
			||||||
    this.type = props.type
 | 
					    this.type = props.type
 | 
				
			||||||
    this.groupByValue = props.groupByValue
 | 
					    this.reportValue = props.reportValue
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  get id () {
 | 
					  get id () {
 | 
				
			||||||
@ -34,13 +34,13 @@ class Chart {
 | 
				
			|||||||
    return this._chartType
 | 
					    return this._chartType
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  get groupByValue () {
 | 
					  get reportValue () {
 | 
				
			||||||
    return this._groupByValue
 | 
					    return this._reportValue
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  set groupByValue (value) {
 | 
					  set reportValue (value) {
 | 
				
			||||||
    this._groupByValue = value || this._groupByValue
 | 
					    this._reportValue = value || this._reportValue
 | 
				
			||||||
    return this._groupByValue
 | 
					    return this._reportValue
 | 
				
			||||||
  } 
 | 
					  } 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  set table (table) {
 | 
					  set table (table) {
 | 
				
			||||||
 | 
				
			|||||||
@ -30,7 +30,7 @@ class Charts {
 | 
				
			|||||||
        label: c.label,
 | 
					        label: c.label,
 | 
				
			||||||
        table: c.table.label,
 | 
					        table: c.table.label,
 | 
				
			||||||
        type: c.type,
 | 
					        type: c.type,
 | 
				
			||||||
        groupByValue: c.groupByValue
 | 
					        reportValue: c.reportValue
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    })
 | 
					    })
 | 
				
			||||||
    return chartProps
 | 
					    return chartProps
 | 
				
			||||||
@ -47,7 +47,7 @@ class Charts {
 | 
				
			|||||||
      label: chart.label,
 | 
					      label: chart.label,
 | 
				
			||||||
      type: chart.type,
 | 
					      type: chart.type,
 | 
				
			||||||
      table: chart.table,
 | 
					      table: chart.table,
 | 
				
			||||||
      groupByValue: chart.groupByValue
 | 
					      reportValue: chart.reportValue
 | 
				
			||||||
    })
 | 
					    })
 | 
				
			||||||
    return newChart
 | 
					    return newChart
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
				
			|||||||
@ -1,15 +1,15 @@
 | 
				
			|||||||
import Chart from './Chart.js'
 | 
					import Chart from './Chart.js'
 | 
				
			||||||
import { GroupByNodule } from 'lovelacejs'
 | 
					import { GroupByNodule } from 'lovelacejs'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class ChartJsDataset extends Chart {
 | 
					class OneAxisChart extends Chart {
 | 
				
			||||||
  constructor (props) {
 | 
					  constructor (props) {
 | 
				
			||||||
    super(props)
 | 
					    super(props)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    this.groupByNodule = new GroupByNodule({
 | 
					    this.groupByNodule = new GroupByNodule({
 | 
				
			||||||
      id: this.id,
 | 
					      id: this.id,
 | 
				
			||||||
      label: `${this.label} groupedBy ${this.groupByValue}`,
 | 
					      label: `${this.label} groupedBy ${this.reportValue}`,
 | 
				
			||||||
      tables: [this.table],
 | 
					      tables: [this.table],
 | 
				
			||||||
      groupByValue: this.groupByValue
 | 
					      groupByValue: this.reportValue
 | 
				
			||||||
    }).export()
 | 
					    }).export()
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    this.chartLabels = Object.keys(this.groupByNodule)
 | 
					    this.chartLabels = Object.keys(this.groupByNodule)
 | 
				
			||||||
@ -35,7 +35,7 @@ class ChartJsDataset extends Chart {
 | 
				
			|||||||
    return {
 | 
					    return {
 | 
				
			||||||
      labels: this.chartLabels,
 | 
					      labels: this.chartLabels,
 | 
				
			||||||
      datasets: [{
 | 
					      datasets: [{
 | 
				
			||||||
        label: `${this.label} groupedBy ${this.groupByValue}`,
 | 
					        label: `${this.label} groupedBy ${this.reportValue}`,
 | 
				
			||||||
        data: this.groupByCounts,
 | 
					        data: this.groupByCounts,
 | 
				
			||||||
        backgroundColor: this._getbackgroundColors()
 | 
					        backgroundColor: this._getbackgroundColors()
 | 
				
			||||||
      }],
 | 
					      }],
 | 
				
			||||||
@ -57,7 +57,7 @@ class ChartJsDataset extends Chart {
 | 
				
			|||||||
    return {
 | 
					    return {
 | 
				
			||||||
      labels: this.chartLabels,
 | 
					      labels: this.chartLabels,
 | 
				
			||||||
      datasets: [{
 | 
					      datasets: [{
 | 
				
			||||||
        label: `${this.label} groupedBy ${this.groupByValue}`,
 | 
					        label: `${this.label} groupedBy ${this.reportValue}`,
 | 
				
			||||||
        data: this.groupByCounts,
 | 
					        data: this.groupByCounts,
 | 
				
			||||||
        backgroundColor: this._getbackgroundColors()
 | 
					        backgroundColor: this._getbackgroundColors()
 | 
				
			||||||
      }],
 | 
					      }],
 | 
				
			||||||
@ -101,4 +101,4 @@ class ChartJsDataset extends Chart {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export default ChartJsDataset
 | 
					export default OneAxisChart
 | 
				
			||||||
 | 
				
			|||||||
@ -16,7 +16,7 @@ class ChartListItem extends Component {
 | 
				
			|||||||
      <Card key={chart.id} id={chart.id} style={{ width: '380px' }}>
 | 
					      <Card key={chart.id} id={chart.id} style={{ width: '380px' }}>
 | 
				
			||||||
        <Card.Content>
 | 
					        <Card.Content>
 | 
				
			||||||
          <Card.Header>{ chart.label }</Card.Header>
 | 
					          <Card.Header>{ chart.label }</Card.Header>
 | 
				
			||||||
          <Card.Meta>{`${chart.table} grouped by ${chart.groupByValue}`}</Card.Meta>
 | 
					          <Card.Meta>{`${chart.table} grouped by ${chart.reportValue}`}</Card.Meta>
 | 
				
			||||||
        </Card.Content>
 | 
					        </Card.Content>
 | 
				
			||||||
        <Card.Content extra>
 | 
					        <Card.Content extra>
 | 
				
			||||||
          <span 
 | 
					          <span 
 | 
				
			||||||
 | 
				
			|||||||
@ -11,14 +11,14 @@ class ChartViewer extends Component {
 | 
				
			|||||||
    this.chart = React.createRef()
 | 
					    this.chart = React.createRef()
 | 
				
			||||||
    this.state = {
 | 
					    this.state = {
 | 
				
			||||||
      chart: null,
 | 
					      chart: null,
 | 
				
			||||||
      groupByValue: ''
 | 
					      reportValue: ''
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    document.addEventListener('setSelectedChart', this.setFocusChart)
 | 
					    document.addEventListener('setSelectedChart', this.setFocusChart)
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  handleGroupByChange = (e, value) => {
 | 
					  handleGroupByChange = (e, value) => {
 | 
				
			||||||
    this.setState({ groupByValue: value.value })
 | 
					    this.setState({ reportValue: value.value })
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  saveChart = () => {
 | 
					  saveChart = () => {
 | 
				
			||||||
@ -40,6 +40,8 @@ class ChartViewer extends Component {
 | 
				
			|||||||
    const { chart } = this.state
 | 
					    const { chart } = this.state
 | 
				
			||||||
    if (!chart) return
 | 
					    if (!chart) return
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    console.log(chart)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (chart.type === 'bar')  return <Bar data={chart[chart.type]} width={600} height={600} ref={this.chart} />
 | 
					    if (chart.type === 'bar')  return <Bar data={chart[chart.type]} width={600} height={600} ref={this.chart} />
 | 
				
			||||||
    if (chart.type === 'doughnut')  return <Doughnut data={chart[chart.type]} width={600} height={600} ref={this.chart} />
 | 
					    if (chart.type === 'doughnut')  return <Doughnut data={chart[chart.type]} width={600} height={600} ref={this.chart} />
 | 
				
			||||||
    if (chart.type === 'line')  return <Line data={chart[chart.type]} width={600} height={600} ref={this.chart} />
 | 
					    if (chart.type === 'line')  return <Line data={chart[chart.type]} width={600} height={600} ref={this.chart} />
 | 
				
			||||||
 | 
				
			|||||||
@ -16,7 +16,7 @@ class CreateChartForm extends Component {
 | 
				
			|||||||
      chartType: '',
 | 
					      chartType: '',
 | 
				
			||||||
      selectedTableId: '',
 | 
					      selectedTableId: '',
 | 
				
			||||||
      tables: this.tables.getCollectionProps(),
 | 
					      tables: this.tables.getCollectionProps(),
 | 
				
			||||||
      groupByValue: '',
 | 
					      reportValue: '',
 | 
				
			||||||
      headers : []
 | 
					      headers : []
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -25,7 +25,7 @@ class CreateChartForm extends Component {
 | 
				
			|||||||
    this.controller = new CreateChartController()
 | 
					    this.controller = new CreateChartController()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    this.chartLabelInput = React.createRef()
 | 
					    this.chartLabelInput = React.createRef()
 | 
				
			||||||
    this.groupByValueInput = React.createRef()
 | 
					    this.reportValueInput = React.createRef()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    document.addEventListener('updateTables', this.updateTableList)
 | 
					    document.addEventListener('updateTables', this.updateTableList)
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@ -46,7 +46,7 @@ class CreateChartForm extends Component {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  handleGroupByChange = (e, value) => {
 | 
					  handleGroupByChange = (e, value) => {
 | 
				
			||||||
    this.setState({ groupByValue: value.value })
 | 
					    this.setState({ reportValue: value.value })
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  handleSelectedTableChange = (e, value) => {
 | 
					  handleSelectedTableChange = (e, value) => {
 | 
				
			||||||
@ -82,16 +82,16 @@ class CreateChartForm extends Component {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  handleSubmit = () => {
 | 
					  handleSubmit = () => {
 | 
				
			||||||
    const { chartType, selectedTableId, groupByValue } = this.state
 | 
					    const { chartType, selectedTableId, reportValue } = this.state
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const chartLabel = this.chartLabelInput.current.inputRef.current.value
 | 
					    const chartLabel = this.chartLabelInput.current.inputRef.current.value
 | 
				
			||||||
    // const groupByValue = this.groupByValueInput.current.inputRef.current.value
 | 
					    // const reportValue = this.reportValueInput.current.inputRef.current.value
 | 
				
			||||||
    const table = this.tables.getById(selectedTableId)
 | 
					    const table = this.tables.getById(selectedTableId)
 | 
				
			||||||
    this.controller.addNewChart({
 | 
					    this.controller.addNewChart({
 | 
				
			||||||
      label: chartLabel,
 | 
					      label: chartLabel,
 | 
				
			||||||
      type: chartType,
 | 
					      type: chartType,
 | 
				
			||||||
      table: table,
 | 
					      table: table,
 | 
				
			||||||
      groupByValue: groupByValue
 | 
					      reportValue: reportValue
 | 
				
			||||||
    })
 | 
					    })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    this.clearInput()
 | 
					    this.clearInput()
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user