Comments (6)
You can add a transparent overlay view that covers the chart when the user taps on the circle. There's a utility class HandlingView which you could use for this - you can pass a touchHandler
to it in which you clear the popup.
In order for the circles to continue being interactive while the overlay is open you'd have to make that the overlay is added behind the circles (in this case the overlay can be added permanently, no need to do it only when user taps). I'd create a ChartLayer
class and implement chartInitialized
such that it adds this overlay as subview of the chart. Then pass this layer to Chart
initialiser before the layer holding the circles. If you don't want to create new layer class you can also instantiate ChartPointsViewsLayer
with a dummy chart point, where you just add the overlay to the chart in the view generator.
from swiftcharts.
P.S. Here also code to make clearer what I mean, with ChartPointsViewsLayer
approach, it would look similar to this
let overlayGenerator = {(chartPointModel: ChartPointLayerModel, layer: ChartPointsLayer, chart: Chart) -> UIView? in
let view = HandlingView(frame: chart.frame)
view.touchHandler = {
// code to hide current popup
}
return view
}
let dummyChartPoint = ChartPoint(0, 0) // coordinates are not important here since we don't use them
let overlayLayer = ChartPointsViewsLayer(xAxis: xAxis, yAxis: yAxis, innerFrame: innerFrame, chartPoints: dummyChartPoint, viewGenerator: overlayGenerator)
...
let chart = Chart(
frame: chartFrame,
layers: [
...
overlayLayer,
circlesLayer,
...
]
)
let me know if it works out for you or you face any other issues!
from swiftcharts.
Didn't seem to work, the touchHandler was never entered. Would it be possible to provide an updated running example? Thanks so much for your quick response.
from swiftcharts.
This is an exact copy of the areas example, you can find the overlay part enclosed in ////////////. https://gist.github.com/i-schuetz/a7801eba798e2d04d1c5
from swiftcharts.
Thank you. This is what I observed now, if I click on any of the green space, then the pop up is clear. However, if I click on some of the white space, then sometimes the popup is not clear. For example, click 6,290, then click on the first top box (i.e. 350-300,0-2), then it is not clear.
from swiftcharts.
Ah, you have to pass chart.bounds
instead of chart.frame
to the HandlingView
. The chart's frame starts at 0,70 which is why the overlay doesn't cover the upper part.
from swiftcharts.
Related Issues (20)
- Static library
- Temporarily hide lines in Line chart
- What's the correct way to set contentView background color and border? HOT 1
- Is this kind of y axis layout possible:
- Extending Views to create custom views isn't working due to file private and internal properties
- How to overlay a layer of labels?
- Axis disappear after coming back from background
- X Y points in horizontal bar chart keeps moving rights; when the y axis labels length (text) is more
- Swift 5
- Changing axis values
- X values not adding properly
- Axis Labels not showing up HOT 2
- ChartLabelSettings() ignoring supplied font color, always defaults to black HOT 1
- SPM Support?
- Problem building on new MacBook
- SPM not working properly due to missing TAG HOT 1
- x, y Axis didn't show in the Chart HOT 2
- ChartPointsBubbleLayer not draws properly HOT 1
- how to dynamic live update line chart
- How can i make xAxisLabel to get multiple data instead of one value for one xAxisLabel ?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swiftcharts.