-
Notifications
You must be signed in to change notification settings - Fork 486
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1081 from julien/issue_1080
Implement radar chart | Fixes #1080
- Loading branch information
Showing
13 changed files
with
218 additions
and
0 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
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,66 @@ | ||
import Chart from './Chart'; | ||
import Soy from 'metal-soy'; | ||
import templates from './RadarChart.soy.js'; | ||
import types from './utils/types'; | ||
import {Config} from 'metal-state'; | ||
|
||
/** | ||
* Radar Chart Component | ||
* @augments Chart | ||
*/ | ||
class RadarChart extends Chart {} | ||
|
||
RadarChart.STATE = { | ||
/** | ||
* Labels visibility | ||
* @default true | ||
* @instance | ||
* @memberof RadarChart | ||
* @type {Boolean} | ||
*/ | ||
labels: Config.bool().value(true), | ||
|
||
/** | ||
* Set radar options | ||
* @default undefined | ||
* @instance | ||
* @memberof RadarChart | ||
* @type {?Object} | ||
* | ||
*/ | ||
radar: Config.shapeOf({ | ||
axis: Config.shapeOf({ | ||
line: Config.shapeOf({ | ||
show: Config.bool(), | ||
}), | ||
max: Config.number(), | ||
text: Config.shapeOf({ | ||
show: Config.bool(), | ||
}), | ||
}), | ||
level: Config.shapeOf({ | ||
show: Config.bool(), | ||
text: Config.shapeOf({ | ||
format: Config.func(), | ||
show: Config.bool(), | ||
}), | ||
}), | ||
size: Config.shapeOf({ | ||
ratio: Config.number(), | ||
}), | ||
}), | ||
|
||
/** | ||
* The variety of chart that will be rendered. | ||
* @default radar | ||
* @instance | ||
* @memberof AreaLineChart | ||
* @type {?(string|undefined)} | ||
*/ | ||
type: Config.oneOf(types.radar).value('radar'), | ||
}; | ||
|
||
Soy.register(RadarChart, templates); | ||
|
||
export {RadarChart}; | ||
export default RadarChart; |
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,8 @@ | ||
{namespace ClayRadarChart} | ||
|
||
/** | ||
* This renders the component's whole content. | ||
*/ | ||
{template .render} | ||
{call ClayChart.render /} | ||
{/template} |
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,30 @@ | ||
import {bb} from 'billboard.js'; | ||
import RadarChart from '../RadarChart'; | ||
|
||
beforeAll(() => { | ||
jest.spyOn(bb, 'generate').mockImplementation(); | ||
}); | ||
|
||
beforeEach(() => { | ||
bb.generate.mockReset(); | ||
}); | ||
|
||
afterAll(() => { | ||
bb.generate.mockReset(); | ||
bb.generate.mockRestore(); | ||
}); | ||
|
||
describe('RadarChart', () => { | ||
it('should be pass correct type to billboard.js', done => { | ||
const chart = new RadarChart({ | ||
data: [], | ||
}); | ||
|
||
chart.on('chartReady', () => { | ||
const config = bb.generate.mock.calls[0][0]; | ||
|
||
expect(config.data.type).toBe('radar'); | ||
done(); | ||
}); | ||
}); | ||
}); |
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,13 @@ | ||
import Chart from './Chart'; | ||
import {RadarChart as RadarChartBase} from '../RadarChart'; | ||
|
||
/** | ||
* Radar Chart component. | ||
* @augments Chart | ||
*/ | ||
class RadarChart extends Chart {} | ||
|
||
RadarChart.PROPS = RadarChartBase.STATE; | ||
|
||
export {RadarChart}; | ||
export default RadarChart; |
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,33 @@ | ||
.bb-chart-radars { | ||
.bb-levels { | ||
polygon { | ||
fill: none; | ||
stroke: #848282; | ||
stroke-width: .5px; | ||
} | ||
|
||
text { | ||
fill: #848282; | ||
} | ||
} | ||
|
||
.bb-axis { | ||
line { | ||
stroke: #848282; | ||
stroke-width: .5px; | ||
} | ||
|
||
text { | ||
font-size: 1.15em; | ||
cursor: default; | ||
} | ||
} | ||
|
||
.bb-shapes { | ||
polygon { | ||
fill-opacity: .2; | ||
stroke-width: 1px; | ||
} | ||
} | ||
} | ||
|
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
1 change: 1 addition & 0 deletions
1
packages/clay-isomorphic/fixtures/expected/ClayRadarChart.render
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 @@ | ||
<div class="metal-chart-container"><div class="metal-chart" ref="chart"></div><div hiddenref="placeholder"><div aria-hidden="true" class="loading-icon"><span class="loading-animation"></span></div></div></div> |
3 changes: 3 additions & 0 deletions
3
packages/clay-isomorphic/fixtures/input/ClayRadarChart.render
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,3 @@ | ||
{ | ||
|
||
} |