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

UI/bar chart horizontal #12437

Merged
merged 51 commits into from Sep 7, 2021
Merged

UI/bar chart horizontal #12437

merged 51 commits into from Sep 7, 2021

Conversation

hellobontempo
Copy link
Contributor

@hellobontempo hellobontempo commented Aug 25, 2021

Horizontal bar chart component for client counts.

bar_chart

TO DO:

  • Abstract to make more reusable for other use cases (i.e. unstacked data)
  • Clean up D3
  • Accessibility (this will happen in tandem with D3 cleanup)

@vercel vercel bot temporarily deployed to Preview – vault September 1, 2021 18:17 Inactive
@hellobontempo hellobontempo added this to the 1.9 milestone Sep 1, 2021
*
* @example
* ```js
* <BarChartComponent @title="Top 10 Namespaces" @description="Each namespace's client count includes clients in child namespaces." @labelKey="namespace_path" @dataset={{this.testData}} @mapLegend={{ array (hash key="non_entity_tokens" label="Active direct tokens") (hash key="distinct_entities" label="Unique Entities") }} @onClick={{this.onClick}} >
Copy link
Contributor Author

Choose a reason for hiding this comment

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

All on one line because storybook didn't like when each arg was on its own line...

@vercel vercel bot temporarily deployed to Preview – vault September 1, 2021 18:20 Inactive
}
}

.header-right {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

.header-right is where anything passed into the block is yielded (i.e. an export button). Should this styling be less specific since the button is no longer part of this component?

import { select, event, selectAll } from 'd3-selection';
// eslint-disable-next-line no-unused-vars
import { transition } from 'd3-transition';

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Chart styling is within the component file for now so that a future developer doesn't have to hunt down the .css file and some .css styling is kind of wonky when interacting with d3. In next PR, when cleaning up d3, may consider moving all static styling to .css

.append('rect')
.attr('class', 'data-bar')
.style('cursor', 'pointer')
.attr('width', chartData => `${xScale(chartData[1] - chartData[0] - 5)}%`)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

- 5 is responsible for the small gap between horizontal bars

@hellobontempo hellobontempo marked this pull request as ready for review September 1, 2021 18:32
Copy link
Contributor

@Monkeychip Monkeychip left a comment

Choose a reason for hiding this comment

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

This is a great start. I know you still have some refinements that can come in future PRs. This component works, and getting it merged will make it easier for the development process on the metrics project.

@vercel vercel bot temporarily deployed to Preview – vault September 3, 2021 18:57 Inactive
@arnav28 arnav28 merged commit 8b3cc50 into main Sep 7, 2021
jartek pushed a commit to jartek/vault that referenced this pull request Sep 11, 2021
* creates bar chart component

* WIP//starts styling

* fixes width of bars

* WIP//barchart

* uses d3 max method instead of Math.max

* stacks data

* adds y axis

* fixes styling and spacing

* adds spacing between bars

* styling DONE

* adds legend

* adds tooltip

* tweaks styling adds pointer cursor to rects

* fixes tooltip placement

* moves starget from bar to whole area

* finishes hover selection styling

* cleans up

* cleans up a tiny bit

* stopping point

* adjusts tooltip placemnt

* WIP//clean up time

* sort of not broken

* unbroken, ish

* tooltip position fixed

* truncates text and adds tooltip

* changes tooltip width depending on content

* unbroken

* finishes initial refactor/cleanup

* finishes documentation

* passes in map legend to component

* more tidying

* add export option

* adds grid to header for export button option

* updates comments

* fix variable name change

* moves dataset formatting to parent

* removes unused code"

* adds assertions and empty state if no data

* cleans up comments adds assertion to check for map legend

* adds storybook

* adds changelog

* deletes dummy parent:

* restores index.hbs

* uses scss variables instead

* exchanges more variables

* remove unused variable in storybook

* writes basic test

* removes pauseTest()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants