Skip to content

Commit

Permalink
Added download pdf icon, fixed compare in barchart, removed preserve …
Browse files Browse the repository at this point in the history
…checkbox and added delete bt
  • Loading branch information
airenzp authored and xzhou82 committed Jul 30, 2024
1 parent fd2e822 commit 51e4255
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 56 deletions.
12 changes: 12 additions & 0 deletions client/dom/control.icons.js
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,7 @@ export const icons = {
</svg>`
elem.attr('title', opts.title)
elem.html(svg).style('cursor', 'pointer')
if (opts.handler) elem.on('click', opts.handler)
},
table: (elem, opts = {}) => {
const _opts = { color: 'black', width: 18, height: 18, transform: '' }
Expand All @@ -534,5 +535,16 @@ export const icons = {
</svg>`
elem.attr('title', opts.title)
elem.html(svg).style('cursor', 'pointer')
if (opts.handler) elem.on('click', opts.handler)
},
pdf: (elem, opts = {}) => {
const _opts = { color: 'black', width: 18, height: 18, transform: '' }
Object.assign(_opts, opts)
const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${_opts.width}" height="${_opts.height}" fill="${_opts.color}" class="bi bi-copy" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M14 4.5V14a2 2 0 0 1-2 2h-1v-1h1a1 1 0 0 0 1-1V4.5h-2A1.5 1.5 0 0 1 9.5 3V1H4a1 1 0 0 0-1 1v9H2V2a2 2 0 0 1 2-2h5.5zM1.6 11.85H0v3.999h.791v-1.342h.803q.43 0 .732-.173.305-.175.463-.474a1.4 1.4 0 0 0 .161-.677q0-.375-.158-.677a1.2 1.2 0 0 0-.46-.477q-.3-.18-.732-.179m.545 1.333a.8.8 0 0 1-.085.38.57.57 0 0 1-.238.241.8.8 0 0 1-.375.082H.788V12.48h.66q.327 0 .512.181.185.183.185.522m1.217-1.333v3.999h1.46q.602 0 .998-.237a1.45 1.45 0 0 0 .595-.689q.196-.45.196-1.084 0-.63-.196-1.075a1.43 1.43 0 0 0-.589-.68q-.396-.234-1.005-.234zm.791.645h.563q.371 0 .609.152a.9.9 0 0 1 .354.454q.118.302.118.753a2.3 2.3 0 0 1-.068.592 1.1 1.1 0 0 1-.196.422.8.8 0 0 1-.334.252 1.3 1.3 0 0 1-.483.082h-.563zm3.743 1.763v1.591h-.79V11.85h2.548v.653H7.896v1.117h1.606v.638z"/>
</svg>`
elem.attr('title', opts.title)
elem.html(svg).style('cursor', 'pointer')
if (opts.handler) elem.on('click', opts.handler)
}
}
9 changes: 2 additions & 7 deletions client/plots/profileBarchart.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,14 +291,9 @@ class profileBarchart extends profilePlot {
export async function getPlotConfig(opts, app) {
try {
const defaults = app.vocabApi.termdbConfig?.chartConfigByType?.profileBarchart
if (!defaults) throw 'default config not found in termdbConfig.chartConfigByType.profileBarchart'
defaults.settings = { profileBarchart: getDefaultProfilePlotSettings() }
const config = copyMerge(structuredClone(defaults), opts)
const settings = getDefaultProfilePlotSettings()

config.settings = {
profileBarchart: settings,
controls: { isOpen: false }
}
config.settings.controls = { isOpen: false }
const twlst = []
for (const component of config.plotByComponent) {
component.hasSubjectiveData = false
Expand Down
10 changes: 7 additions & 3 deletions client/plots/profilePlot.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,12 @@ export class profilePlot {

this.tip = new Menu({ padding: '4px', offsetX: 10, offsetY: 15 })
document.addEventListener('scroll', event => this?.tip?.hide())

icon_functions['pdf'](iconsDiv.append('div').style('padding', '0px 5px 15px 5px'), {
title: 'Clear filters',
handler: () => {
window.print()
}
})
if (this.type != 'profileRadarFacility' && !config.settings[this.type].comparison) {
//Facility radar plot does not need to compare
const compareIconDiv = iconsDiv.append('div').style('margin-bottom', '20px')
Expand Down Expand Up @@ -323,8 +328,7 @@ export class profilePlot {
})
}
this.components.controls.on(`downloadClick.${chartType}`, () =>
//downloadSingleSVG(this.svg, this.getDownloadFilename(), this.dom.holder.node())
window.print()
downloadSingleSVG(this.svg, this.getDownloadFilename(), this.dom.holder.node())
)
this.components.controls.on(`helpClick.${chartType}`, () => {
let link
Expand Down
60 changes: 14 additions & 46 deletions client/src/profileHome.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ async function loadDataset(headerHolder, dslabel) {
const app = await _.appInit(opts)

addButtons(headerHolder, app, dslabel, isLoggedIn, site)
launchPlot(app, 'profilePolar', 'Polar Graph', false, isLoggedIn, site)
launchPlot(app, 'profilePolar', 'Polar Graph', isLoggedIn, site)
}

function addButtons(headerHolder, app, dslabel, isLoggedIn, site) {
Expand All @@ -94,70 +94,39 @@ function addButtons(headerHolder, app, dslabel, isLoggedIn, site) {
div
.append('button')
.text('Polar Graph')
.on('click', e => launchPlot(app, 'profilePolar', 'Polar Graph', preserveCheckbox.node().checked, isLoggedIn, site))
.on('click', e => launchPlot(app, 'profilePolar', 'Polar Graph', isLoggedIn, site))
div
.append('button')
.text('Bar Graph')
.on('click', e =>
launchPlot(app, 'profileBarchart', 'Bar Graph', preserveCheckbox.node().checked, isLoggedIn, site)
)
.on('click', e => launchPlot(app, 'profileBarchart', 'Bar Graph', isLoggedIn, site))
if (isLoggedIn)
div
.append('button')
.text('Radar Graph 1')
.on('click', e =>
launchRadarPlot(
app,
'profileRadarFacility',
'Radar Graph 1',
'plot1',
preserveCheckbox.node().checked,
isLoggedIn,
site
)
)
.on('click', e => launchRadarPlot(app, 'profileRadarFacility', 'Radar Graph 1', 'plot1', isLoggedIn, site))
if (isLoggedIn)
div
.append('button')
.text('Radar Graph 2')
.on('click', e =>
launchRadarPlot(
app,
'profileRadar',
'Radar Graph 2',
'plot1',
preserveCheckbox.node().checked,
isLoggedIn,
site
)
)
.on('click', e => launchRadarPlot(app, 'profileRadar', 'Radar Graph 2', 'plot1', isLoggedIn, site))
if (dslabel == 'ProfileFull' && isLoggedIn)
div
.append('button')
.text('Radar Graph 3')
.on('click', e =>
launchRadarPlot(
app,
'profileRadar',
'Radar Graph 3',
'plot2',
preserveCheckbox.node().checked,
isLoggedIn,
site
)
)
.on('click', e => launchRadarPlot(app, 'profileRadar', 'Radar Graph 3', 'plot2', isLoggedIn, site))
if (isLoggedIn)
div
.append('button')
.text('Summary')
.on('click', e => launchSummaryPlot(e.target, app, preserveCheckbox.node().checked, isLoggedIn, site))
.on('click', e => launchSummaryPlot(e.target, app, isLoggedIn, site))

div.append('label').attr('for', 'preservePlots').text('Preserve Plots')
const preserveCheckbox = div.append('input').attr('id', 'preservePlots').attr('type', 'checkbox')
const deleteBt = div
.append('button')
.on('click', e => deletePlots(app))
.text('Delete All')
}

async function launchPlot(app, chartType, header, preserve, isLoggedIn, site) {
if (!preserve) await deletePlots(app)
async function launchPlot(app, chartType, header, isLoggedIn, site) {
const config = await app.dispatch({
type: 'plot_create',
config: {
Expand All @@ -169,8 +138,7 @@ async function launchPlot(app, chartType, header, preserve, isLoggedIn, site) {
})
}

async function launchRadarPlot(app, chartType, header, plot, preserve, isLoggedIn, site) {
if (!preserve) await deletePlots(app)
async function launchRadarPlot(app, chartType, header, plot, isLoggedIn, site) {
const config = await app.dispatch({
type: 'plot_create',
config: {
Expand All @@ -183,7 +151,7 @@ async function launchRadarPlot(app, chartType, header, plot, preserve, isLoggedI
})
}

async function launchSummaryPlot(button, app, preserve, isLoggedIn, site) {
async function launchSummaryPlot(button, app, isLoggedIn, site) {
/*
holder: the holder in the tooltip
chartsInstance: MassCharts instance
Expand Down

0 comments on commit 51e4255

Please sign in to comment.