Skip to content
Open

Axis #17

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
3b36e2c
category input post attempt
cyyan88 Dec 6, 2021
2bf697f
create category and show on sidebar
cyyan88 Dec 7, 2021
dca8ca8
category page exists
cyyan88 Dec 9, 2021
bb01330
add categories to sidebar and dropdown
cyyan88 Dec 13, 2021
d1eb613
separate category & data modal
cyyan88 Dec 19, 2021
fb4157a
select category sidebar
cyyan88 Dec 24, 2021
be64c40
category data shows up
cyyan88 Dec 29, 2021
696d8df
show data for each category
cyyan88 Jan 1, 2022
37ab825
page update on add data
cyyan88 Jan 1, 2022
1cdb5ed
added data info, error showing data on first load
cyyan88 Jan 3, 2022
6dd77d9
props.match.params not exist
cyyan88 Jan 4, 2022
e7ffe9b
data view for clicking on data titles
cyyan88 Jan 4, 2022
59e490b
update category page on upload
cyyan88 Jan 6, 2022
b1a34ab
data styling
cyyan88 Jan 7, 2022
abcb40e
change to /category, remove console.log
cyyan88 Jan 7, 2022
14fb639
dataId not working
cyyan88 Jan 11, 2022
4580393
data not loading into select
cyyan88 Jan 11, 2022
377c216
treeselect async data loading
cyyan88 Jan 13, 2022
8a1de2a
pull
cyyan88 Jan 17, 2022
44c0eff
merge master
cyyan88 Jan 17, 2022
b6d3a0a
receive data id
cyyan88 Jan 18, 2022
b5ce853
select category data for chart
cyyan88 Jan 23, 2022
14ffff4
load charts correctly, not loading data
cyyan88 Jan 23, 2022
8b7b273
remove dataIds, replace with datadropdown
cyyan88 Jan 31, 2022
da276e9
dropdown and axis input
cyyan88 Feb 8, 2022
ddb68bb
save x & y changes
cyyan88 Feb 10, 2022
5363f29
editmodal bug
cyyan88 Feb 13, 2022
db6f6ee
fix widgetmodal chart showing up
cyyan88 Feb 14, 2022
e030608
axis labels
cyyan88 Feb 22, 2022
054d233
axis selection
cyyan88 Mar 2, 2022
c0c664c
pull origin
cyyan88 Mar 3, 2022
fce5152
pull
cyyan88 Mar 3, 2022
0d036df
add axis to charts
cyyan88 Mar 7, 2022
c379efb
menu highlight bug
cyyan88 Mar 14, 2022
0452624
Column
cyyan88 Mar 19, 2022
171e69e
clean code
cyyan88 Mar 19, 2022
36b9625
Merge branch 'master' of https://github.com/DukeAML/daml-dashboard in…
cyyan88 Apr 12, 2022
56aa4d4
remove axis edits
cyyan88 Apr 12, 2022
2324f6a
axis bugs
cyyan88 Apr 12, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/api/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import axios from 'axios';

const client = axios.create({
baseURL: "https://peagle-backend.herokuapp.com"
//baseURL: "http://localhost:5000"
// baseURL: "http://localhost:5000"
});

const printOutput = true;
Expand Down
1 change: 0 additions & 1 deletion src/components/dashboards/Chart.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { useState } from 'react';
import {widgets, widgetDict} from './Constants';
import EditModal from './EditModal';
import { ResponsiveContainer } from 'recharts';
import './Dashboards.css';
import DraftWidgetModal from './DraftWidgetModal';

Expand Down
23 changes: 12 additions & 11 deletions src/components/dashboards/EditModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import DataDropdown from "../data/DataDropdown";
import { useEffect } from 'react';

