ChartsOrg / ChartsOrg/Charts

Ability to deselect chart value upon highlighting already selected value

Open
#3,861 3 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Swift
Stars
28k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

* [x] I've read, understood, and done my best to follow the [*CONTRIBUTING guidelines](https://github.com/jjatie/Charts/blob/master/CONTRIBUTING.md).

## Enhancement Request

In my pie chart, I allow users to select values upon tap. This triggers the `chartValueSelected(_ chartView: ChartViewBase, entry: ChartDataEntry, highlight: Highlight)` delegate function. If the user taps the same slice again, this same function is called. Instead of selecting the already selected value, I would like a subsequent tap to deselect the selected value, thus triggering `chartValueNothingSelected(_ chartView: ChartViewBase)`.

I imagine it would be best to expose a bool to configure this behavior, and simply compare the `lastHighlighted` value to the new `highlight` in `highlightValue(_ highlight: Highlight?, callDelegate: Bool)` to know when to select vs deselect.

## Charts Environment

**Charts version/Branch/Commit Number:** 3.2.2
**Platform(s) running Charts:** iOS

Contributor guide

Open the contributing guide

Research direction

Start with highlightValue(_:callDelegate:) and the chartValueSelected(_:,entry:,highlight:) and chartValueNothingSelected(_:) delegate callbacks described in the issue. Check how repeated highlights are represented and define completion as a repeated tap deselecting the current slice while preserving selection for a different value; verify the behavior on an iOS pie chart.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
data-visualization, mobile
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.