I'm developing iOS app and I want to add/draw an HeatMap without using Google maps or any kind of map. I just want to draw it on my View. I have been looking for an open source library for iOS but I didn't find any.
Do anyone know a way how do I draw an HeatMap on View in iOS?
Here is an example for what I'm looking for but it's for Android platform:
https://github.com/HeartlandSoftware/AndroidHeatMap
Thanks, Tal.
in github enter in search field:
language:swift heatmap
you will get:
https://github.com/jamesdouble/JDSwiftHeatMap
If anyone is still looking for a heatmap that doesn't require a MKMapView and one that you can just place over an image, you could try this cocoapod
pod 'LFHeatMap'
https://github.com/gpolak/LFHeatMap.
Before you consider it for your project just know that you can't adjust the colour gradient of the "heat" without hacking the library a little. But it's pretty easy to use:
let points: [CGPoint] = [CGPoint(x: 25, y: 25),
CGPoint(x: 125, y: 125),
CGPoint(x: 200, y: 200)]
let image = LFHeatMap.heatMap(with: CGRect(x: 0, y: 0, width: 300, height: 300),
boost: 0.5,
points: points,
weights: nil)
let overlayHeatMap = UIImageView(image: image)
self.view.addSubview(overlayHeatMap)
overlayHeatMap.frame = CGRect(x: 0, y: 50, width: 300, height: 300)
If you're interested in changing the colour you can fiddle with code around line 411 in LFHeatMap.m below the comment that says '// Red and alpha component'
I am trying to retrieve a clipping region's dataURL, but whenever rects are outside of the region, the resulting image has a margin (I guess that it is trying to include the rects).
Here is an example of the behavior: https://codesandbox.io/embed/clip-area-x24ci
(Click on the "export" button or move the black rectangle outside of the clipping region)
Is is possible to retrieve just the clipping region's content?
You can set x, y, width and height for node.toDataURL() function:
const clipArea = {
x: 100,
y: 100,
height: 200,
width: 200
};
const dataURL = node.toDataURL({
pixelRatio: 2,
...clipArea
});
i'm using overFlow : linebreak in my program .And it work's fine this is my code ,
styles: {
fillStyle: 'DF',
overflow: 'linebreak',
columnWidth: 110,
lineWidth: 2,
lineColor: [85, 51, 27]
}
But that doesn't reflect inside the beforePageContent , Here is that code ,
beforePageContent: function(data) {
doc.setFontSize(12);
doc.setFont("courier");
doc.text("Process Name :",20 ,15);
doc.setFontStyle('bold');
//doc.overflow('linebreak');
doc.setFontStyle('normal');
doc.text("Description :"+sampData, 20, 30);
},
So how can i use lineBreak inside my beforePageContent block .
The overflow: linebreak; style is only for jspdf-autotable. In the hooks you are using pure jspdf and need to use jspdf methods. There are two functions that you are probably going to be helpful. The first one is doc.getStringUnitWidth("hello") and the second is doc.splitTextToSize("A longer title that might be split", 50).
Example 1:
var strArr = doc.splitTextToSize("A longer title that might be split", 50)
doc.text(strArr, 50, 50);
Example 2:
var str = "A longer title that /n is split";
doc.text(str, 50, 50);
I want to use chart.renderer.image to put a image on Yaxis. Please see this fiddle
Is there a easy way to put the image on Yaxis? For example I want to put the image on Yaxis [0,100]. It is very difficult to using the following way to do that.
chart.renderer.image('http://highcharts.com/demo/gfx/sun.png', 0, 10, 30, 30)
.add();
In this line:
chart.renderer.image('http://highcharts.com/demo/gfx/sun.png', 20, 50, 30, 30)
.add();
first two parameters are responsible for position (x,y). So you should modify it to position object in yAxis, like in the example: http://jsfiddle.net/F4qS8/701/
i'm hoping that this quick description and image will ring a bell with someone who has had a similar issue and therefore a suggestion/fix.
i have a column graph that i am adding data to dynamically (via jQuery parsing an XML file).
for some reason, after the data is added, the alignment of the different series gets a little off. the issue fixes itself after i toggle one of the series by being visible/invisible (by clicking the series in the legend).
when i add the data via hardcoding the numbers, just to ensure it works, it works great.
here is the image:
the yellow series is the last series added to the chart, the red and purple series line up ok after toggling the visibility of one of the 5 series.
any help would be greatly appreciated!
UPDATE with info on the data:
i have 5 series of data and 10 x-axis categories
i am building a multidimensional array of data as i parse the XML file
the array length is 5, with each of those 5 index's containing an array of length 10
this is what the array looks like after it has been populated with data:
index#: 0 value: 0,0,0,0,0,0,0,0,0,0
index#: 1 value: 180,210,0,0,0,0,0,0,180,210
index#: 2 value: 22,4,0,0,0,0,0,0,22,4
index#: 3 value: 0,0,0,0,0,0,0,0,0,0
index#: 4 value: 200,30,0,0,0,0,0,0,4,0
i am adding the data to the chart with the following JS code:
for (var c_ary_bs = 0; c_ary_bs < ary_bs_schedule_orig.length; c_ary_bs++) {
chart.series[c_ary_bs].setData(ary_bs_schedule_orig[c_ary_bs]);
}
hopefully that will help, thank you!
UPDATE 2, some more info
i've hard coded the data being added to the array, to help pinpoint the issue:
chart.series[0].setData([0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
chart.series[1].setData([180, 210, 0, 0, 0, 0, 0, 0, 180, 210]);
chart.series[2].setData([22, 4, 0, 0, 0, 0, 0, 0, 22, 4]);
chart.series[3].setData([0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
chart.series[4].setData([200, 30, 0, 0, 0, 0, 0, 0, 4, 0]);
alert('done')
when the alert fires, the graph columns are aligned properly, after I click "ok" to dismiss the alert, the alignment issue happens, as the previous image depicts.
I found an imperfect fix:
-setting the marginLeft of the chart to 70 alleviates the issue with the columns not aligning
-for some reason the y-axis title text is displaying over the y-axis ticks, so i am using the following to make it visible:
yAxis: {
title: {
x:-20,
text: 'Schedule Days'
}
}
(note the x: -20)
Whats's odd is that when I toggle one of the series (by clicking it in the legend) the yAxis title text reverts to where it should be (which is now 20px off because of the above fix).
The perfect fix would put the yAxis text where it is after I toggle one of the series, but at least this way it is now visible regardless of whether or not the user toggles the series.