From 318104aa9e942e0738ffb14d89c89d7355e8607b Mon Sep 17 00:00:00 2001 From: Joshua Shoemaker Date: Wed, 5 Aug 2020 23:43:08 -0500 Subject: [PATCH] refact: changed ChartjsChart to CharjsDataset --- .../Chart/{ChartjsChart.js => ChartjsDataset.js} | 16 +++------------- src/views/Chart/ChartViewer.js | 10 +++++----- 2 files changed, 8 insertions(+), 18 deletions(-) rename src/Models/Chart/{ChartjsChart.js => ChartjsDataset.js} (76%) diff --git a/src/Models/Chart/ChartjsChart.js b/src/Models/Chart/ChartjsDataset.js similarity index 76% rename from src/Models/Chart/ChartjsChart.js rename to src/Models/Chart/ChartjsDataset.js index 527a974..dd35feb 100644 --- a/src/Models/Chart/ChartjsChart.js +++ b/src/Models/Chart/ChartjsDataset.js @@ -1,16 +1,12 @@ import Chart from './Chart.js' import { GroupByNodule } from 'lovelacejs' -class ChartJsChart extends Chart { - constructor (props) { - super(props) - } - +class ChartJsDataset extends Chart { get props () { const groupByNodule = new GroupByNodule({ id: this.table.id, - label: `${this.table.label} groupedBy something`, + label: `${this.table.label} groupedBy ${this.groupByValue}`, tables: [this.table], groupByValue: this.groupByValue }).export() @@ -30,12 +26,6 @@ class ChartJsChart extends Chart { backgroundColor: this._getbackgroundColors() }], } - - // return [{ - // label: this.label, - // data: groupByCounts, - // backgroundColor: this._getbackgroundColors() - // }] } _generateRandomRGBNumber () { @@ -53,4 +43,4 @@ class ChartJsChart extends Chart { } } -export default ChartJsChart +export default ChartJsDataset diff --git a/src/views/Chart/ChartViewer.js b/src/views/Chart/ChartViewer.js index 5ed43d8..44b3dad 100644 --- a/src/views/Chart/ChartViewer.js +++ b/src/views/Chart/ChartViewer.js @@ -1,5 +1,5 @@ import React, { Component } from 'react' -import ChartJsChart from '../../Models/Chart/ChartjsChart' +import ChartJsDataset from '../../Models/Chart/ChartjsDataset' import FocusTable from '../../Models/FocusTable' import { Doughnut } from 'react-chartjs-2' import { Dropdown } from 'semantic-ui-react' @@ -32,14 +32,14 @@ class ChartViewer extends Component { renderChart = () => { if (!this.state.table) return - const chart = new ChartJsChart({ - label: 'test chart', + const chart = new ChartJsDataset({ + label: this.state.label, type: 'bar', table: this.state.table, groupByValue: this.state.groupByValue }) - console.log(chart.props) + console.log(chart) return } @@ -59,7 +59,7 @@ class ChartViewer extends Component { return (