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

Tooltip: customize point style (like in legend plugin) #11787

Open
marc-mabe opened this issue May 24, 2024 · 0 comments
Open

Tooltip: customize point style (like in legend plugin) #11787

marc-mabe opened this issue May 24, 2024 · 0 comments

Comments

@marc-mabe
Copy link

marc-mabe commented May 24, 2024

Feature Proposal

I want to customize the legend and tooltip icons to be rendered as a line instead of rectangle.
For the legend plugin this works fine with usePointStyle=true together with a custom generateLabels doing something like this:

if (dataset.type === 'line') {
	const defaultLineOpts = Chart.defaults.elements.line;
	labelItem.pointStyle = 'line';
	labelItem.rotation = 0;
	labelItem.lineWidth = get(dataset, 'borderWidth', defaultLineOpts.borderWidth);
	labelItem.lineDash = get(dataset, 'borderDash', defaultLineOpts.borderDash);
	labelItem.lineJoin = get(dataset, 'borderJoinStyle', defaultLineOpts.borderJoinStyle);
	labelItem.lineCap = get(dataset, 'borderCapStyle', defaultLineOpts.borderCapStyle);
	labelItem.lineDashOffset = get(dataset, 'borderDashOffset', defaultLineOpts.borderDashOffset);
} else {
	labelItem.pointStyle = 'rect';
}

Unfortunately for the tooltip plugin this does not work :/
I can set usePointStyle=true and defined a custom callbacks.labelPointStyle but I can only return an object of { pointStyle: PointStyle; rotation: number }.
This way I get a line rendered but I didn't find any way define the line width or build dotted lines which makes the chart tooltip useless if you have a chart with multiple lines of similar colors differentiated by line style (like dotted lines).

In _drawColorBox border[Width|Color|Dash|DashOffset] is used only if usePointStyle=false.

In my opinion (without knowing very much about your code structure) it would be beneficial for users and reduce code complexity if both (legend and tooltip) plugins would share the same logic to render customized icons and therefor share the same configuration options to do so.

Thanks :)

Possible Implementation

No response

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