Coder Social home page Coder Social logo

rajeshm20 / amcharts Goto Github PK

View Code? Open in Web Editor NEW

This project forked from chimpstudios/amcharts

0.0 2.0 0.0 16.45 MB

A Native Objective C wrapper for the AmCharts charting library. http://www.amcharts.com

License: MIT License

Objective-C 6.29% Ruby 0.10% JavaScript 88.90% HTML 3.56% CSS 1.15%

amcharts's Introduction

AmCharts

This is a Native Objective C wrapper for the AmCharts javascript charting library. Both OS X (10.9+) and iOS (7.1+) are supported.

Screenshot

AmCharts in Cocoa App

Getting Started

  1. Clone this repo
  2. In your project Add the freshly cloned 'AmChartsLibrary.xcodeproj' to your workspace. Adding an Existing Project to a Workspace

OS X

  1. Add a link to the AmCharts.framework by selecting your target > General Pane > Linked Frameworks and Libraries OS X Integration
  2. In "Build Phases" add the AmCharts.framework as a target dependency
  3. Add a new "Copy Files Build Phase"
  4. Set the destination to "Frameworks"
  5. Add the AmCharts.framework

You can now start generating charts in your app!

iOS

  1. Add a link to the libAmChartsMobile.a by selecting your target > General Pane > Linked Frameworks and Libraries
  2. Under "Build Settings" add -ObjC to "other linker flags"
  3. Under "Build Phases" add AmChartsMobile to the target dependencies
  4. Add a new "Copy Files Build Phase"
  5. Set Destination to "Resources" and add the "AmChartResources.bundle" iOS Integration

Generating Charts

Once the AmChart framework or library is included in your project. Generating a chart is very simple. Import the framework

#import <AmCharts/AmCharts.h>

if you are building an iOS app use this instead:

#import <AmChartsMobile/AmCharts.h>

Add an AmChartView (inherits from Webview) or AmMobileChartView (inherits from UIView) to your window.

Here are some examples of common charts.

Pie Chart
AmPieChart *pieChart = [[AmPieChart alloc] init];
pieChart.type = @"pie";
pieChart.theme = @"none";
NSMutableArray *dataProvider = [[NSMutableArray alloc] init];
[dataProvider addObject:@{@"country" : @"Lithuania", @"litres" : @(501.9)}];
[dataProvider addObject:@{@"country" : @"Czech Republic", @"litres" : @(301.9)}];
[dataProvider addObject:@{@"country" : @"Ireland", @"litres" : @(201.1)}];
pieChart.dataProvider = dataProvider;

pieChart.valueField = @"litres";
pieChart.titleField = @"country";

// where self.chartView references an AmChartView *
[self.chartView setChart:pieChart];
[self.chartView drawChart];

AmCharts in Cocoa App

Bar Chart

This code:

AmSerialChart *chart = [[AmSerialChart alloc] init];
chart.type = @"serial";
chart.dataProvider = [@[@{@"year" : @"2005", @"income" : @"23.5"},
                       @{@"year" : @"2006", @"income" : @"26.2"},
                        @{@"year" : @"2007", @"income" : @"30.1"},
                        @{@"year" : @"2008", @"income" : @"32.0"},
                        @{@"year" : @"2009", @"income" : @"31.6"},
                        @{@"year" : @"2010", @"income" : @"33.4"},
                        @{@"year" : @"2011", @"income" : @"34.3"},
                        @{@"year" : @"2012", @"income" : @"34.9"},
                        @{@"year" : @"2013", @"income" : @"35.7"}] mutableCopy];
chart.categoryField = @"year";
//chart.rotate = YES;
chart.categoryAxis.gridPosition = @"start";
chart.categoryAxis.axisColor = @"#DADADA";
AmValueAxis *valAxis = [[AmValueAxis alloc] init];
valAxis.axisAlpha = @(0.2);
chart.valueAxes = [@[valAxis] mutableCopy];
chart.balloon = nil;
AmGraph *graph = [[AmGraph alloc] init];
graph.type = @"column";
graph.title = @"Income";
graph.valueField = @"income";
graph.lineAlpha = @(0);
graph.fillColors = @"#ADD981";
graph.fillAlphas = @(0.8);
graph.balloonText = @"[[title]] in [[category]]:<b>[[value]]</b>";
chart.graphs = [@[graph] mutableCopy];

[self.chartView setChart:chart];
[self.chartView drawChart];

produces this bar chart: AmCharts in Cocoa App

World Map

This code:

AmMap *map = [[AmMap alloc] init];
map.type = @"map";
map.theme = @"none";
map.pathToImages = @"ammap/images/";

AmMapData *mapData = [[AmMapData alloc] init];
mapData.map = @"worldLow";
mapData.getAreasFromMap = true;

map.mapDataProvider = mapData;

AmAreasSettings *areaSettings = [[AmAreasSettings alloc] init];
areaSettings.autoZoom = true;
areaSettings.selectedColor = @"#CC0000";

AmSmallMap *smallMap = [[AmSmallMap alloc] init];

map.smallMap = smallMap;

[self.chartView setChart:map];
[self.chartView drawChart];

produces this map: AmCharts in Cocoa App

Questions

This repo contains both a Mac and iOS example app. You can check how they are set up to make sure that your own project is configured properly. The AmChart website has extensive documentation as well as numerous tutorials. If you find a bug in this wrapper library, send me a pull request with a fix, or at the very least do some detective work first before opening up an issue.

Legal

The source for AmChartsLibrary (the objective-c wrapper) is released under the MIT license. The original AmCharts javascript core is maintained under a separate license. Check http://www.amcharts.com/online-store/ for further information.

amcharts's People

Contributors

andrewschenk avatar

Watchers

 avatar  avatar

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.