ember-data-visualizations v3.14.0
ember-data-visualizations
Ember addon to support visualizations with dc.js (d3 & crossfiltering)
Installation
ember install ember-data-visualizationsUsage
All charts
All charts must have a group and a dimension. All charts use d3-tip (an npm package which can be found here) to create and style tooltips.
See the dummy app for an example of each type of chart. The code for the dummy can be found in tests/dummy. In particular, tests/dummy/controllers/application.js and tests/dummy/templates/application.hbs will be useful in understanding the use of this addon.
Optional parameters
height(number): height in pixels of the chartcolors(Array): Hex strings to color the chartshowLegend(boolean): Whether or not to show an interactive legend. Heatmaps do not have this option, however, as a heatmap doesn't make sense without a legend.legendWidth(number): width in pixels of the legend. Not applicable ifshowLegendisfalse. If not specified, defaults to 250.isChartAvailable(boolean, defaults totrue): iftrue, shows normal view. Iffalse, shows chart-not-available view.chartNotAvailableMessage(String): message to display on top of chart ifisChartAvailableis falsechartNotAvailableTextColor(String): Hexadecimal color value to color the text ofchartNotAvailableMessagechartNotAvailableColor: (String): Hexadecimal color value to color the chart ifisChartAvailableis false
All optional boolean parameters except isChartAvailable default to false.
Column chart
The column chart uses an array of crossfilter groups to display different types of column charts (vertical bar charts). If there is only one group, you must still pass an array of 1 group to the column chart. This is true for many of the charts in this addon.
Required parameters
dimension: crossfilter dimension to use for chartgroup: array of crossfilter groups to use for chartxAxis(Object):domain(Array, probably ofmomentobjects) andticks(number of ticks to show)
Optional parameters
yAxis(Object):domain(Array, probably of numbers) (optional): autofits bars,ticks(number of ticks to show), andformatter(function to apply to every y-axis value for tick display),bottomLabelPosition(boolean): whether to display labels on the top, or on the bottom of x-axis.type(String) (defaults toGROUPED):GROUPEDis for "ordinary" data and is most likely what should be used if there is only one crossfilter group.LAYEREDis for "overlapping data: e.g. there are 10 fruits, 6 of which are citrus, 3 of which are oranges. If this chart isLAYERED, theseriesoption tells the chart how to format the bars (hatching).STACKEDcreates a stacked bar chart: e.g. there are 10 fruits, 20 vegetables, and 15 meats and we want to display them on top of each other.
series(Array): Each object in the array has properties:title: the name ofthis.get('group')at the same index (used in tooltip creation)hatch:pos(for a hatch from bottom left to top right),neg(for a hatch from top left to bottom right), orfalse(for no hatch)
labelOptions(Object): display options for labels on top of bars/columns.showMaxMin(boolean): whether or not to show max/min indicators for the maximum and minimum values of one of the groups on the column chart.showDataValues(boolean): whether or not to display the y-value of each point above each bar.labelCollisionResolution(string) 'auto' | 'default': runs collision detection algorithm to determine if a label is too wide, and skips next labels accordingly.
seriesMaxMin(index): index ofthis.get('group')to use to determine the maximum and minimum values (only used ifshowMaxMinistrue)width(number): width in pixels of chart. If not specified, the chart will fill to the width of its container.showComparisonLines(boolean): whether or not to show the comparison linescomparisonLines(Array of Objects): horizontal lines to mark a target, average, or any kind of comparison value. Properties:value(number): value on y axis on which to show linecolor(Hex string): color of the comparison linealert(String; acceptable values:above,below,''): whether to change the color of rectangles above or below this line. Use an empty string for no color changing.alertColorIndex(number): index of thecolorsarray to use for color changes for this line.
showCurrentIndicator(boolean): whether or not to show diamond-shaped 'current' indicator on x axiscurrentInterval(Object): MUST have astartproperty which contains amomentobject that tells the chart where to display the current indicator.
Line chart
The line chart uses an array of crossfilter groups to display different types of line charts. If there is only one group, you must still pass an array of 1 group to the line chart. This is true for many of the charts in this addon.
Required parameters
dimension: crossfilter dimension to use for chartgroup: array of crossfilter groups to use for chartxAxis(Object):domain(Array, probably ofmomentobjects) andticks(number of ticks to show)
Optional parameters
yAxis(Object):domain(Array, probably of numbers) (optional) andticks(number of ticks to show)series(Array): Each object in the array has atitleproperty.titleis the name ofthis.get('group')at the same index (used in tooltip creation).width(number): width in pixels of chart. If not specified, the chart will fill to the width of its container.showCurrentIndicator(boolean): whether or not to show diamond-shaped 'current' indicator on x axiscurrentInterval(Object): MUST have astartproperty which contains amomentobject that tells the chart where to display the current indicator.showComparisonLines(boolean): whether or not to show the comparison linescomparisonLines(Array of Objects): horizontal lines to mark a target, average, or any kind of comparison value. Properties:value(number): value on y axis on which to show linecolor(Hex string): color of the comparison line
showMaxMin(boolean): whether or not to show max/min indicators for the maximum and minimum values of one of the groups on the line chartseriesMaxMin(index): index ofthis.get('group')to use to determine the maximum and minimum values (only used ifshowMaxMinistrue)
Row chart
The row chart uses an array of crossfilter groups to display different types of row charts (horizontal bar charts). If there is only one group, you must still pass an array of 1 group to the row chart. This is true for many of the charts in this addon.
Required parameters
dimension: crossfilter dimension to use for chartgroup: array of crossfilter groups to use for chart- Currently, the row chart only supports using one group, so the
groupparameter will be an array of length 1. However, it is kept as an array for potential future use on stacked, grouped, or layered charts.
- Currently, the row chart only supports using one group, so the
Optional parameters
colorsnote: colors2 is currently the color that the bars appear aslabelWidth(number): width in pixels of the labels div; defaults to 150xAxis(Object):ticksproperty tells the chart how many ticks to display on the x axis.width(number): width in pixels of chart. If not specified, the chart will fill to the width of its container.hideXAxisLines(boolean): whether to hide the x-axis grid lines that show by default on the chartshowYGridLines(boolean): whether to show y-axis grid lines on the chartshowYTicks(boolean): whether to show tick marks for each bar on the y axisshowMaxMin: whether to show max/min indicators for the maximum and minimum values of the row chartshowComparisonLine(boolean): whether to show a comparison linecomparisonLine(Object): a vertical line to mark a target, average, or any kind of comparison value. Properties:value(value on y axis on which to show line)displayValue(text that will appear to the left of the line on the y axis)color(Hex string)
chartNotAvailableBars(number): number of bars to show on the chart not available view
Pie chart
The pie chart does not use an array of crossfilter groups. It uses a singular group.
Required parameters
dimension: crossfilter dimension to use for chartgroup: crossfilter group to use for chart (not an array)
Optional parameters
colorMap(Object): parameter/key pairs by which to color chart- e.g. if key values of the data are
'apples, bananas, blueberries', colorMap might be{'apples': '#8b0000', 'bananas': '#ffff00', 'blueberries': '#6495ed'}, where those colors exist in thecolorsarray.
- e.g. if key values of the data are
heightnote: radius of the chart is height / 2donutChart(boolean): whether or not this pie chart is a donut chart (has an inner radius)showTotal(boolean): whether or not to show the total number in the center of the chart. Not recommended unlessdonutChartistruelabels(boolean): whether or not to show labels on the pie slices with the key value of the slicelabelsWithValues(boolean): whether or not to show values and labels both on the pie slices with the key value of the sliceexternalLabels(boolean): whether or not the labels appear on the outside of the chart. Only iflabelsistruelegend(boolean): whether or not to show a legend for the pie chartlabelCollisionResolution(string) auto | default : whether or not run collision detection algorithm to render labels outside of pie slices if they overlap.formatter(function) : formats label values, total text and tooltips according to the function passed.
Bubble chart
The bubble chart does not use an array of crossfilter groups. It uses a singluar group.
The bubble chart is a dc-addons bubbleCloud, which is not as robustly supported as the rest of our chart types. Therefore, crossfiltering on this chart will likely not be possible until the source is updated. See this issue.
Required parameters
dimension: crossfilter dimension to use for chartgroup: crossfilter group to use for chart (not an array)- The
keyof each fact is a string that identifies the fact. It is also used as the title of the bubble, subject to thetitleFormatterfunction (see optional parameters) - The
valueof each fact is an object with the following properties:tooltip(String): tooltips display thekeyproperty with a subtitle of whatever is contained in this property. Optional.colorValue(number): index of thecolorsarray that this bubble is colored. e.g. if thecolorsarray is['#8b0000', '#ffff00', '#6495ed'], abananaobject might have acolorValueof1. See the dummy app for an example of color mapping. Optional.radius(String): Not necessarily a number value. This is the string value that will be transformed into a number based onradiusFormat.- e.g. if
radiusFormat = 'timestamp',radiusshould be a timestamp like'2018-06-26T16:55:25-04:00'. Required.
- e.g. if
subtitle(String): Actual subtitle of bubble. Optional.
- The
Optional parameters
- Formats/formatters (if not specified, the labels on the bubbles will assume the
keyandvalue.subtitleproperty verbatim, andradiusFormatwill assume'count'):radiusFormat(string): specifies how to interpret thevalue.radiusstring to get an actual radius number. Options:timestamp,milliseconds,count.- The
timestampoption calculates the duration betweenvalue.radiusand now. - The
millisecondsoption assumes thatvalue.radiusis a duration in milliseconds. - The
countoption assumes that whatever is currently invalue.radiusis the actual physical radius desired.
- The
titleFormatter(function): Takes an input of the fact'skeyproperty and outputs the formatted string for the bubble label.- e.g. if the
keyis'First Last'and the label on the bubble should be the initials,titleFormattertakes an input ofFirst Lastand returnsFL.
- e.g. if the
subtitleFormatter(function): Takes an input of the fact'svalue.subtitleproperty and outputs the formatted string for the bubble subtitle.- e.g. if the
subtitleis a timestamp,subtitleFormattertakes an input of a timestamp and returns a formatted duration.
- e.g. if the
width(number): width in pixels of the chart. It is recommended that the chart be roughly square for best display of the bubbles. If not specified, the chart will fill to the width of its container.
Heat map
The heatmap does not use an array of crossfilter groups. It uses a singular group.
Required parameters
dimension: crossfilter dimension to use for chartcolors(Array): list of colors to use.group: crossfilter group to use for chart (not an array)- The
keyof each fact is an array that tells the heatmap the position of the fact on the chart.key[0]will tell the chart the y position, andkey[1]the x position. - The
valueproperty of each fact will be used to determine the color of the fact.
- The
colorMap(function): a function that takesvalueas parameter and returns index of an element fromcolorslist.xAxis(Object) describes the x axis. Properties:domain(Array): describes the domain of the x axis. This property is REQUIRED.ticks(number): number of tick LABELS to show on the x axis. This property is optional, and if left out, the chart will automatically show as many labels as will comfortably fit based on the chart's width.tickMarks(number): number of ticks to show on the x axis. This property is optional, and if left out, the chart will show a tick for each data point.label(String): a label for the x axis. This property is optional.
keyFormat(function): function to apply tokey[1]in order to attain the desired format on the screen. For example, ifkey[1]of each fact on yourgroupis a date formatted like20161109,keyFormatmight bekey => moment(key.toString()).format('MMM DD').
Optional parameters
yAxis(Object):labelproperty shows a label on the y axis (optional).width(number): width in pixels of chart. If not specified, the chart will fill to the width of its container.showCurrentIndicator(boolean): whether or not to show diamond-shaped 'current' indicator on x axiscurrentInterval(Object): MUST have astartproperty which contains amomentobject that tells the chart where to display the current indicator.legend(boolean): whether or not to show an interactive legend to the right of the heatmap. Iftrue,legendWidthmust also be specified for the legend to appear.legendWidth(number): width in pixels that legend should take up on the right side of the chart. This width is subtracted from the chart's overall width when drawing the chart, so it cannot be larger than thewidthparameter.minBoxWidth(number): minimum width in pixels for each box in the heatmap. If not specified, defaults to 4.
Contributing
Installation
git clone https://github.com/purecloudlabs/ember-data-visualizations.gitcd ember-data-visualizationsyarn --pure-lockfile
Linting
yarn lint:jsyarn lint:js -- --fix
Running tests
ember test– Runs the test suite on the current Ember versionember test --server– Runs the test suite in "watch mode"ember try:each– Runs the test suite against multiple Ember versions
Running the example charts
npm run storybook- Visit the examples at http://localhost:9001.
For more information on using ember-cli, visit https://ember-cli.com/.
License
This project is licensed under the MIT License.
2 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
9 years ago
9 years ago
9 years ago