Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,17 @@ If you do not want to host the JSON file publicly, you can follow [these steps](

**_Note:_** The JSON file parsing is using D3 library, so consult the [D3 documentation](https://github.com/d3/d3-request/blob/master/README.md#json) for the data format details.

### Deep linking to a particular quadrant

You can use the optional query string parameter `quadrant` to specify the quadrant to view.

Supported values are:

- `first`
- `second`
- `third`
- `fourth`

### Building the radar

Paste the URL in the input field on the home page.
Expand Down
24 changes: 23 additions & 1 deletion spec/util/urlUtils-spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { constructSheetUrl, getDocumentOrSheetId, getSheetName } = require('../../src/util/urlUtils')
const { constructSheetUrl, getDocumentOrSheetId, getSheetName, getQuadrantFromURL } = require('../../src/util/urlUtils')
const config = require('../../src/config')
const queryParams = require('../../src/util/queryParamProcessor')

Expand Down Expand Up @@ -80,4 +80,26 @@ describe('Url Utils', () => {

expect(sheetName).toEqual('sheetName')
})

it('should return all if no quadrant found in url', () => {
queryParams.mockReturnValue({ some: 'param' })
delete window.location
window.location = Object.create(window)
window.location.href = 'https://thoughtworks.com/radar?sheet=radar'
window.location.search = '?'
const quadrant = getQuadrantFromURL()

expect(quadrant).toBe('all')
})

it('should return quadrant if found in url', () => {
queryParams.mockReturnValue({ quadrant: 'FIRST' })
delete window.location
window.location = Object.create(window)
window.location.href = 'https://thoughtworks.com/radar?sheet=radar'
window.location.search = '?'
const quadrant = getQuadrantFromURL()

expect(quadrant).toBe('first')
})
})
20 changes: 19 additions & 1 deletion src/graphing/radar.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ const {
renderMobileView,
renderRadarLegends,
removeScrollListener,
selectRadarQuadrant,
} = require('./components/quadrants')
const { renderQuadrantTables } = require('./components/quadrantTables')
const { addQuadrantNameInPdfView, addRadarLinkInPdfView } = require('./pdfPage')

const { constructSheetUrl } = require('../util/urlUtils')
const { constructSheetUrl, getQuadrantFromURL } = require('../util/urlUtils')
const { toRadian } = require('../util/mathUtils')

const MIN_BLIP_WIDTH = 12
Expand Down Expand Up @@ -832,9 +833,26 @@ const Radar = function (size, radar) {
hideTooltipOnScroll(tip)
addRadarLinkInPdfView()
}

selectQuadrantsToShow(quadrants)
}

return self
}

function selectQuadrantsToShow(quadrants) {
const quadrantToShow = getQuadrantFromURL()
let quadrant

for (const q of quadrants) {
if (q.order === quadrantToShow) {
quadrant = q
}
}

if (quadrant) {
selectRadarQuadrant(quadrant.order, quadrant.startAngle, quadrant.quadrant.name())
}
}

module.exports = Radar
8 changes: 8 additions & 0 deletions src/util/urlUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,16 @@ function getSheetName() {
return queryParams.sheetName
}

function getQuadrantFromURL() {
const queryParams = QueryParams(window.location.search.substring(1))
const quadrantQueryString = queryParams.quadrant

return quadrantQueryString?.toLowerCase() ?? 'all'
}

module.exports = {
constructSheetUrl,
getDocumentOrSheetId,
getSheetName,
getQuadrantFromURL,
}