Skip to content

Commit e792424

Browse files
committed
Made a way better graph
1 parent addd2bf commit e792424

File tree

4 files changed

+33
-9
lines changed

4 files changed

+33
-9
lines changed

package.json

+4
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"watch": "lerna run watch"
5050
},
5151
"devDependencies": {
52+
"@types/react-plotly.js": "^2.6.3",
5253
"@typescript-eslint/eslint-plugin": "~5.55.0",
5354
"@typescript-eslint/parser": "~5.55.0",
5455
"eslint": "~8.36.0",
@@ -65,5 +66,8 @@
6566
"stylelint-prettier": "^3.0.0",
6667
"typedoc": "~0.23.28",
6768
"typescript": "~5.0.4"
69+
},
70+
"dependencies": {
71+
"react-plotly.js": "^2.6.0"
6872
}
6973
}

packages/collaboration/src/activeusersdisplay.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class ActiveUsersDisplay extends Widget {
66
constructor(cell: Cell) {
77
super();
88

9-
this.addClass('active-users-display');
9+
this.addClass('jp-active-users-display');
1010

1111
this.updateContent(cell);
1212
}
@@ -25,7 +25,7 @@ class ActiveUsersDisplay extends Widget {
2525

2626
export function addDisplay(cell: Cell) {
2727

28-
const display = cell.node.getElementsByClassName('active-users-display')[0];
28+
const display = cell.node.getElementsByClassName('jp-active-users-display')[0];
2929
const activeUsersDisplay = new ActiveUsersDisplay(cell);
3030

3131

packages/collaboration/src/activitydisplay.tsx

+18-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as React from 'react';
22
import { ReactWidget } from '@jupyterlab/apputils';
33
import { INotebookTracker, Notebook, NotebookPanel } from '@jupyterlab/notebook';
4+
import Plot from 'react-plotly.js';
45

56
export class ActivityDisplay extends ReactWidget {
67

@@ -68,11 +69,22 @@ const ActivityDisplayComponent: React.FC<ActivityDisplayComponentProps> = ({trac
6869
}
6970

7071
}, [tracker]);
71-
72-
const graph = state.map((count, index) => (
73-
<div key={index} style={{height: '8px', width: count*5, backgroundColor: 'green', margin: '2px'}}/>
74-
))
75-
76-
return <div>{graph}</div>;
72+
73+
const data = [{
74+
y: state.map((_, index) => index + 1),
75+
x: state,
76+
type: 'bar',
77+
orientation: 'h',
78+
marker: {color: 'green'}
79+
}] as Plotly.Data[];
80+
81+
const layout = {
82+
width: 300,
83+
height: 500,
84+
xaxis: {title: 'Active users'},
85+
yaxis: {title: 'Cell', autorange: 'reversed' as const}
86+
};
87+
88+
return <Plot className='jp-graph' data={data} layout={layout}/>
7789

7890
}

packages/collaboration/style/sidepanel.css

+9-1
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,14 @@
334334
/************************************************************
335335
Activity tracking
336336
*************************************************************/
337-
.active-users-display {
337+
.jp-active-users-display {
338338
padding-left: 75px;
339+
}
340+
341+
.jp-graph {
342+
display: flex;
343+
flex-direction: column;
344+
overflow-y: auto;
345+
margin-top: 3px;
346+
margin-left: 3px;
339347
}

0 commit comments

Comments
 (0)