Giter VIP home page Giter VIP logo

androidheatmap's Introduction

Release Method Count API Apache 2

AndroidHeatMap

AndroidHeatMap is an easy to use heat map control for Android apps.

Example View

Installation

There are three different ways to use this library:

1. Gradle dependency (recommended)

  • Add the following to your project level build.gradle:
allprojects {
	repositories {
		maven { url "https://jitpack.io" }
	}
}
  • Add this to your app build.gradle:
dependencies {
	compile 'ca.heartlandsoftware:androidheatmap:1.0'
}

2. Maven

  • Add the following to the <repositories> section of your pom.xml:
<repository>
	<id>jitpack.io</id>
	<url>https://jitpack.io</url>
</repository>
  • Add the following to the <dependencies> section of your pom.xml:
<dependency>
	<groupId>ca.heartlandsoftware</groupId>
	<artifactId>androidheatmap</artifactId>
	<version>1.0</version>
</dependency>

3. Clone the whole repository

  • Open your commandline-input and navigate to the desired destination folder on your machine (where you want to place the library)
  • Use the command git clone https://github.com/HeartlandSoftware/AndroidHeatMap.git to download the full AndroidHeatMap repository to your computer (this includes the folder of the library as well as the folder of the example project)
  • Import the library folder (AndroidHeatMap) into Android Studio (recommended) or your Eclipse workspace
  • Add it as a reference to your project:

Getting Started

Add a HeatMap control to your xml layout.

<ca.hss.heatmaplib.HeatMap
    android:id="@+id/heatmap"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:minOpacity="0"
    app:maxOpacity="255" />

Back in your activity or fragment you would get a reference to the BottomSheetLayout like any other view.

HeatMap heatMap = (HeatMap) findViewById(R.id.heatmap);

Set the range that you want the heat maps gradient to cover.

heatMap.setMinimum(0.0);
heatMap.setMaximum(100.0);

Now you can add data to the heat map.

//add random data to the map
Random rand = new Random();
for (int i = 0; i < 20; i++) {
    HeatMap.DataPoint point = new HeatMap.DataPoint(rand.nextFloat(), rand.nextFloat(), rand.nextDouble() * 100.0);
    heatMap.addData(point);
}

Options

Colour Gradient

Changing the colour gradient.

//make the colour gradient from pink to yellow
Map<Float, Integer> colorStops = new ArrayMap<>();
colors.put(0.0f, 0xffee42f4);
colors.put(1.0f, 0xffeef442);
heatMap.setColorStops(colors);

Opacity

Set the minimum and maximum opacity of the heat map. The value is an 2 byte alpha value with the range [0,255].

//make the minimum opacity completely transparent
heatMap.setMinimumOpactity(0);
//make the maximum opacity 50% transparent
heatMap.setMaximumOpacity(127);

Or set it in xml.

<ca.hss.heatmaplib.HeatMap
    app:minOpacity="0"
    app:maxOpacity="255" />

Radius

Set the radius of each points coloured gradient.

//set the radius to 300 pixels.
heatMap.setRadius(300);

Or in xml.

<ca.hss.heatmaplib.HeatMap
    app:radius="100dp" />

Refresh

After changing an option after the heat map has been rendered force a refresh.

heatMap.forceRefresh();

License

Copyright 2016 Heartland Software Solutions Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.