v1 error chart
@rgdonohue asked in slack about how you can adapt the v0 error bars example to work in v1. Here's a working example:
Go to http://cedar-v1.surge.sh/ and enter the following in the JSON editor:
{
"type": "bar",
"datasets": [
{
"data": {
"features": [
{"attributes": {"state": "CA", "pop": 5000, "error": 2000}},
{"attributes": {"state": "AZ", "pop": 2000, "error": 1400}},
{"attributes": {"state": "NY", "pop": 8000, "error": 1000}}
]
}
}
],
"series": [
{
"category": {"field": "state", "label": "State"},
"value": {"field": "pop", "label": "Population"}
}
],
"overrides": {
"valueAxes": [{
"id": "v1"
}],
"graphs": [{
"balloonText": "value:<b>[[value]]</b><br>error:<b>[[error]]</b>",
"bullet": "yError",
"bulletSize": 10,
"errorField": "error",
"bulletAxis": "v1"
}]
}
}
You will get something like this:
The key is the overrides section which allows you to set the relevant AmCharts properties to match their error char example.
@benstoltz
If we want to make this easier we should add default ids to the spec axes.
@ajturner @ghudgins
Do we want to open an issue for the Cedar JSON to support errors, perhaps by allowing users to specify an errorField on series, so that consumers don't have to use overrides?
@tomwayson A need is often to do more than draw these bars for a single error value but to draw them according to upper and lower confidence interval values, which won't be symmetrical for non-normalized distributions.
That makes sense. I did a quick check and did not see a way to do it in amCharts. If it can be done in amCharts, it can be done in cedar v1.
There's a "bulletOffset" option for the graphs. Seems like we should be able to deduct the difference between the UCI and value from the LCI and value, and then offset the bullet with that number. Not currently working for me though.