Skip to content

Commit

Permalink
Fix capitalization of box plot ticks in comparison view
Browse files Browse the repository at this point in the history
  • Loading branch information
alisman committed Aug 11, 2022
1 parent 5f94c6a commit 11ba41f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
12 changes: 12 additions & 0 deletions packages/cbioportal-frontend-commons/src/lib/StringUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,18 @@ export function capitalize(str: string) {
}
}

export function lowerCaseAndCapitalizeString(str: string) {
// this is heurisitic. if it's a short string, it could
// be an acronym and shouldn't be lowercased
if (str.length < 5) {
return str;
} else {
return str.toLowerCase().replace(/^./g, s => {
return s.toUpperCase();
});
}
}

export function isUrl(str: string) {
const pattern = /^http[s]?:\/\//;
return pattern.test(str);
Expand Down
7 changes: 5 additions & 2 deletions src/shared/components/plots/BoxScatterPlot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import classnames from 'classnames';
import WindowStore from '../window/WindowStore';
import LegendDataComponent from './LegendDataComponent';
import LegendLabelComponent from './LegendLabelComponent';
import { lowerCaseAndCapitalizeString } from '../../../../packages/cbioportal-frontend-commons/src';

export interface IBaseBoxScatterPlotPoint {
value: number;
Expand Down Expand Up @@ -135,6 +136,9 @@ export default class BoxScatterPlot<

constructor(props: any) {
super(props);

console.log('aaron', props.data);

makeObservable(this);
}

Expand Down Expand Up @@ -538,8 +542,7 @@ export default class BoxScatterPlot<

@bind
private formatCategoryTick(t: number, index: number) {
//return wrapTick(this.labels[index], MAXIMUM_CATEGORY_LABEL_SIZE);
return this.labels[index];
return lowerCaseAndCapitalizeString(this.labels[index]);
}

@bind
Expand Down

0 comments on commit 11ba41f

Please sign in to comment.