refact: renamed ChartjsDataset to One AxisChart
This commit is contained in:
parent
e657c43d74
commit
5bc50c3770
@ -1,3 +1,3 @@
|
||||
export default [
|
||||
'line', 'bar', 'radar', 'doughnut', 'pie', 'polar', /*'bubble', 'scatter', 'area', 'mixed' */
|
||||
]
|
||||
export default {
|
||||
oneAxisCharts: ['line', 'bar', 'radar', 'doughnut', 'pie', 'polar'] /*'bubble', 'scatter', 'area', 'mixed' */
|
||||
}
|
||||
|
@ -1,3 +0,0 @@
|
||||
export default [
|
||||
'line', 'bar', 'radar', 'doughnut', 'pie', 'polar', /*'bubble', 'scatter', 'area', 'mixed' */
|
||||
]
|
3
src/Models/Chart/Chart.js
vendored
3
src/Models/Chart/Chart.js
vendored
@ -57,7 +57,8 @@ class Chart {
|
||||
}
|
||||
|
||||
_validateChartType = type => {
|
||||
if (chartTypes.includes(type)) return true
|
||||
const allChartTypes = Object.values(chartTypes).flat()
|
||||
if (allChartTypes.includes(type)) return true
|
||||
else return false
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { uuid } from 'uuidv4'
|
||||
import ChartJsDataset from '../../Models/Chart/ChartjsDataset'
|
||||
import chartjsTypes from '../../Constants/chartjsTypes'
|
||||
import OneAxisChart from '../../Models/Chart/OneAxisChart'
|
||||
import chartTypes from '../../Constants/chartTypes'
|
||||
|
||||
let instance = null
|
||||
|
||||
@ -13,7 +13,7 @@ class Charts {
|
||||
|
||||
addNewChart = chart => {
|
||||
let newChart = null
|
||||
if (chartjsTypes.includes(chart.type)) newChart = this._generateChartJsDataset(chart)
|
||||
if (chartTypes.oneAxisCharts.includes(chart.type)) newChart = this._generateOneAxisChart(chart)
|
||||
|
||||
if (newChart) this.collection.push(newChart)
|
||||
}
|
||||
@ -41,8 +41,8 @@ class Charts {
|
||||
if (indexToRemove > -1) this.collection.splice(indexToRemove, 1)
|
||||
}
|
||||
|
||||
_generateChartJsDataset = chart => {
|
||||
const newChart = new ChartJsDataset({
|
||||
_generateOneAxisChart = chart => {
|
||||
const newChart = new OneAxisChart({
|
||||
id: chart.id || uuid(),
|
||||
label: chart.label,
|
||||
type: chart.type,
|
||||
|
@ -1,6 +1,5 @@
|
||||
import React, { Component } from 'react'
|
||||
import { Button, Input, Header, Dropdown } from 'semantic-ui-react'
|
||||
// import './CreateNodule.css'
|
||||
|
||||
import Tables from '../../Models/Tables'
|
||||
import Nodules from '../../Models/Nodules'
|
||||
@ -36,7 +35,8 @@ class CreateChartForm extends Component {
|
||||
}
|
||||
|
||||
getChartTypeDropdownOptions = () => {
|
||||
return chartTypes.map(t => {
|
||||
const allChartTypes = Object.values(chartTypes).flat()
|
||||
return allChartTypes.map(t => {
|
||||
return {key: t, text: t, value: t}
|
||||
})
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user