Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

include tooltip in v1 defintion #341

Open
tomwayson opened this issue Oct 23, 2017 · 8 comments
Open

include tooltip in v1 defintion #341

tomwayson opened this issue Oct 23, 2017 · 8 comments

Comments

@tomwayson
Copy link
Member

It was part of the v0.x definition and I think we want this to be abstracted rather than relying on overrides.

I think for v1 we'll want this at the series level rather than the root.

@tomwayson
Copy link
Member Author

@tomwayson
Copy link
Member Author

Seems like in v0 you can't turn off tooltips!

Go to http://jsfiddle.net/tomwayson/dox5o6w4/ and try setting "tooltip": false, on the definition, or passing tooltip: false to .show()

That's kinda awful, and I don't think we should continue that in v1x.

@tomwayson tomwayson added this to the v1.0.0 milestone Dec 22, 2017
@tomwayson
Copy link
Member Author

Also, I'm not keen on the name tooltip, this isn't some confusingly named text input - it's data, maybe popup?

@tomwayson
Copy link
Member Author

FYI here are the current tooltip settings.

Serial/pie charts:

graph.balloonText = `${graph.title} [[${spec.categoryField}]]: <b>[[${graph.valueField}]]</b>`

x/y charts:

graph.balloonText = `<div>${series.category.label}: [[${series.category.field}]]</div><div>${series.value.label}: [[${series.value.field}]]</div>`
// bubble
if (spec.type === 'xy' && series.size) {
graph.valueField = series.size.field
graph.balloonText = `${graph.balloonText}<div>${series.size.label}: [[${graph.valueField}]]</div>`
} else {
delete graph.valueField
}
}

@tomwayson
Copy link
Member Author

After a discussion w/ the Hub team we're going to stick w/ the name "tooltip"

@tomwayson tomwayson added the hub label Mar 22, 2018
@tomwayson
Copy link
Member Author

We should use .visible to control whether or not to show tooltips for consistency with legend (#394), and default to true.

@tomwayson
Copy link
Member Author

tomwayson commented Mar 22, 2018

The crux of this issue is figuring out how to do token replacement in the string templates.

v0 allows for injecting attribute values using {} as the delimiter: Ex:

{Number_of_SUM} Students in {Type}

However, in v1, b/c there can be multiple series, so you could not specify a single top level tooltip that used hardcoded field names and labels like that. Ideally we'd let consumer's inject values from the series. For example, if you were to try and express the current default tooltip using template literals it would effectively be:

${series.value.label} ${data[series.category.field]}: <b>${data[series.value.field]}</b>

However v1's joined datasets complicate this. For a joined dataset it's effectively:

${series.value.label} ${data.categoryField}: <b>${data[series.value.field + '_' + datasetIndex]}</b>

I'm not even sure we could support adlib expressions that we could capture all that nested nastiness.

An alternative is that we can start w/ tooltip being defined at the series level instead of at the definition.tooltip level. Then consumers could safely use hardcoded field names and labels in the templates. The problem is that if you wanted to turn tooltips off (visible = false), you'd have to do it for each series. Long term we'd want to support tooltip at both at the top level and at the series level, and merge them w/ Object.assign() when generating the AmCharts tooltip. We could do that now and then later add the ability to inject series properties so that you could better handle most cases w/ a single top-level tooltip.

@tomwayson
Copy link
Member Author

tomwayson commented Mar 29, 2018

#411 helps w/ this a bit, b/c the format for joined field names is now: ${series.source}_${series.value.field} (again using template literals), so at least everything we'd need to do token replacement is available either on data (row) or the series itself. So the joined template would now be:

${series.value.label} ${data.categoryField}: <b>${data[series.source + '_' + series.value.field]}</b>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant