-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* blah * setup * clean up * rename history to dashboard * clean up
- Loading branch information
1 parent
1ad3ba0
commit fbc72d6
Showing
11 changed files
with
348 additions
and
267 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
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.