-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Highcharts plugin): add
tooltip.sort
configuration (#170)
* feat(Highcharts plugin): add `tooltip.sort` configuration * fix: kuzmadom review fixes
- Loading branch information
Showing
5 changed files
with
38 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/plugins/highcharts/renderer/helpers/tooltip/helpers.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,20 @@ | ||
import orderBy from 'lodash/orderBy'; | ||
import type {TooltipData, TooltipLine} from './types'; | ||
|
||
export const escapeHTML = (html = '') => { | ||
const elem = document.createElement('span'); | ||
elem.innerText = html; | ||
|
||
return elem.innerHTML; | ||
}; | ||
|
||
export const getSortedLines = (lines: TooltipLine[], sort: TooltipData['sort'] = {}) => { | ||
// set eneabled to true after https://github.com/gravity-ui/chartkit/issues/171 | ||
const {enabled = false, order = 'desc', iteratee = 'originalValue'} = sort; | ||
|
||
if (!enabled) { | ||
return [...lines]; | ||
} | ||
|
||
return orderBy(lines, iteratee, order); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters