How to specify custom image for either Scatter Chart or Bubble Chart? - uiimage

I have a CombinedChart in my app (same app on both Android and iOS platforms using MPAndroidChart & iOS-Charts respectively) with stacked bars and a line but I also need to highlight specific points where a given event happened. I've got some small icon images (png) and need to place the correct image at the correct place on the graph depending on what type of event happened.
I have tried Bubble chart first and can get bubbles of the right colour at the right location but can't specify custom image instead of the bubbles' circles.
I am now trying Scatter Chart which does have a Custom shape option but it's not just a shape I need, it's a specific image. I have not worked with Core Graphics before so I'm not familiar with CGPath functions.
Is there a way to pass a UIImage to the ScatterChart customScatterShape property?
Or maybe a way to convert a UIImage created from a named png to a CGPath object which the Scatter Chart custom shape requires?
Thanks in advance for your suggestions!

As of MPAndroid version 3.0.2, you can pass in a Drawable as part of your Entry dataSet.add(new Entry(x, y, drawable)), and enable the drawIcons flag via dataSet.setDrawIcons(true).
Source code where icon gets drawn for Line charts specifically: LineChartRenderer.java

Related

Can I add a moving scale or axis in plots using Vegalite?

I am trying to add a movable scale or axis inside a plot. For instance: in this example of stacked plot: Click-to-view
I want to include a movable y-axis scale so, if we hover the graph and put the mouse pointer on the beginning of the orange color of any bar, the a-xis will begin from that bar. (Specifically, moving x=0 line.)
I meant something like this example (of d3).
https://observablehq.com/#d3/index-chart
But, here I want to change the value of x-axis by moving the line. Is it possible to do it using vegalite? If somebody has any similar example in vegalite, can you refer it?
Thank you!
AFAIK, there is no animation in Vega Lite. However, you may check out Gemini which aims to extend the grammar of data viz to some simple animations of single-view Vega/Vega-Lite charts

XCODE 11, SWIFT 5. Drawing Lines, Boxes etc

I have recently switched to Xcode 11 and Swift 5. Also switched my entire project from UISwift to Storyboard as I read it has many advantages.
Now I’m finding disadvantages, I can’t draw boxes/lines on my storyboard, I can do it using the code but that creates further problems with making changes to my project in storyboard and element constrains.
Does anyone know if it’s possible to draw background boxes/lines between text? In some instances I have 6 labels that would all go under one box, so I can’t use label background feature.
See the online example below, of grey boxes
Now I’m finding disadvantages, I can’t draw boxes/lines on my storyboard
The storyboard editor isn't a drawing program -- it's mainly for laying out views and connecting them to each other and to other objects e.g. view controllers. If you're trying to use it to draw lines and boxes, you're barking up the wrong tree.
The storyboard editor does let you configure the views you create, so for example you can set the image displayed by a UIImageView, or the text displayed in a label, or the background color of any view. The gray boxes in your example are easy to do by just setting the background color of a view to gray. Or better, use a table to display those views, and programmatically set the background color of the cells depending on their row.
Does anyone know if it’s possible to draw background boxes/lines between text?
There are some hacky options. For example, you could very easily create a view class that draws a horizontal or vertical line through it's center point, or a view class that draws a line around its perimeter for a box. (You can actually use key-value coding to set properties on the view's layer to do this even without creating a subclass, but it's not something you want to have to do every time you need a box.) Those are fine for occasional use, but if you have any complex drawing to do, it's probably time to write a view class that draws the necessary content in code.
In some instances I have 6 labels that would all go under one box, so I can’t use label background feature.
Those 6 labels should all be contained inside another view, so you'd just set the background color for the view that contains them. Again, from your example, it looks like those are rows in a table. Each row in a table is its own view (or "cell"), and it's easy to set the background color in the same code that configures the rest of the subviews in that cell.

How can i create holo effect around coordinates text in qgis grid?

I am creating some maps in QGIS 2.18 composer manager. I can easily create grid for my map item, but latitude and longitude lines are going straight through the coordinates labels. Is there some kind of solution, that allows me to create halo effect around text, some kind of buffer? I dont want to move labels.
This is how it looks now:
strikeout label
This is what I want to achieve (created in paint):
desired label
Thanks

HTML5 Canvas: Create tooltip on customized drawing

I am using Flot to plot images for our project. For pre-defined shapes like line, pie, I can add tooltip through flot.tooltip.
However, we have some images that are drawn through Html5 canvas API, such as Here. I would like to add a tooltip for the red rectangle and another tooltip for the blank area. Any library to make it work?
With canvas there isn't a good way to detect when the mouse hovers over a particular drawn item; it's just a buffer, with no idea of what operations were used to draw into it. Flot's own hover detection has no concept of what was drawn on the canvas; it just knows that, e.g. the pie starts at a particular point and extend outwards a certain number of pixels.
So no matter what, you will have to write a function that accepts a mouse event, examines whatever data you used to draw the image, and decides what that corresponds to.
Where Flot could help is in providing a way to override the built-in hover function with your own; then the tooltip plugin would simply work with your function. Since you can't currently do that, you have a choice of a) modifying the tooltip plugin to use your function, or b) registering your own mousemove listener on the overlay element, which then generates 'fake' plothover events for the tooltip plugin to consume.

Drawing on CATiledLayer or CALayer with pdf in iOS

i have a scrollview which contains a pdfpage rendered with CATiledLayer, i want to draw stuff onto the pdf page so i created a overlay layer, i need the graphic to look vectorized so i decided to use CATiledlayer for the overlay layer. Only problem is that it is very slow to draw (I'm using beizerpath to draw), then i tried to optimize it by creating the overlay layer with the visible height and width when zooming in and out, so i don't need to create the overlay for the whole content bound. But still no luck , i want to try CALayer but the draw path just becomes blurry and pixelated, so i'm not sure how i can improve on this. I also tried drawinrect but for some reason it doesn't seem to work.
I suggest not using bezierpath to draw annotations since it requires you to redraw the whole path every time the pen moves. It would be better if you draw only the current line segment using CGContextAddQuadCurveToPoint.
At touchMoved, get the current point and 2 prev points
Using those points, get the area where the line should be drawn
draw at that area in drawRect using setNeedsDisplayAtRect
inside drawRect, go to the end of your path and add your new line using CGContextAddQuadCurveToPoint

Resources