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

Add Categorical Bar Chart on Study View #4951

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

olzhasmukayev
Copy link
Contributor

@olzhasmukayev olzhasmukayev commented Jul 25, 2024

Choose chart type:

image

Copy link

netlify bot commented Jul 25, 2024

Deploy Preview for cbioportalfrontend ready!

Name Link
🔨 Latest commit dcf08bf
🔍 Latest deploy log https://app.netlify.com/sites/cbioportalfrontend/deploys/66e2e773872618000835a286
😎 Deploy Preview https://deploy-preview-4951.cancerrevue.org
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@@ -312,3 +324,18 @@ export const STUDY_VIEW_CONFIG: StudyViewConfig = _.assign(
studyViewFrontEnd,
(getServerConfig() || {}).study_view
);

export const chartChangeOptionsMap: ChangeChartOptionsMap = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this used?

uniqueKey: string,
data: ClinicalDataCount[] | string[]
): void {
const { totalCount, naCount } = (data as (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add comments here to explain what's happening here. can also add comments below to describe the method of choosing which chart

@@ -414,6 +416,85 @@ export class ChartHeader extends React.Component<IChartHeaderProps, {}> {
);
}

if (
this.props.chartControls &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can simplify to this.props.chartControls?.showChartChangeOptions


@autobind
private onSelection(bars: { data: BarDatum[] }[]): void {
const dataBins = _.flatten(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when performing multiple array functions, lets chain multiple lodash functions like
_(bars) .function() .function() ...
lodash has a map function

const TILT_ANGLE = 30;

@observer
export default class CategoryBarChart
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm noticing some similarities with our existing BarChart component. can we look into maybe extending it or reusing that code to prevent duplicate code?

}
}

const onlyContainsNA = (element: BarDatum): boolean => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

like said above, these functions are in BarChart as well. we could make export these functions to prevent duplication

import { VictoryLabel, Helpers } from 'victory';
import { Tooltip, OverlayTrigger } from 'react-bootstrap';

export class CategoryBarChartAxisLabel extends VictoryLabel {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above. i think we have very similar components with our BarChart component. it would be nice to reuse this somehow. lets look into this for all similarly related components

updateCurrentBinsValue() {
let newBins: number[] = [];
if (this.currentBinMethod === BinMethodOption.CUSTOM) {
newBins = _.sortBy(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lodash chaining here as well

@@ -1451,6 +1484,11 @@ export class ChartContainer extends React.Component<IChartContainerProps, {}> {
() => (this.newlyAdded = false),
STUDY_VIEW_CONFIG.thresholds.chartHighlight
);
} else if (this.chartChanged) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

currently when changing a chart type, the highlight doesn't go away. look into the mechanism behind this and figure out why

@inodb inodb changed the title feat: add category bar chart Add Categorical Bar Chart on Study View Aug 13, 2024
@inodb
Copy link
Member

inodb commented Aug 13, 2024

@olzhasmukayev Nice work! Can we enable it for Metastatic Sites as well?

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants