-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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/total client usage #13359
Merged
Merged
UI/total client usage #13359
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import Component from '@glimmer/component'; | ||
import { action } from '@ember/object'; | ||
import { select } from 'd3-selection'; | ||
import { scaleLinear, scaleBand } from 'd3-scale'; | ||
import { stack } from 'd3-shape'; | ||
|
||
/** | ||
* ARG TODO fill out | ||
* @module TotalClientUsage | ||
* TotalClientUsage components are used to... | ||
* | ||
* @example | ||
* ```js | ||
* <TotalClientUsage @requiredParam={requiredParam} @optionalParam={optionalParam} @param1={{param1}}/> | ||
* ``` | ||
* @param {object} requiredParam - requiredParam is... | ||
* @param {string} [optionalParam] - optionalParam is... | ||
* @param {string} [param1=defaultValue] - param1 is... | ||
*/ | ||
|
||
// ARG TODO pull in data | ||
const DATA = [ | ||
{ month: 'January', directEntities: 500, nonDirectTokens: 22 }, | ||
{ month: 'February', directEntities: 150, nonDirectTokens: 22 }, | ||
{ month: 'March', directEntities: 155, nonDirectTokens: 25 }, | ||
{ month: 'April', directEntities: 155, nonDirectTokens: 229 }, | ||
{ month: 'May', directEntities: 156, nonDirectTokens: 24 }, | ||
{ month: 'June', directEntities: 157, nonDirectTokens: 42 }, | ||
{ month: 'July', directEntities: 158, nonDirectTokens: 12 }, | ||
{ month: 'August', directEntities: 161, nonDirectTokens: 1 }, | ||
{ month: 'September', directEntities: 190, nonDirectTokens: 222 }, | ||
{ month: 'October', directEntities: 250, nonDirectTokens: 66 }, | ||
{ month: 'November', directEntities: 300, nonDirectTokens: 32 }, | ||
{ month: 'December', directEntities: 600, nonDirectTokens: 202 }, | ||
]; | ||
|
||
// COLOR THEME: | ||
const BAR_COLOR_DEFAULT = ['#1563FF', '#8AB1FF']; | ||
|
||
export default class TotalClientUsage extends Component { | ||
@action | ||
registerListener(element) { | ||
let stackFunction = stack().keys(['directEntities', 'nonDirectTokens']); | ||
let stackedData = stackFunction(DATA); | ||
let yScale = scaleLinear() | ||
.domain([0, 802]) // TODO calculate high of total combined | ||
.range([100, 0]); | ||
let xScale = scaleBand() | ||
.domain(DATA.map(month => month.month)) | ||
.range([0, 100]) | ||
.paddingInner(0.85); | ||
let chartSvg = select(element); | ||
chartSvg.attr('width', '100%'); | ||
chartSvg.attr('height', '100%'); | ||
|
||
let groups = chartSvg | ||
.selectAll('g') | ||
.data(stackedData) | ||
.enter() | ||
.append('g') | ||
.style('fill', (d, i) => BAR_COLOR_DEFAULT[i]); | ||
|
||
groups | ||
.selectAll('rect') | ||
.data(stackedData => stackedData) | ||
.enter() | ||
.append('rect') | ||
.attr('width', `${xScale.bandwidth()}%`) | ||
.attr('height', data => `${100 - yScale(data[1])}%`) | ||
.attr('x', data => `${xScale(data.data.month)}%`) | ||
.attr('y', data => `${yScale(data[0]) + yScale(data[1]) - 100}%`); | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
.chart-wrapper { | ||
border: $light-border; | ||
border-radius: $radius-large; | ||
padding: $spacing-l $spacing-l $spacing-s $spacing-l; | ||
height: 380px; | ||
width: 100%; | ||
|
||
display: grid; | ||
grid-template-columns: 1.5fr 1fr 1fr 1fr; | ||
grid-template-rows: repeat(5, 1fr); | ||
|
||
// ARG TODO we can manage this using css grid | ||
// > div.is-border { | ||
// border: 0.3px solid $ui-gray-200; | ||
// margin-bottom: $spacing-xxs; | ||
// } | ||
} | ||
|
||
.chart-header { | ||
grid-column-start: 1; | ||
grid-column-end: span col4-end; | ||
grid-row-start: 1; | ||
|
||
.chart-title { | ||
font-size: $size-5; | ||
font-weight: $font-weight-bold; | ||
line-height: normal; | ||
} | ||
.chart-description { | ||
font-size: $size-8; | ||
font-weight: $font-weight-normal; | ||
color: $ui-gray-700; | ||
margin-bottom: $spacing-xs; | ||
} | ||
} | ||
|
||
.data-description { | ||
grid-column-start: 1; | ||
grid-row-start: 2; | ||
} | ||
|
||
.data-one { | ||
grid-column-start: 1; | ||
grid-row-start: 3; | ||
} | ||
|
||
.data-two { | ||
grid-column-start: 1; | ||
grid-row-start: 4; | ||
} | ||
|
||
.chart-container { | ||
grid-column-start: 2; | ||
grid-column-end: span col4-end; | ||
grid-row-start: 2; | ||
grid-row-end: span 3; | ||
|
||
padding: $spacing-m 0; | ||
} | ||
|
||
.chart { | ||
.tick > text { | ||
font-weight: $font-weight-semibold; | ||
font-size: $size-8; | ||
} | ||
} | ||
|
||
.legend-container { | ||
grid-column-start: 2; | ||
grid-column-end: span col4-end; | ||
grid-row-start: 5; | ||
justify-self: center; | ||
align-self: center; | ||
} | ||
|
||
.legend { | ||
width: 100%; | ||
height: 100%; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice job! thank you for doing this