Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create visualization graph #1011

Merged
merged 57 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
164d7f9
add a blank
YukaUU Jun 10, 2024
fe4eee4
Merge branch 'yukaUU_GSoC_db_Mark_add_centerPosition_and_Zoom' into y…
YukaUU Jun 13, 2024
a2d41a9
Add log at Toolbar and logAnnotation callback
YukaUU Jun 16, 2024
fc7ba17
add log side menu
YukaUU Jun 30, 2024
91c0996
Added opening/closing of side menu/ header
YukaUU Jul 2, 2024
c2e0231
add log annotation icon
YukaUU Jul 3, 2024
d9b78d5
draft pull request
YukaUU Jul 6, 2024
a1f8279
add sideMenu on right
YukaUU Jul 6, 2024
08ed4f3
add collapsiblelist in Log Panel
YukaUU Jul 6, 2024
a154cbb
add collapsible list on right side menu
YukaUU Jul 7, 2024
50f70a0
add collapsiblelist in Log Panel
YukaUU Jul 7, 2024
78026e7
add layers on log panel using $UI.layers,$UI.layers.list
YukaUU Jul 8, 2024
71c3d13
add original component
YukaUU Jul 9, 2024
0fd78db
logの情報を取り出す
YukaUU Jul 13, 2024
144f139
change function fetchMark : logAnnotaiton
YukaUU Jul 13, 2024
20038b6
add loadingLog function
YukaUU Jul 13, 2024
4013f34
add visualizationLayerItems in dataloader
YukaUU Jul 14, 2024
3d8ef72
create graph in log panel
YukaUU Jul 15, 2024
7ff366e
add data calculate
YukaUU Jul 15, 2024
c05437c
create graph
YukaUU Jul 15, 2024
431550c
fix from log to visualization in subtool
YukaUU Jul 15, 2024
3b0f51b
fix id: 'visualization_panel'
YukaUU Jul 15, 2024
1d78faa
fix:visualizationSideMenu
YukaUU Jul 15, 2024
15e43e1
fix id and $UI.visualizationList (CollapsibleList )
YukaUU Jul 15, 2024
7ef73f6
fix visualizationlist
YukaUU Jul 15, 2024
84650dc
fix side menu size
YukaUU Jul 15, 2024
bc73fef
fix titleVisualization
YukaUU Jul 15, 2024
3c71ed3
fix createVisualizationViewer
YukaUU Jul 15, 2024
d919cb8
fix VisualizationViewer (is logsViewer instance)
YukaUU Jul 15, 2024
ffd169a
fix $UI.visualizatiomViewer
YukaUU Jul 15, 2024
48b84a8
fix id overvisuzalization
YukaUU Jul 15, 2024
302db07
fix css , js pass
YukaUU Jul 15, 2024
da45fb2
delete addHumanItem in visualizationviewer.js
YukaUU Jul 15, 2024
be6e49d
fix comment
YukaUU Jul 15, 2024
2bc6ec9
add comment
YukaUU Jul 15, 2024
4d9c558
delete console.log
YukaUU Jul 15, 2024
9b9f79e
fix dataloader and $D
YukaUU Jul 15, 2024
ced2289
add comment
YukaUU Jul 15, 2024
5d0604c
fix comments
YukaUU Jul 16, 2024
88d1846
delete graph in info page
YukaUU Jul 16, 2024
10a8801
change name from states to viewerStates
YukaUU Jul 18, 2024
29e4a08
fix
YukaUU Jul 18, 2024
67c0196
add zooming in each annotation at Multi mode
YukaUU Jul 18, 2024
467755e
ad zoom data each annotation
YukaUU Jul 18, 2024
7204c13
add viewerStates in each annotation at multi mode
YukaUU Jul 18, 2024
277397e
add viewerStates in each annotation at multi mode
YukaUU Jul 18, 2024
17e6f80
fix Multi mode on the pencil tool seems to save all annotations
YukaUU Jul 18, 2024
037c693
fix error This line has a length of 148. Maximum allowed is 125
YukaUU Jul 18, 2024
27c7fd3
delete viewerStates ( previuos commit :added viewerStates each annota…
YukaUU Jul 18, 2024
e748f61
fix visualization panel using $D.visualizations.geometries.features
YukaUU Jul 18, 2024
a093930
fix small bug
YukaUU Jul 18, 2024
4e6f480
remove viewerStates:image
YukaUU Jul 18, 2024
0076c4d
fix point viewerStates
YukaUU Jul 19, 2024
591a265
fix small bug
YukaUU Jul 20, 2024
eb64052
Remove unused code from viewer.html
YukaUU Jul 20, 2024
179d08a
delete unused code
YukaUU Jul 20, 2024
01ffbd9
fix comment in visualizationviewer
YukaUU Jul 22, 2024
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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ The toolbar is in the top-left of the main content window. Use the toolbar butto
| ![](https://fonts.gstatic.com/s/i/materialicons/bug_report/v4/24px.svg) | Bug Report | Report a bug or give feedback. |
| ![](https://fonts.gstatic.com/s/i/materialicons/camera_enhance/v4/24px.svg) | Slide Capture | Click to take a screenshot of the slide and annotations on it. |
| ![](https://fonts.gstatic.com/s/i/materialicons/help/v4/24px.svg) | Tutorial | Click to view a guided tour of the viewer tools. |

| ![](https://fonts.gstatic.com/s/i/materialicons/auto_graph/v4/24px.svg) | Visualization | Click to view visualizations of annotations. |

## Toolbar Shortcuts

Expand Down
17 changes: 14 additions & 3 deletions apps/viewer/dataloaders.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,26 @@ function layersLoader() {
console.error(error);
});
}

// visualization
function visualization() {
$CAMIC.store.findMark($D.params.slideId).then(function(layers) {
$D.visualizations = [...layers.map(covertToVisualization)];
visualizationLayerItems($D.visualizations);
}).catch(function(error) {
$UI.message.addError('Loading visualizations is Error');
console.error(error);
});
}

var checkCoreIsReady = setInterval(function() {
if ($UI.layersViewer && $UI.layersViewerMinor) {
if ($UI.layersViewer && $UI.layersViewerMinor && $UI.visualizationViewer) {
clearInterval(checkCoreIsReady);
loadingHumanOverlayers();
loadingRulerOverlayers();
loadingHeatmapOverlayers();
loadingComputerOverlayers();
visualization();
}
}, 500);
}


158 changes: 145 additions & 13 deletions apps/viewer/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ function initialize() {
}
}, 100);
}