const EditModal = props => {

console.log(props)
const [title, setTitle] = useState(props.el.chartTitle);
const [dataProps, setDataProps] = useState(props.el.dataProps || {});
const [dataId, setDataId] = useState(props.el.data);
Expand All @@ -36,7 +36,11 @@ const EditModal = props => {
.then(res => {
const axes = Object.keys(res.file_data[0]);
const newData = { data: res.file_data };
axes.forEach(axis => newData[axis] = axis);
//axis needs to be selectable by user..
newData['dataTitle'] = res.title;
//axes.forEach(axis => newData[axis] = axis);
newData['x'] = (axes.length > 0) ? axes[0] : 'x';
newData['y'] = (axes.length > 1) ? axes[1] : 'y';
setDataProps(newData)
setDataId(e)
})
Expand Down Expand Up @@ -74,6 +78,8 @@ const EditModal = props => {
const selectedWidget = widgetDict[props.el.widgetType];
const WidgetRender = selectedWidget || <div />;

const singleAxis = ['Bubble chart', 'Simple pie chart', 'Active shape pie chart', 'Simple radial bar chart', 'Tree map']
const axisMap = singleAxis.includes(props.el.widgetType) ? ['y'] : ['x', 'y']
const headers = ['h1', 'h2', 'h3']
const axesConfig =
headers.length !== 0 ? (
Expand All @@ -83,10 +89,10 @@ const EditModal = props => {
</div>
<div style={{ margin: "1rem" }}>
<Row gutter={48}>
{["x", "y"].map((axis, index) => (
{axisMap.map((axis, index) => (
<React.Fragment key={index}>
<Col span={4} key={index}>
{axis}-axis
{singleAxis.includes(props.el.widgetType) ? 'Column': `${axis}-axis`}
<br />
<Dropdown
overlay={
Expand All @@ -100,7 +106,7 @@ const EditModal = props => {
}
>
<Button>
{dataProps[axis]}
{dataProps[axis]? dataProps[axis]: axis}
<DownOutlined />
</Button>
</Dropdown>
Expand Down Expand Up @@ -138,7 +144,7 @@ const EditModal = props => {
<div>
Select data
</div>
<DataDropdown onSelectData={updateDataProps} currentData={props.el.dataProps ? props.el.dataProps.dataTitle: null}/>
<DataDropdown onSelectData={updateDataProps} currentData={dataProps ? dataProps.dataTitle: null}/>
{axesConfig}
</Col>
{
Expand All @@ -156,11 +162,6 @@ const EditModal = props => {
</Col>
}






</Modal>

)
Expand Down
2 changes: 1 addition & 1 deletion src/components/layout/SideBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const SideBar = props => {
>
{
context.categories.map(cat => {
return <Menu.Item key={cat._id} className="menu-item" onClick={changeCategoryPage} style={subStyles}>{cat.name}</Menu.Item>
return <Menu.Item key={cat._id} className="menu-item" onClick={changeCategoryPage} style={subStyles} >{cat.name}</Menu.Item>
})
}
<CategoryModal style={subStyles}/>
Expand Down
68 changes: 12 additions & 56 deletions src/components/widgetSelection/WidgetDataEntry.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,56 +16,25 @@ class WidgetDataEntry extends React.PureComponent {
}
state = {
selected: "",
fileList: [],
processedFile: { contents: "", headers: [] },
axes: {},
chartTitle: "",
rerenderWidget: false,
dataId: ""
dataId: "",
title: ""
};

static contextType = Context;

handleFileChange = info => {
this.setState({
fileList: info.fileList.slice(-1) // only allow upload of one file
});
};

// Adding file from file explorer
onFileChange({ file, onSuccess }) {
const reader = new FileReader();
reader.onload = () => {
const workBook = reader.result;
const wb = XLSX.read(workBook, { type: "binary" });
const wsname = wb.SheetNames[0];
const ws = wb.Sheets[wsname];
const jsonContentData = wb.SheetNames.reduce((initial, name) => {
// Gets all data
// ex. initial[name] = [{x: 1, y: 10, __rowNum__: 1}, {x: 2, y: 1, __rowNum__: 2}, ...]
initial[name] = XLSX.utils.sheet_to_json(ws, { defval: null });
return initial;
}, {});

// Only gets data for first workbook for now
const content = Object.values(jsonContentData)[0];
this.processData(content)

// Mark file finished reading
onSuccess("Done", file);
}
reader.readAsBinaryString(file);
}

processData = content => {
processData = (content, title) => {
// Only gets headers for first workbook for now (we can get headers simply from the content at any time)
let headers = Object.keys(content[0]);
this.setState({
processedFile: { content, headers },
axes: { x: headers[0], y: headers[1] || headers[0] },
chartTitle: ""
});
const dataProps = { data: content, ...this.state.axes, id: this.state.dataId };
const dataProps = { data: content, ...this.state.axes, id: this.state.dataId, dataTitle: title };
this.props.onReceiveDataProps(dataProps);
}

Expand All @@ -75,7 +44,7 @@ class WidgetDataEntry extends React.PureComponent {
.then(res => {
this.setId(id)
const content = Object.values(res.file_data);
this.processData(content)
this.processData(content, res.title);
});
}

Expand All @@ -91,6 +60,7 @@ class WidgetDataEntry extends React.PureComponent {
this.setState({ axes: { ...this.state.axes, [axis]: headers[key] } }, () => {
this.props.onReceiveDataProps({ data: content, ...this.state.axes, id: this.state.dataId });
});

};

handleChartTitleChange = e => {
Expand All @@ -110,6 +80,8 @@ class WidgetDataEntry extends React.PureComponent {
<Menu.Item key={index}>{header}</Menu.Item>
));

const singleAxis = ['Bubble chart', 'Simple pie chart', 'Active shape pie chart', 'Simple radial bar chart', 'Tree map']
const axisMap = singleAxis.includes(this.props.widget) ? ['y'] : ['x', 'y']
const axesConfig =
headers.length !== 0 ? (
<React.Fragment>
Expand All @@ -118,10 +90,10 @@ class WidgetDataEntry extends React.PureComponent {
</div>
<div style={{ margin: "1rem" }}>
<Row gutter={48}>
{["x", "y"].map((axis, index) => (
{axisMap.map((axis, index) => (
<React.Fragment key={index}>
<Col span={4} key={index}>
{axis}-axis
{singleAxis.includes(this.props.widget) ? 'Column': `${axis}-axis`}
<br />
<Dropdown
overlay={
Expand Down Expand Up @@ -164,7 +136,6 @@ class WidgetDataEntry extends React.PureComponent {


const dataProps = content ? { data: content, ...this.state.axes } : {};
console.log(dataProps)

return (
<div>
Expand All @@ -178,26 +149,11 @@ class WidgetDataEntry extends React.PureComponent {
<Col style={{ height: "20rem" }} span={24}>
<WidgetRender setTitle={this.props.setTitle} updateChart={this.props.updateChart} {...dataProps} {...(selectedWidget.value === "Text Box" ? { el: { chartTitle: this.props.title } } : {})} />
</Col>
{this.props.widget !== "Text Box" && <div><Col span={24}>
<div className="widget-header"> Upload your .XLSX or your .CSV file here.</div>
{this.props.widget !== "Text Box" && <div style={{width: '100%'}}><Col span={24}>
<div className="widget-header"> Select data for your chart.</div>

<DataDropdown onSelectData={this.onSelectData}/>

<div style={{ margin: "1rem" }}>
<Upload
accept=".csv, .xlsx"
multiple={false}
name="file"
fileList={this.state.fileList}
action="memory"
customRequest={this.onFileChange.bind(this)}
onChange={this.handleFileChange}
>
<Button>
<UploadOutlined /> Upload Data
</Button>
</Upload>
</div>
</Col>
<Col span={24}>{axesConfig}</Col>
<Col span={24}>{inputTitle}</Col>
Expand Down
7 changes: 4 additions & 3 deletions src/components/widgets/DashedLineChart.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ class SimpleLineChart extends React.Component {

return (
<ResponsiveContainer width="100%" height="100%">
<LineChart data={this.props.data || data}>
<XAxis dataKey={this.props.x || "name"} />
<YAxis />
<LineChart data={this.props.data || data}
margin={{top: 5, right: 5, bottom: 35, left: 15 }}>
<XAxis dataKey={this.props.x || "name"} label={{ value: `${this.props.x || "name"}`, position: 'bottom', offset:25}} />
<YAxis label={{ value: `${this.props.y || "name"}`, angle: -90, position: 'left'}} />
<CartesianGrid strokeDasharray="3 3" />
<Tooltip />
<Legend />
Expand Down
12 changes: 5 additions & 7 deletions src/components/widgets/JointLineScatterChart.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,17 @@ export default class Example extends PureComponent {
<ScatterChart
width={500}
height={400}
margin={{
top: 20, right: 20, bottom: 20, left: 20,
}}
margin={{top: 5, right: 5, bottom: 35, left: 15 }}
>
<CartesianGrid />
<XAxis dataKey={this.props.x || "x"}
type="number"
name={this.props.xName || "stature"}
unit={this.props.xUnit || "cm"} />
label={{ value: `${this.props.x || "name"}`, position: 'bottom', offset:25}}
/>
<YAxis dataKey={this.props.y || "y"}
type="number"
name={this.props.yName || "weight"}
unit={this.props.yUnit || "kg"} />
label={{ value: `${this.props.y || "name"}`, angle: -90, position: 'left'}}
/>
<ZAxis type="number" range={[100]} />
<Tooltip cursor={{ strokeDasharray: '3 3' }} />
<Legend />
Expand Down
5 changes: 3 additions & 2 deletions src/components/widgets/PosAndNegBarChart.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ export default class PosAndNegBarChart extends PureComponent {
<ResponsiveContainer width="100%" height="100%">
<BarChart
data={this.props.data || data}
margin={{top: 5, right: 5, bottom: 35, left: 15 }}
>
<CartesianGrid strokeDasharray="3 3" />
<XAxis dataKey={this.props.x || "name"} />
<YAxis />
<XAxis dataKey={this.props.x || "name"} label={{ value: `${this.props.x || "name"}`, position: 'bottom', offset:25}} />
<YAxis label={{ value: `${this.props.y || "name"}`, angle: -90, position: 'left'}} />
<Tooltip />
<Legend />
<ReferenceLine y={0} stroke="#000" />
Expand Down
7 changes: 4 additions & 3 deletions src/components/widgets/SimpleAreaChart.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ class SimpleAreaChart extends React.Component {

return (
<ResponsiveContainer width="100%" height="100%">
<AreaChart data={this.props.data || data}>
<AreaChart data={this.props.data || data}
margin={{top: 5, right: 5, bottom: 35, left: 15 }} >
<CartesianGrid strokeDasharray="3 3" />
<XAxis dataKey={this.props.x || "name"} />
<YAxis />
<XAxis dataKey={this.props.x || "name"} label={{ value: `${this.props.x || "name"}`, position: 'bottom', offset:25}} />
<YAxis label={{ value: `${this.props.y || "name"}`, angle: -90, position: 'left'}} />
<Tooltip />
<Area
type="monotone"
Expand Down
6 changes: 3 additions & 3 deletions src/components/widgets/SimpleBarChart.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ class SimpleBarChart extends React.Component {
<ResponsiveContainer width="100%" height="100%">
<BarChart
data={this.props.data || data}
margin={{top: 5, right: 5, bottom: 5, left: -5 }}
margin={{top: 5, right: 5, bottom: 35, left: 15 }}
>
<CartesianGrid strokeDasharray="3 3" />
<XAxis dataKey={this.props.x || "name"} />
<YAxis />
<XAxis dataKey={this.props.x || "name"} label={{ value: `${this.props.x || "name"}`, position: 'bottom', offset:25}} />
<YAxis label={{ value: `${this.props.y || "name"}`, angle: -90, position: 'left'}} />
<Tooltip />
<Legend />
<Bar dataKey={this.props.y || "pv"} fill={primary} />
Expand Down
10 changes: 6 additions & 4 deletions src/components/widgets/SimpleLineChart.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,22 @@ const data = [
];

class SimpleLineChart extends React.Component {


static contextType = Context;

render() {
const { context } = this.context;
const { secondary } = context;

return (
<ResponsiveContainer width="100%" height="100%">
<LineChart
data={this.props.data || data}
margin={{top: 5, right: 5, bottom: 5, left: -5 }}
margin={{top: 5, right: 5, bottom: 35, left: 15 }}
>
<XAxis dataKey={this.props.x || "name"} />
<YAxis />
<XAxis dataKey={this.props.x || "name"} label={{ value: `${this.props.x || "name"}`, position: 'bottom', offset:25}} />
<YAxis label={{ value: `${this.props.y || "name"}`, angle: -90, position: 'left'}} />
<CartesianGrid strokeDasharray="3 3" />
<Tooltip />
<Legend />
Expand Down
4 changes: 3 additions & 1 deletion src/components/widgets/SimplePieChart.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { PieChart, Pie, Cell, ResponsiveContainer } from "recharts";
import { PieChart, Pie, Cell, ResponsiveContainer, Legend } from "recharts";
import { Context } from "../../context/Context";

const data = [
Expand Down Expand Up @@ -46,6 +46,7 @@ class SimplePieChart extends React.Component {
return (
<ResponsiveContainer width="100%" height="100%">
<PieChart>
<Legend verticalAlign="top" height={36}/>
<Pie
data={this.props.data || data}
labelLine={false}
Expand All @@ -60,6 +61,7 @@ class SimplePieChart extends React.Component {
/>
))}
</Pie>

</PieChart>
</ResponsiveContainer>
);
Expand Down
4 changes: 3 additions & 1 deletion src/components/widgets/SimpleRadialBarChart.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { PureComponent } from 'react';
import { RadialBarChart, RadialBar, ResponsiveContainer } from 'recharts';
import { RadialBarChart, RadialBar, ResponsiveContainer, Legend } from 'recharts';
import { Context } from "../../context/Context";

const data = [
Expand Down Expand Up @@ -30,7 +30,9 @@ export default class SimpleRadialBarChart extends PureComponent {
return (
<ResponsiveContainer width="100%" height="100%">
<RadialBarChart data={this.props.data || data}>
{/* <Legend verticalAlign="top" height={36}/> */}
<RadialBar minAngle={15} label={{ position: 'insideStart', fill: '#fff' }} background clockWise dataKey={this.props.x || "uv"} fill={primary} />
{/* <RadialBar minAngle={15} label={{ position: 'insideStart', fill: '#fff' }} background clockWise dataKey={this.props.x || "uv"} /> */}
</RadialBarChart>
</ResponsiveContainer>
);
Expand Down
Loading