Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions TreeMapSample.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.168
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TreeMapSample", "TreeMapSample\TreeMapSample.csproj", "{E06A90FC-6A36-4580-96E9-4A838E82FF2D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E06A90FC-6A36-4580-96E9-4A838E82FF2D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E06A90FC-6A36-4580-96E9-4A838E82FF2D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E06A90FC-6A36-4580-96E9-4A838E82FF2D}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{E06A90FC-6A36-4580-96E9-4A838E82FF2D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E06A90FC-6A36-4580-96E9-4A838E82FF2D}.Release|Any CPU.Build.0 = Release|Any CPU
{E06A90FC-6A36-4580-96E9-4A838E82FF2D}.Release|Any CPU.Deploy.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4280D5F1-DED4-4307-A12C-77F6DE1FB00E}
EndGlobalSection
EndGlobal
19 changes: 19 additions & 0 deletions TreeMapSample/Assets/AboutAssets.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Any raw assets you want to be deployed with your application can be placed in
this directory (and child directories) and given a Build Action of "AndroidAsset".

These files will be deployed with you package and will be accessible using Android's
AssetManager, like this:

public class ReadAsset : Activity
{
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);

InputStream input = Assets.Open ("my_asset.txt");
}
}

Additionally, some Android functions will automatically load asset files:

Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf");
116 changes: 116 additions & 0 deletions TreeMapSample/MainActivity.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
using Android.App;
using Android.OS;
using Android.Support.V7.App;
using Android.Runtime;
using Android.Widget;
using Org.Json;
using Com.Syncfusion.Treemap;
using Android.Graphics;

namespace TreeMapSample
{
[Activity(Label = "@string/app_name", Theme = "@style/AppTheme", MainLauncher = true)]
public class MainActivity : AppCompatActivity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);

SfTreeMap treeMap = new SfTreeMap(this);
treeMap.ColorValuePath = "Growth";
treeMap.WeightValuePath = "Population";
treeMap.LayoutType = Com.Syncfusion.Treemap.Enums.LayoutType.Squarified;
treeMap.ShowTooltip = true;

LeafItemSetting leafItemSetting = new LeafItemSetting();
leafItemSetting.ShowLabels = true;
leafItemSetting.Gap = 2;
leafItemSetting.LabelPath = "Country";
treeMap.LeafItemSettings = leafItemSetting;

TreeMapFlatLevel flatLevel = new TreeMapFlatLevel();
flatLevel.HeaderHeight = 20;
flatLevel.GroupPath = "Continent";
flatLevel.GroupGap = 5;
flatLevel.ShowHeader = true;
flatLevel.GroupStrokeColor = Color.Gray;
flatLevel.GroupStrokeWidth = 1;
flatLevel.HeaderStyle = new Style() { TextColor = Color.Black };
treeMap.Levels.Add(flatLevel);

LegendSetting legendSettings = new LegendSetting();
legendSettings.ShowLegend = true;
legendSettings.LegendSize = new Size(700, 45);
legendSettings.LabelStyle = new Style() { TextColor = Color.Black };
treeMap.LegendSettings = legendSettings;

RangeColorMapping rangeColorMapping = new RangeColorMapping();

Range range1 = new Range();
range1.From = 0;
range1.To = 1;
range1.Color = Color.ParseColor("#77D8D8");
range1.LegendLabel = "1 % Growth";

Range range2 = new Range();
range2.From = 0;
range2.To = 2;
range2.Color = Color.ParseColor("#AED960");
range2.LegendLabel = "2 % Growth";

Range range3 = new Range();
range3.From = 0;
range3.To = 3;
range3.Color = Color.ParseColor("#FFAF51");
range3.LegendLabel = "3 % Growth";

Range range4 = new Range();
range4.From = 0;
range4.To = 4;
range4.Color = Color.ParseColor("#F3D240");
range4.LegendLabel = "4 % Growth";

rangeColorMapping.Ranges.Add(range1);
rangeColorMapping.Ranges.Add(range2);
rangeColorMapping.Ranges.Add(range3);
rangeColorMapping.Ranges.Add(range4);

treeMap.LeafItemColorMapping = rangeColorMapping;
treeMap.DataSource = GetDataSource();

SetContentView(treeMap);
}

JSONArray GetDataSource()
{
JSONArray array = new JSONArray();
array.Put(getJsonObject("Asia", "Indonesia", 3, 237641326));
array.Put(getJsonObject("Asia", "Russia", 2, 152518015));
array.Put(getJsonObject("North America", "United States", 4, 315645000));
array.Put(getJsonObject("North America", "Mexico", 2, 112336538));
array.Put(getJsonObject("North America", "Canada", 1, 35056064));
array.Put(getJsonObject("South America", "Colombia", 1, 47000000));
array.Put(getJsonObject("South America", "Brazil", 3, 193946886));
array.Put(getJsonObject("Africa", "Nigeria", 2, 170901000));
array.Put(getJsonObject("Africa", "Egypt", 1, 83661000));
array.Put(getJsonObject("Europe", "Germany", 1, 81993000));
array.Put(getJsonObject("Europe", "France", 1, 65605000));
array.Put(getJsonObject("Europe", "UK", 1, 63181775));

return array;
}

JSONObject getJsonObject(string continent, string country, double growth, double population)
{
JSONObject obj = new JSONObject();

obj.Put("Continent", continent);
obj.Put("Country", country);
obj.Put("Growth", growth);
obj.Put("Population", population);

return obj;
}

}
}
9 changes: 9 additions & 0 deletions TreeMapSample/Properties/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="1"
android:versionName="1.0"
package="TreeMapSample.TreeMapSample">
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="27" />
<application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme">
</application>
</manifest>
30 changes: 30 additions & 0 deletions TreeMapSample/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Android.App;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("TreeMapSample")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("TreeMapSample")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
44 changes: 44 additions & 0 deletions TreeMapSample/Resources/AboutResources.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
Images, layout descriptions, binary blobs and string dictionaries can be included
in your application as resource files. Various Android APIs are designed to
operate on the resource IDs instead of dealing with images, strings or binary blobs
directly.

For example, a sample Android app that contains a user interface layout (main.axml),
an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png)
would keep its resources in the "Resources" directory of the application:

Resources/
drawable/
icon.png

layout/
main.axml

values/
strings.xml

In order to get the build system to recognize Android resources, set the build action to
"AndroidResource". The native Android APIs do not operate directly with filenames, but
instead operate on resource IDs. When you compile an Android application that uses resources,
the build system will package the resources for distribution and generate a class called "R"
(this is an Android convention) that contains the tokens for each one of the resources
included. For example, for the above Resources layout, this is what the R class would expose:

public class R {
public class drawable {
public const int icon = 0x123;
}

public class layout {
public const int main = 0x456;
}

public class strings {
public const int first_string = 0xabc;
public const int second_string = 0xbcd;
}
}

You would then use R.drawable.icon to reference the drawable/icon.png file, or R.layout.main
to reference the layout/main.axml file, or R.strings.first_string to reference the first
string in the dictionary file values/strings.xml.
Loading