Warning
This help isn’t complete. It may even look terrible. If you want to work on it, see How to Contribute. You can also ask for help in the Juice Slack #documentation channel.
Contents
A Matchup slice is used to present the user with a view of the data separated compared against the average of those results with the highest positive and separate differences displayed. It currently only has a default flavor.
Matchup slices support the Common configuration options for all slices. Additional options are:
The template that will be evaluated to determine the score title
Optional: | Yes, default is “score” |
---|---|
Values: | Underscore.js template or plain text |
Example: | config:
scoreTitleTemplate: "<%= selection(\"lollipop\", {\"dimension\":
\"metric\"}) %> score"
|
The text that indicates average
Optional: | Yes, default is “industry average” |
---|---|
Values: | String |
Example: | config:
averageTitle: "Company average"
|
The statistical difference to group the values by. Values within this threshold are considered to be “similar”.
Optional: | Yes, default is 1 |
---|---|
Values: | number |
Example: | config:
differenceThreshold: 2
|
Togglable display modes (eg. show summary|all)
Optional: | Yes, default is [“summary”, “all”] |
---|---|
Values: | Array of strings/mode names |
Example: | config:
displayModes: ["summary", "all"]
|
Flag that indicates whether the count within the group should be shown
Optional: | Yes, default is |
---|---|
Values: | true|false |
Example: | config:
showCount: false
|
A boolean that controls if the data should be sorted. If set to true
,
sorting will be disabled and displayModes
will be automatically set to
["all"]
Optional: | Yes, default is |
---|---|
Values: | true|false |
Example: | config:
disableSort: true
|
The first dimension in self.dimensions is the grouping dimension, and the first metric is the value metric.
The code for the default matchup flavor looks as follows:
class MatchupV3Service(CensusService):
def build_response(self):
self.metrics = ('popdiff', )
self.dimensions = ('state',)
recipe = self.recipe().metrics(*self.metrics).dimensions(
*self.dimensions)
self.response['responses'].append(recipe.render())
The slice in stack.yaml:
- slice_type: "matchup"
slug: "matchup"
title: "matchup"
data_service: "censusv2service.MatchupV3Service"
config:
"differenceThreshold": 0.01
"scoreTitleTemplate": "Population Change"
"averageTitle": "Average Change"
Any additional dimensions and metrics are not included in the output in any way.