// setting core functionalities
function initCore() {
// start initial
Expand Down Expand Up @@ -223,7 +222,6 @@ function initCore() {
// for support QUIP 2.0
const data = Array.isArray(e.data) ? e.data[e.data.selected] : e.data;
const type = data.provenance.analysis.source;

let body;
let attributes;
let warning = null;
Expand Down Expand Up @@ -260,16 +258,17 @@ function initCore() {


// add center position and zoom
if (data.states != undefined) {
// Rounds a number to the specified number of decimal places.
function roundTo(num, decimalPlaces) {
const factor = 10 ** decimalPlaces;
return Math.round(num * factor) / factor;
}
if (data.geometries.features[data.selected].viewerStates != null ||
data.geometries.features[data.selected].viewerStates != undefined) {
const decimalPlaces = 3;
attributes.X = data.states.x,
attributes.Y = data.states.y,
attributes.zoom = roundTo(data.states.zoom, decimalPlaces);
attributes.X = data.geometries.features[data.selected].viewerStates.x,
attributes.Y = data.geometries.features[data.selected].viewerStates.y,
attributes.zoom = roundTo(data.geometries.features[data.selected].viewerStates.z, decimalPlaces);
}
// Rounds a number to the specified number of decimal places.
function roundTo(num, decimalPlaces) {
const factor = 10 ** decimalPlaces;
return Math.round(num * factor) / factor;
}


Expand Down Expand Up @@ -668,6 +667,17 @@ async function initUIcomponents() {
value: 'slCap',
callback: captureSlide,
});

// visualization panel
subToolsOpt.push({
name: 'visualization',
icon: 'auto_graph', // material icons' name
title: 'visualization',
value: 'visualization',
type: 'btn',
callback: visualization,
});

subToolsOpt.push({
name: 'tutorial',
icon: 'help',
Expand Down Expand Up @@ -741,6 +751,15 @@ async function initUIcomponents() {
$UI.layersSideMenu.addContent(loading);
// TODO add layer viewer

$UI.visualizationSideMenu = new SideMenu({
id: 'visualization_panel',
width: 250,
contentPadding: 5,
position: 'right',
height: '45vh',
// , isOpen:true
callback: toggleSideMenu,
});

/* annotation popup */
$UI.annotPopup = new PopupPanel({
Expand Down Expand Up @@ -850,7 +869,6 @@ async function initUIcomponents() {
// const minorViewerData = $D.overlayers.map((d) => {
// return {item: d, isShow: false};
// });

$UI.AssistantViewer = new Assistant({
id: 'ml_assistant',
viewer: $CAMIC.viewer,
Expand Down Expand Up @@ -882,6 +900,21 @@ async function initUIcomponents() {
rootCallback.bind('minor'),
);

$UI.visualizationViewer = createVisualizationViewer(
'overvisuzalization',
null,
callback.bind('main'),
rootCallback.bind('main'),
);

// // create UI and set data - minor
// $UI.visualizationViewerMinor = createVisualizationViewer(
// 'overvisuzalizationMinor',
// null,
// callback.bind('minor'),
// rootCallback.bind('minor'),
// );

// TODO move to add layers
// if ($D.params.states && $D.params.states.l) {
// $D.params.states.l.forEach((id) =>
Expand All @@ -908,13 +941,43 @@ async function initUIcomponents() {
// console.log(e);
},
});

$UI.visualizationList = new CollapsibleList({
id: 'visualizationlist',
list: [
{
id: 'visualizationlist',
title: 'Human:Draw Annotation',
content: 'No Template Loaded', // $UI.annotOptPanel.elt
// isExpand:true
},
// {
// id: 'heatMap',
// title: 'HeatMap',
// content: 'No Template Loaded', // $UI.algOptPanel.elt,
// },
],
changeCallBack: function(e) {
// console.log(e);
},
});
$UI.layersSideMenu.clearContent();
// add to layers side menu
const title = document.createElement('div');
title.classList.add('item_head');
title.textContent = 'Layers Manager';

$UI.layersSideMenu.addContent(title);
// add to log side menu
const titleVisualization = document.createElement('div');
titleVisualization.classList.add('item_head');
titleVisualization.textContent = 'Visualization Panel';
// add CSS
titleVisualization.style.color = '#365f9c';
titleVisualization.style.fontSize = '20px';
titleVisualization.style.backgroundColor = 'rgba(220, 220, 220, 1)';
titleVisualization.style.marginTop = '28px';

$UI.visualizationSideMenu.addContent(titleVisualization);

// loading status
$UI.loadStatus = document.createElement('div');
Expand Down Expand Up @@ -954,6 +1017,17 @@ async function initUIcomponents() {
$UI.layersList.elt.parentNode.removeChild($UI.layersList.elt);
closeMinorControlPanel();
$UI.layersSideMenu.addContent($UI.layersList.elt);

// visualization
$UI.visualizationList.clearContent('visualizationlist');
$UI.visualizationList.addContent('visualizationlist', $UI.visualizationViewer.elt);
// TODO Heatmap
// $UI.visualizationList.clearContent('heatMap');
// $UI.visualizationList.addContent('heatMap', $UI.visualizationViewerMinor.elt);

$UI.visualizationList.elt.parentNode.removeChild($UI.visualizationList.elt);
closeMinorControlPanel();
$UI.visualizationSideMenu.addContent($UI.visualizationList.elt);
}
}, 300);

Expand Down Expand Up @@ -1320,6 +1394,18 @@ function createLayerViewer(id, viewerData, callback, rootCallback) {
return layersViewer;
}

function createVisualizationViewer(id, viewerData, callback, rootCallback) {
const visualizationViewer = new VisualizationViewer({
id: id,
data: viewerData,
removeCallback: removeCallback,
locationCallback: locationCallback,
callback: callback,
rootCallback: rootCallback,
});
visualizationViewer.elt.parentNode.removeChild(visualizationViewer.elt);
return visualizationViewer;
}
// create lay panel for side-by-side control
function createLayPanelControl() {
$UI.layCtrlbar = document.createElement('div');
Expand Down Expand Up @@ -1479,6 +1565,7 @@ function addHumanLayerItems() {

$UI.layersViewerMinor.addHumanItems(minorViewerItems);
}

function openLoadStatus(text) {
const txt = $UI.loadStatus.querySelector('.text');
txt.textContent = `Loading ${text}`;
Expand Down Expand Up @@ -1523,6 +1610,51 @@ function addHeatmapLayerItems(data) {
$UI.layersViewerMinor.addItems(minorViewerData, 'heatmap');
}

function visualizationLayerItems(data) {
var initialZommingData = [];

// Get initial data
$D.visualizations.map((d) => {
d.geometries.features.map((ditailData)=>{
if (ditailData.viewerStates) {
initialZommingData.push(roundToSecondDecimalPlace(ditailData.viewerStates.z));
}
});
});
let result = countOccurrences(initialZommingData);

$UI.visualizationViewer.visualization('myChart', result);
}

// Function to round to decimal places
function roundToSecondDecimalPlace(num) {
return Math.round(num * 100) / 100;
}

function countOccurrences(arr) {
// Create objects for counting
let countMap = {};

// Count each element in the array
arr.forEach(function(value) {
if (countMap[value] === undefined) {
countMap[value] = 1;
} else {
countMap[value]++;
}
});

// Convert the result to a 2-dimensional array
let result = [];
for (let key in countMap) {
if (countMap.hasOwnProperty(key)) {
result.push([parseFloat(key), countMap[key]]);
}
};

return result;
}

// const mainViewerData = $D.overlayers.map((d) => {
// const isShow =
// $D.params.states &&
Expand Down
23 changes: 17 additions & 6 deletions apps/viewer/uicallbacks.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,9 @@ function toolsOff() {
case 'download_selection':
downloadSelectionOff();
break;
case 'log':
$UI.visualizationSideMenu.close();
break;
}
}

Expand Down Expand Up @@ -892,7 +895,7 @@ function annoCallback(data) {
noteData.notes = resultString;

// get center position and zoom
let states = StatesHelper.getCurrentStates(true);
let viewerStates = StatesHelper.getCurrentStates(true);

// save
// provenance
Expand All @@ -919,11 +922,6 @@ function annoCallback(data) {
$CAMIC.viewer,
$CAMIC.viewer.canvasDrawInstance.getImageFeatureCollection(),
),
states: {
x: states.x,
y: states.y,
zoom: states.z,
},
};

// save annotation
Expand Down Expand Up @@ -2736,6 +2734,19 @@ async function captureSlide() {
$UI.layersSideMenu.close();
}

/* Log annotaiton */
let isSidemenuOpen = true;

function visualization() {
if (isSidemenuOpen == true) {
$UI.visualizationSideMenu.open();
isSidemenuOpen = false;
} else {
$UI.visualizationSideMenu.close();
isSidemenuOpen = true;
};
}

function downloadSlideCapture(combiningCanvas) {
const imageData = combiningCanvas.toDataURL('image/jpeg');
const downloadLink = document.createElement('a');
Expand Down
Loading
Loading