Coder Social home page Coder Social logo

anychart / anychart-android Goto Github PK

View Code? Open in Web Editor NEW
2.2K 45.0 367.0 52.71 MB

AnyChart Android Chart is an amazing data visualization library for easily creating interactive charts in Android apps. It runs on API 19+ (Android 4.4) and features dozens of built-in chart types.

Java 99.98% Shell 0.02%
android-library android-development android-ui android-chart data-visualization charts chart android-component chart-component chart-library

anychart-android's Introduction

AnyChart - Robust JavaScript/HTML5 Chart library for any project AnyChart Travis Build AnyChart NPM Version AnyChart Releases AnyChart Download

AnyChart Data Visualization Framework

AnyChart is a flexible JavaScript (HTML5, SVG, VML) charting framework that fits any solution in need of data visualization.

Table of Contents

Download and install

There are several ways to download/install AnyChart.

Direct download

All binaries are located in dist folder.

CDN

If you don't want to download and host AnyChart yourself, you can include it from the AnyChart CDN (Content Delivery Network): https://www.anychart.com/download/cdn

<head>
<script src="https://cdn.anychart.com/releases/v8/js/anychart-base.min.js"></script>
</head>

Package managers

You can install AnyChart using npm, bower or yarn:

  • npm install anychart
  • bower install anychart
  • yarn add anychart

Getting started

The fastest way to start with AnyChart is to include framework into a webpage and write some code. Look at this simple HTML snippet below:

<!doctype html>
<body>
<div id="container" style="width: 500px; height: 400px;"></div>
<script src="https://cdn.anychart.com/releases/v8/js/anychart-base.min.js" type="text/javascript"></script>
<script>
    anychart.onDocumentReady(function() {
        // create a pie chart
        var chart = anychart.pie([
            ["Chocolate", 5],
            ["Rhubarb compote", 2],
            ["Crêpe Suzette", 2],
            ["American blueberry", 2],
            ["Buttermilk", 1]
        ]);
        chart.title("Top 5 pancake fillings");
        // set the container where chart will be drawn
        chart.container("container");
        //  draw the chart on the page
        chart.draw();
    });
</script>
</body>
</html>

Step by step quick start guides

Plugins

AnyChart provides wide variety of plugins for different kind of technologies, which includes:

Using AnyChart with TypeScript

You can use AnyChart in your TypeScript projects - we have definition file for our library which you can find in distribution folder. Please, take a look at webpack and typescript integration example for more details.

Using AnyChart with ECMAScript 6

You can use AnyChart in your ECMAScript 6 projects over two ways:

Plain ECMAScript 6

To add AnyChart on a page use <script> section with type="module" attribute.

<script type="module">
    import '_localpath_to_anychart/anychart-bundle.min.js'
    
    // regular AnyChart code here
</script>

For more details, take a look at AnyChart ES6 example.

Bundling tools and Module Loaders

You can use AnyChart with any bundling tool or module loader such as WebPack, Browserify, Require.js and others. For more details, take a look at AnyChart Webpack example.

Technical Integrations

AnyChart can run on any platform and with any database. These samples were created to demonstrate how AnyChart can be easily integrated into your environment. All examples are distributed under an Apache 2.0 License and can be customized to your application. If you are interested in a particular integration not listed here, please contact us.

ASP.NET, C# and MySQL ASP.NET, VB.NET and MySQL ASP.NET, C#, SignalR and MySQL
Go, Revel and MySQL Go and MySQL Java Servlets, Maven, JDBC, JSP and MySQL
NodeJS and MongoDB using socket.io Java Spring, Maven, Hibernate and MySQL Julia and MySQL
NodeJS Express, Jade and MongoDB PHP, Symfony and MySQL PHP, Laravel and MySQL
PHP, Slim and MySQL Perl, Catalyst Web Framework and MySQL Python, Flask and MySQL
Python, Django and MySQL R, Shiny and MySQL Ruby, Sinatra and MySQL
Ruby on Rails and MySQL Scala, Akka and MySQL Scala, Play and MySQL

Contribution guide

To contribute to AnyChart project please:

  • Fork AnyChart repository.
  • Create a branch from the develop branch.
  • Make any changes you want to contribute.
  • Create a pull request against the develop branch.

GitHub documentation: Forking repositories.
GitHub documentation: Collaborating using pull requests.

Please, note:

  1. AnyChart bears no responsibility for the code written by third-party developers until pull request is accepted.
  2. After pull request is accepted the author of pull request sign over all rights to the code to AnyChart.

Build and debug

Dependencies

AnyChart uses several third-party libraries and tools to work with JavaScript and CSS.

Building options

build.py python script is used to work with AnyChart project. You need to install python to use it.

To see all available options of the build script use -h or --help command:

./build.py -h.

To see command options use:

./build.py <command_name> -h

To install all dependencies use the deps command:

./build.py deps.

After running this command you can compile the project using the compile command:

./build.py compile

This compiles production version of anychart-bundle and all modules and puts them into the out folder. You can read more about modules in our Modules article.

To create a dev build for the debug purposes use -d or --develop option:

./build.py compile -d

The -df option generates property renaming report, variable renaming report, and source map location mapping files:

./build.py compile -df

Source map maps minified code to source code. Read more about using source maps in Chrome or source maps in Firefox.

Module system

AnyChart since v8.0.0 is structured as a modules, so you can use only what you need. Please look at our article Modules to start working with modules.

Package directory

├── css
│   ├── anychart.less
│   ...
├── dist
│   ├── json-schema.json
│   ├── xml-schema.xsd
│       ...
├── src
│   ├── charts
│   ├── core
│   ├── modules
│   ├── themes
│       ...
│   README.md
│   LICENSE
│   ...

css

The css folder contains .less CSS files that are compiled into one .css file.

src

The src folder contains AnyChart source code files organized according to the project structure. For example:

  • charts subfolder contains chart classes
  • core subfolder contains core classes
  • modules subfolder contains modules
  • themes contains themes

dist

The dist folder contains binaries and JSON/XML Schemas.

Contacts

Links

License

© AnyChart.com - JavaScript charts. All rights reserved.

anychart-android's People

Contributors

aldiand avatar arsenymalkov avatar loki20beta avatar romanlubushkin avatar vivektilva avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

anychart-android's Issues

Map loading is very slow for Choropleth Map.

I am drawing India's map in here. But the map drawing is really slow. The data is a lot (like 1200 models).
But after the models are added the map takes about 5 minutes to display on the screen.

What could be the reason?
Is there a way to make it faster?

Logo Design Offer as Open Source Contribution

Hello Sir. I'm a Graphics Designer. I want provide a logo for you. Would you mind if I propose a new logo design for your application as my Open Source Contribution?

Thanks before.

Can not see negative bar in WaterFall chart

I am using Waterfall chart and its works perfectly when I pass first and last column data as positive value.
When I pass First column data as negative value it does not show bar for that particulars.

Is there any way to display bar for negative values in negative Y axis or starts Y axis value from largest negative number in graph data?
Example data: -90, 120, 30, -20, 40

Vertical Chart misses few labels.

Hi ,
I am using vertical chart from your library. When data is about 20 a few labels are missed on Y-axis.
Is there a way to resolve this issue?
Thanks.
screenshot_20180703_141900

Regarding polar chart !

Hi,

i have seen your library and i want to use polar chart , i want to make a polar chart like below in screenshot , can i customize your polar chart as y0u can see in the screenshot.

  1. can i set random color for each arc in the circle as now all in blue color.
  2. progress of a particular section in percentage - as you can see in the image below , like if i have 40 % then my arc will be filled 40% .

Please see my requirement
brush- 1

Cannot show the chart

Among the five mobile phones, one of them can't display the pie clearly.
The content is as follows:

Mobile info:

Not able to implement onClick for line chart.

I am trying to set customise the tooltip and set some info on it. But for some reason it does not work.

cartesian.setOnClickListener(new ListenersInterface.OnClickListener(new String[]{"x", "value"}) {
        @Override
        public void onClick(Event event) {

            Log.e("Route", "Graphs Clicked "+ event.getData().get("x") + " "+ event.getData().get("value"));

            Toast.makeText(RouteMapperActivity.this, event.getData().get("x") + ":" + event.getData().get("value"), Toast.LENGTH_SHORT).show();
            cartesian.getTooltip().setTitle("Date : " );
            cartesian.getTooltip().setFormat("Speed : ");
            setToolTip();

        }
    });

the log is printing but nothing happens to the tooltip.

How to change Waterfall Chart bar fill color.

I want to set custom color into waterfall chart start, end, raise and fall bar. I could not find a way to set color to bar and in legend.
Need your help to set custom color in chart.

Thanking you.

Chart not working on background thread.

I get data to be displayed in the ChartView from a remote source on a new thread.

But whenever it reaches runOnUiThread(() -> anyChartView.setChart(cartesian));

I get the error Uncaught ReferenceError: cartesian1 is not defined

But when I load information on the main thread, the chart works well.
I can't do this on the main thread , It's going to slow down the UI.

Realtime linechart?

I want to update my line chart every 1 minute wit a few new values, how can i do that?

merger conflict

Error:Execution failed for task ':app:processDebugManifest'.

Manifest merger failed : Attribute application@name value=(com.crm.volley.AppController) from AndroidManifest.xml:22:9-45
is also present at [com.github.AnyChart:AnyChart-Android:0.1.0] AndroidManifest.xml:12:9-71 value=(com.anychart.anychart.application.MyApplication).
Suggestion: add 'tools:replace="android:name"' to element at AndroidManifest.xml:21:5-322:19 to override.

I tried to add tools:replace but it is not working ...

Can u suggest any solution? @Shestac92 @ArsenyMalkov

Getting started uses methods that do not exist

Hi there! I'm a new user of AnyChart, so logically I stared with... the Getting Started.

The method Pie::setData() does not exist. It appears to be Pie::data(), which I had to guess because there isn't any javadoc:

image

Am I missing something or is it just that the method signature changed over versions? Sorry about the bitter issue but I think these things are pretty relevant to get users working with your package.

E/TEST: Uncaught ReferenceError: pareto32 is not defined

I am trying to display 3 charts on single fragment like below code. But only one chart (3rd) is getting displayed and for first two charts it giving me error

E/TEST: Uncaught ReferenceError: circularGauge1 is not defined E/TEST: Uncaught ReferenceError: pareto32 is not defined

My fragment ->

     @Override
public void onViewCreated(final View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    setTypeWiseOrderChart();
    setCustomerWiseOrderChart();
    setStatusWiseOrderChart();


}                                                                                                                                                         
     private void setTypeWiseOrderChart(){

    AnyChartView typeWiseOrderChartView = (AnyChartView) getView().findViewById(R.id.type_wise_order_chart_view);

    CircularGauge circularGauge = AnyChart.circular();
    circularGauge.data(new SingleValueDataSet(new String[] { "23", "34", "67", "93", "56", "100"}));
    circularGauge.fill("#fff")
            .stroke(null)
            .padding(0d, 0d, 0d, 0d)
            .margin(100d, 100d, 100d, 100d);
    circularGauge.startAngle(0d);
    circularGauge.sweepAngle(270d);

    Circular xAxis = circularGauge.axis(0)
            .radius(100d)
            .width(1d)
            .fill((Fill) null);
    xAxis.scale()
            .minimum(0d)
            .maximum(100d);
    xAxis.ticks("{ interval: 1 }")
            .minorTicks("{ interval: 1 }");
    xAxis.labels().enabled(false);
    xAxis.ticks().enabled(false);
    xAxis.minorTicks().enabled(false);

    circularGauge.label(0d)
            .text("Temazepam, <span style=\"\">32%</span>")
            .useHtml(true)
            .hAlign(HAlign.CENTER)
            .vAlign(VAlign.MIDDLE);
    circularGauge.label(0d)
            .anchor(Anchor.RIGHT_CENTER)
            .padding(0d, 10d, 0d, 0d)
            .height(17d / 2d + "%")
            .offsetY(100d + "%")
            .offsetX(0d);
    Bar bar0 = circularGauge.bar(0d);
    bar0.dataIndex(0d);
    bar0.radius(100d);
    bar0.width(17d);
    bar0.fill(new SolidFill("#64b5f6", 1d));
    bar0.stroke(null);
    bar0.zIndex(5d);
    Bar bar100 = circularGauge.bar(100d);
    bar100.dataIndex(5d);
    bar100.radius(100d);
    bar100.width(17d);
    bar100.fill(new SolidFill("#F5F4F4", 1d));
    bar100.stroke("1 #e5e4e4");
    bar100.zIndex(4d);

    circularGauge.label(1d)
            .text("Guaifenesin, <span style=\"\">34%</span>")
            .useHtml(true)
            .hAlign(HAlign.CENTER)
            .vAlign(VAlign.MIDDLE);
    circularGauge.label(1d)
            .anchor(Anchor.RIGHT_CENTER)
            .padding(0d, 10d, 0d, 0d)
            .height(17d / 2d + "%")
            .offsetY(80d + "%")
            .offsetX(0d);
    Bar bar1 = circularGauge.bar(1d);
    bar1.dataIndex(1d);
    bar1.radius(80d);
    bar1.width(17d);
    bar1.fill(new SolidFill("#1976d2", 1d));
    bar1.stroke(null);
    bar1.zIndex(5d);
    Bar bar101 = circularGauge.bar(101d);
    bar101.dataIndex(5d);
    bar101.radius(80d);
    bar101.width(17d);
    bar101.fill(new SolidFill("#F5F4F4", 1d));
    bar101.stroke("1 #e5e4e4");
    bar101.zIndex(4d);

    circularGauge.label(2d)
            .text("Salicylic Acid, <span style=\"\">67%</span>")
            .useHtml(true)
            .hAlign(HAlign.CENTER)
            .vAlign(VAlign.MIDDLE);
    circularGauge.label(2d)
            .anchor(Anchor.RIGHT_CENTER)
            .padding(0d, 10d, 0d, 0d)
            .height(17d / 2d + "%")
            .offsetY(60d + "%")
            .offsetX(0d);
    Bar bar2 = circularGauge.bar(2d);
    bar2.dataIndex(2d);
    bar2.radius(60d);
    bar2.width(17d);
    bar2.fill(new SolidFill("#ef6c00", 1d));
    bar2.stroke(null);
    bar2.zIndex(5d);
    Bar bar102 = circularGauge.bar(102d);
    bar102.dataIndex(5d);
    bar102.radius(60d);
    bar102.width(17d);
    bar102.fill(new SolidFill("#F5F4F4", 1d));
    bar102.stroke("1 #e5e4e4");
    bar102.zIndex(4d);

    circularGauge.label(3d)
            .text("Fluoride, <span style=\"\">93%</span>")
            .useHtml(true)
            .hAlign(HAlign.CENTER)
            .vAlign(VAlign.MIDDLE);
    circularGauge.label(3d)
            .anchor(Anchor.RIGHT_CENTER)
            .padding(0d, 10d, 0d, 0d)
            .height(17d / 2d + "%")
            .offsetY(40d + "%")
            .offsetX(0d);
    Bar bar3 = circularGauge.bar(3d);
    bar3.dataIndex(3d);
    bar3.radius(40d);
    bar3.width(17d);
    bar3.fill(new SolidFill("#ffd54f", 1d));
    bar3.stroke(null);
    bar3.zIndex(5d);
    Bar bar103 = circularGauge.bar(103d);
    bar103.dataIndex(5d);
    bar103.radius(40d);
    bar103.width(17d);
    bar103.fill(new SolidFill("#F5F4F4", 1d));
    bar103.stroke("1 #e5e4e4");
    bar103.zIndex(4d);

    circularGauge.label(4d)
            .text("Zinc Oxide, <span style=\"\">56%</span>")
            .useHtml(true)
            .hAlign(HAlign.CENTER)
            .vAlign(VAlign.MIDDLE);
    circularGauge.label(4d)
            .anchor(Anchor.RIGHT_CENTER)
            .padding(0d, 10d, 0d, 0d)
            .height(17d / 2d + "%")
            .offsetY(20d + "%")
            .offsetX(0d);
    Bar bar4 = circularGauge.bar(4d);
    bar4.dataIndex(4d);
    bar4.radius(20d);
    bar4.width(17d);
    bar4.fill(new SolidFill("#455a64", 1d));
    bar4.stroke(null);
    bar4.zIndex(5d);
    Bar bar104 = circularGauge.bar(104d);
    bar104.dataIndex(5d);
    bar104.radius(20d);
    bar104.width(17d);
    bar104.fill(new SolidFill("#F5F4F4", 1d));
    bar104.stroke("1 #e5e4e4");
    bar104.zIndex(4d);

    circularGauge.margin(50d, 50d, 50d, 50d);
    circularGauge.title()
            .text("Medicine manufacturing progress' +\n" +
                    "    '<br/><span style=\"color:#929292; font-size: 12px;\">(ACME CORPORATION)</span>")
            .useHtml(true);
    circularGauge.title().enabled(true);
    circularGauge.title().hAlign(HAlign.CENTER);
    circularGauge.title()
            .padding(0d, 0d, 0d, 0d)
            .margin(0d, 0d, 20d, 0d);

    typeWiseOrderChartView.setChart(circularGauge);
}

private void setCustomerWiseOrderChart(){

    AnyChartView customerWiseOrderChartView = (AnyChartView) getView().findViewById(R.id.customer_wise_order_chart_view);

    Pareto pareto = AnyChart.pareto();

    List<DataEntry> data = new ArrayList<>();

    data.add(new ValueDataEntry("Food is tasteless", 65));
    data.add(new ValueDataEntry("Wait time", 109));
    data.add(new ValueDataEntry("Unfriendly staff", 12.5));
    data.add(new ValueDataEntry("Not clean", 45));
    data.add(new ValueDataEntry("Overpriced", 250));
    data.add(new ValueDataEntry("To noisy", 27));
    data.add(new ValueDataEntry("Food not fresh", 35));
    data.add(new ValueDataEntry("Small portions", 170));
    data.add(new ValueDataEntry("Not atmosphere", 35));
    data.add(new ValueDataEntry("Food is to salty", 35));

    pareto.data(data);

    pareto.title("Pareto Chart of Restaurant Complaints");

    pareto.yAxis(0d).title("Defect frequency");

    pareto.yAxis(1d).title("Cumulative Percentage");

    pareto.animation(true);

    pareto.lineMarker(0)
            .value(80d)
            .axis(pareto.yAxis(1d))
            .stroke("#A5B3B3", 1d, "5 2", StrokeLineJoin.ROUND, StrokeLineCap.ROUND);

    pareto.getSeries(0d).tooltip().format("Value: {%Value}");

    Base line = pareto.getSeries(1d);
    line.seriesType("spline")
            .markers(true);
    line.labels().enabled(true);
    line.labels()
            .anchor(Anchor.RIGHT_BOTTOM)
            .format("{%CF}%");
    line.tooltip().format("Cumulative Frequency: {%CF}% \\n Relative Frequency: {%RF}%");

    pareto.crosshair().enabled(true);
    pareto.crosshair().xLabel(true);

    customerWiseOrderChartView.setChart(pareto);
}

private void setStatusWiseOrderChart(){
    AnyChartView statusWiseOrderChartView = (AnyChartView) getView().findViewById(R.id.status_wise_order_chart_view);

    Pie pie = AnyChart.pie();

    pie.setOnClickListener(new ListenersInterface.OnClickListener(new String[]{"x", "value"}) {
        @Override
        public void onClick(Event event) {
            Toast.makeText(getActivity(), event.getData().get("x") + ":" + event.getData().get("value"), Toast.LENGTH_SHORT).show();
        }
    });

    List<DataEntry> data = new ArrayList<>();
    data.add(new ValueDataEntry("Apples", 6371664));
    data.add(new ValueDataEntry("Pears", 789622));
    data.add(new ValueDataEntry("Bananas", 7216301));
    data.add(new ValueDataEntry("Grapes", 1486621));
    data.add(new ValueDataEntry("Oranges", 1200000));

    pie.data(data);

    pie.title("Fruits imported in 2015 (in kg)");

    pie.labels().position("outside");

    pie.legend().title().enabled(true);
    pie.legend().title()
            .text("Retail channels")
            .padding(0d, 0d, 10d, 0d);

    pie.legend()
            .position("center-bottom")
            .itemsLayout(LegendLayout.HORIZONTAL)
            .align(Align.CENTER);

    statusWiseOrderChartView.setChart(pie);
}`

My fragment view ->

`<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".views.OrdersPlacedFragment"
android:background="@color/colorWhite">

    <com.anychart.AnyChartView
        android:id="@+id/type_wise_order_chart_view"
        android:layout_width="match_parent"
        android:layout_height="300dp"
        />

    <com.anychart.AnyChartView
        android:id="@+id/customer_wise_order_chart_view"
        android:layout_width="match_parent"
        android:layout_height="300dp"
        />

    <com.anychart.AnyChartView
        android:id="@+id/status_wise_order_chart_view"
        android:layout_width="match_parent"
        android:layout_height="300dp"
        />

</LinearLayout></androidx.core.widget.NestedScrollView>`

Error Synching Gradle

Failed to resolve: com.github.AnyChart:AnyChart-Android:0.3.0

Below is my Module:app build.gradle file

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.anychart.charts"
        minSdkVersion 17
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.github.AnyChart:AnyChart-Android:0.3.0'
}

Licensing

@Shestac92

Thank you so much for your all support,
I have one query ,

I just want to use this funnel chart in my app and want to publish this app to play store,
Do I need to buy paid version or free version will work ???

Set Dynamic Color for Each Column

How can I set the dynamic color for each column?

val barChart = AnyChart.column(); 
val list = mutableListOf<DataEntry>();
list.add(ValueDataEntry("Subrat",1000));
list.add(ValueDataEntry("Nawin",12000));
list.add(ValueDataEntry("Sujin",18000))
barChart.setData(list);
this.binding.anyChartView.setChart(barChart);

Suppose if I the value(x) 0 < x < 1000 , I want to set the yellow color. And if the value(x) is
1000 < x < 2000 then I want to set the blue color.

Multi-Level Categories

Is it possible to implement multi-level categories for a column chart? I noticed this blog post which gives an example in JS, but I haven't been able to find anything for Android/Java.

Specifically, I'd like to group data by week (subcategory) per month (category).

Thanks!

Two polar charts in one activity and data should be changed dynamically

Hi!
My task is to show two polar charts in one activity and it is needed to change data dynamically ( in real time).I tried to write my code similar to these examples:

#41
https://gist.github.com/ArsenyMalkov/4f13aca9bdde09abd6547b2fde5bede6
https://github.com/AnyChart/AnyChart-Android/blob/master/sample/src/main/java/com/anychart/sample/charts/PolarChartActivity.java

Data chagnes dynamically when i have only one chart in activity.
Two charts are in activity when I don't change data in real time.
Is there any possible solution? Is it possible to have two dynamically changing polar charts in one activity? My code is below:
Thanks in advance

public class MainActivity extends AppCompatActivity {
    Set set;
    Set set2;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        AnyChartView polarChart = findViewById(R.id.polar_chart);
        APIlib.getInstance().setActiveAnyChartView(polarChart);

        List<DataEntry> data = new ArrayList<>();
        data.add(new ValueDataEntry("0", new Random().nextDouble() * 140d));
        data.add(new ValueDataEntry("1", new Random().nextDouble() * 140d));
        data.add(new ValueDataEntry("2", new Random().nextDouble() * 140d));
        data.add(new ValueDataEntry("3", new Random().nextDouble() * 140d));

        set = Set.instantiate();
        set.data(data);
        Mapping series = set.mapAs("{ x: 'x', value: 'value' }");

        polarChart.setChart(setPolar(series));

        AnyChartView polarChart2 = findViewById(R.id.polar_chart2);
        APIlib.getInstance().setActiveAnyChartView(polarChart2);

        set2 = Set.instantiate();
        set2.data(data);
        Mapping series2 = set2.mapAs("{ x: 'x', value: 'value' }");

        polarChart2.setChart(setPolar(series2));

        final int delayMillis = 500;
        final Handler handler = new Handler();
        final Runnable runnable = new Runnable() {
            public void run() {
                List<DataEntry> data = new ArrayList<>();
                data.add(new ValueDataEntry("0", new Random().nextDouble() * 140d));
                data.add(new ValueDataEntry("1", new Random().nextDouble() * 140d));
                data.add(new ValueDataEntry("2", new Random().nextDouble() * 140d));
                data.add(new ValueDataEntry("3", new Random().nextDouble() * 140d));
                set.data(data);
                set2.data(data);
                handler.postDelayed(this, delayMillis);
            }
        };
        handler.postDelayed(runnable, delayMillis);
    }
    private Polar setPolar(Mapping series){
        Polar polar = AnyChart.polar();

        polar.column(series);

        polar.title("Polar");

        polar.sortPointsByX(true)
                .defaultSeriesType(PolarSeriesType.COLUMN)
                .yAxis(false)
                .xScale(ScaleTypes.ORDINAL);

        polar.title().margin().bottom(20d);

        ((Linear) polar.yScale(Linear.class)).stackMode(ScaleStackMode.VALUE);

        polar.tooltip()
                .valuePrefix("$")
                .displayMode(TooltipDisplayMode.UNION);

        return polar;
    }
}

tag cload font

20180806_135037

hi
I have a problem when I change the font to Persian

please help me

Line chart in Android caused a problem

E/TEST: Uncaught SyntaxError: missing ) after argument list

E/TEST: cartesian1 = anychart.line();cartesian1.animation(true);cartesian1.padding(10.0, 20.0, 5.0, 20.0);crosshair2 = cartesian1.crosshair();crosshair2.enabled(true);crosshair3 = cartesian1.crosshair();crosshair3.yLabel(true);crosshair3.yStroke(null, null, null, null, null);tooltip4 = cartesian1.tooltip();tooltip4.positionMode("point");cartesian1.title('SEMESTER-WISE GRADE POINT AVERAGE');linear5 = cartesian1.yAxis(0);linear5.title('SGPA');linear6 = cartesian1.xAxis(0);labelsFactory7 = linear6.labels();labelsFactory7.padding(5.0, 5.0, 5.0, 5.0);set8 = new anychart.data.set();set8.data([{value2: '8.0',x: '1',value: '9.4',value3: '10.0'},{value2: '9.2',x: '2',value: '9.2',value3: '9.92'},{value2: '9.3',x: '3',value: '9.44',value3: '9.8'},{value2: '8.5',x: '4',value: '9.46',value3: '9.84'}]);mapping9 = set8.mapAs({ x: 'x', value: 'value' });mapping10 = set8.mapAs({ x: 'x', value: 'value2' });mapping11 = set8.mapAs({ x: 'x', value: 'value3' });line12 = cartesian1.line(mapping9);line12.name('MY SGPA');stateSettings13 = line12.hovered();markersFactory14 = stateSettings13.markers();markersFactory14.enabled(true);stateSettings15 = line12.hovered();markersFactory16 = stateSettings15.markers();markersFactory16.type("circle");markersFactory16.size(4.0);tooltip17 = line12.tooltip();tooltip17.position('right');tooltip17.anchor("left-center");tooltip17.offsetX(5.0);tooltip17.offsetY(5.0);line18 = cartesian1.line(mapping10);line18.name('AVERAGE SGPA');stateSettings19 = line18.hovered();markersFactory20 = stateSettings19.markers();markersFactory20.enabled(true);stateSettings21 = line18.hovered();markersFactory22 = stateSettings21.markers();markersFactory22.type("circle");markersFactory22.size(4.0);tooltip23 = line18.tooltip();tooltip23.position('right');tooltip23.anchor("left-center");tooltip23.offsetX(5.0);tooltip23.offsetY(5.0);line24 = cartesian1.line(mapping11);line24.name('Topper's SGPA');stateSettings25 = line24.hovered();markersFactory26 = stateSettings25.markers();markersFactory26.enabled(true);stateSettings27 = line24.hovered();markersFactory28 = stateSettings27.markers();markersFactory28.type("circle");markersFactory28.size(4.0);tooltip29 = line24.tooltip();tooltip29.position('right');tooltip29.anchor("left-center");tooltip29.offsetX(5.0);tooltip29.offsetY(5.0);legend30 = cartesian1.legend();legend30.enabled(true);legend31 = cartesian1.legend();legend31.fontSize(13.0);legend32 = cartesian1.legend();legend32.padding(0.0, 0.0, 10.0, 0.0);

Issue/Unable to reload or change data in Circular Gauge chart

In Circular Gauge chart in Fragment and Activity, The change of Data is required in different cases.

I have tried creating a new Chart as well as updating the data values of existing chart with no effect.
.ie.
1 . the Chart does not get updated with new value when updating the data values.
2. When creating a new Chart -- view becomes blank
Below is a sample code :

I want to refresh the view of a chart on button click,
code:

` AnyChartView anyChartView;
Button click = findViewById(R.id.btn_click);
anyChartView = findViewById(R.id.any_chart_view);
anyChartView.setProgressBar(findViewById(R.id.progress_bar));

    click.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            anyChartView = findViewById(R.id.any_chart_view);
            anyChartView.setProgressBar(findViewById(R.id.progress_bar));
            String[] color = new String[]{"#E85053", "#EDE2DC", "#EDE2DC", "#EDE2DC", "#EDE2DC"};

            CircularGauge circularGauge = AnyChart.circular();
            double currentValue = 20;
            circularGauge.data(new SingleValueDataSet(new Double[]{currentValue}));

            circularGauge.fill("#00000000")
                    .stroke(null)
                    .padding(0, 0, 0, 0)
                    .margin(16, 16, 16, 16);
            circularGauge.startAngle(270);
            circularGauge.sweepAngle(180);

            circularGauge.axis(0)
                    .startAngle(270)
                    .radius(100)
                    .sweepAngle(180)
                    .width(30).fill(color).ticks(false);
            circularGauge.axis(0).labels().enabled(false);

            circularGauge.axis(0).scale()
                    .minimum(0)
                    .maximum(90);

            circularGauge.axis(0).scale()
                    .ticks("{interval: 10}")
                    .minorTicks("{interval: 10}");

            circularGauge.range(0,
                    "{\n" +
                            "    from: 0,\n" +
                            "    to: 30,\n" +
                            "    position: 'inside',\n" +
                            "    fill: '#E85053',\n" +
                            "    stroke: '0 #000',\n" +
                            "    startSize: 8,\n" +
                            "    endSize: 8,\n" +
                            "    radius: 80,\n" +
                            "    zIndex: 1\n" +
                            "  }");
            circularGauge.range(1,
                    "{\n" +
                            "    from: 30,\n" +
                            "    to: 60,\n" +
                            "    position: 'inside',\n" +
                            "    fill: '#FFCF50',\n" +
                            "    stroke: '0 #000',\n" +
                            "    startSize: 8,\n" +
                            "    endSize: 8,\n" +
                            "    radius: 80,\n" +
                            "    zIndex: 1\n" +
                            "  }");

            circularGauge.range(2,
                    "{\n" +
                            "    from: 60,\n" +
                            "    to: 90,\n" +
                            "    position: 'inside',\n" +
                            "    fill: '#5CBD51',\n" +
                            "    stroke: '0 #000',\n" +
                            "    startSize: 8,\n" +
                            "    endSize: 8,\n" +
                            "    radius: 80,\n" +
                            "    zIndex: 1\n" +
                            "  }");

            circularGauge.label(1)
                    .text(getString(R.string.poor))
                    .fontColor("#E85053")
                    .fontSize(14)
                    .offsetY("60%")
                    .offsetX(30)
                    .anchor("center");

            circularGauge.label(2)
                    .text(getString(R.string.average))
                    .fontColor("#FFCF50")
                    .fontSize(14)
                    .offsetY("60%")
                    .offsetX(90)
                    .anchor("center");

            circularGauge.label(3)
                    .text(getString(R.string.good))
                    .fontColor("#5CBD51")
                    .fontSize(14)
                    .offsetY("60%")
                    .offsetX(150)
                    .anchor("center");

            circularGauge.container("container");
            circularGauge.draw(true);
            anyChartView.invalidate();
            anyChartView.refreshDrawableState();

            anyChartView.setChart(circularGauge);
        }
    });`

Chart is not showing up

i have implemented the chart view in my app acording to the procedure which is given in the doc, but chart is not showing up, A little text calling anychart trial version is showing at the below.

here is my code,

Gradle:

`apply plugin: 'com.android.application'

android {
compileSdkVersion 27
defaultConfig {
    applicationId "com.gdm.chartsapp"
    minSdkVersion 20
    targetSdkVersion 27
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
testImplementation 'junit:junit:4.12'

implementation 'com.github.AnyChart:AnyChart-Android:0.2.7'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}`

MainActivity.xml:

`<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<com.anychart.anychart.AnyChartView
    android:background="@color/black"
    android:id="@+id/any_chart_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    />

</android.support.constraint.ConstraintLayout>`

MainActivity.java:

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import com.anychart.anychart.AnyChart;
import com.anychart.anychart.AnyChartView;
import com.anychart.anychart.DataEntry;
import com.anychart.anychart.Pie;
import com.anychart.anychart.ValueDataEntry;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Pie pie = AnyChart.pie();

    List<DataEntry> data = new ArrayList<>();
    data.add(new ValueDataEntry("John", 10000));
    data.add(new ValueDataEntry("Jake", 12000));
    data.add(new ValueDataEntry("Peter", 18000));



    AnyChartView anyChartView = findViewById(R.id.any_chart_view);
    anyChartView.setChart(pie);
}
}`

output:

screenshot_20180707-103838_chartsapp

Customize funnel chart

Hey ,

Can you guide me how can I set my custom color in funnel chart..?

and one more que i have,
In funnel chart i want to show label outside and value inside ,,is that possible , can you send me code for that?

@Shestac92 @ArsenyMalkov

Issue/Unable to reload or change data in Circular Gauge chart

In Circular Gauge chart in Fragment and Activity, The change of Data is required in different cases.

I have tried creating a new Chart as well as updating the data values of existing chart with no effect.
.ie.
1 . the Chart does not get updated with new value when updating the data values.
2. When creating a new Chart -- view becomes blank
Below is a sample code :

I want to refresh the view of a chart on button click,
code:

 ` AnyChartView anyChartView;
    Button click = findViewById(R.id.btn_click);
        anyChartView = findViewById(R.id.any_chart_view);
        anyChartView.setProgressBar(findViewById(R.id.progress_bar));

        
        click.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                anyChartView = findViewById(R.id.any_chart_view);
                anyChartView.setProgressBar(findViewById(R.id.progress_bar));
                String[] color = new String[]{"#E85053", "#EDE2DC", "#EDE2DC", "#EDE2DC", "#EDE2DC"};

                CircularGauge circularGauge = AnyChart.circular();
                double currentValue = 20;
                circularGauge.data(new SingleValueDataSet(new Double[]{currentValue}));

                circularGauge.fill("#00000000")
                        .stroke(null)
                        .padding(0, 0, 0, 0)
                        .margin(16, 16, 16, 16);
                circularGauge.startAngle(270);
                circularGauge.sweepAngle(180);

                circularGauge.axis(0)
                        .startAngle(270)
                        .radius(100)
                        .sweepAngle(180)
                        .width(30).fill(color).ticks(false);
                circularGauge.axis(0).labels().enabled(false);

                circularGauge.axis(0).scale()
                        .minimum(0)
                        .maximum(90);

                circularGauge.axis(0).scale()
                        .ticks("{interval: 10}")
                        .minorTicks("{interval: 10}");

                circularGauge.range(0,
                        "{\n" +
                                "    from: 0,\n" +
                                "    to: 30,\n" +
                                "    position: 'inside',\n" +
                                "    fill: '#E85053',\n" +
                                "    stroke: '0 #000',\n" +
                                "    startSize: 8,\n" +
                                "    endSize: 8,\n" +
                                "    radius: 80,\n" +
                                "    zIndex: 1\n" +
                                "  }");
                circularGauge.range(1,
                        "{\n" +
                                "    from: 30,\n" +
                                "    to: 60,\n" +
                                "    position: 'inside',\n" +
                                "    fill: '#FFCF50',\n" +
                                "    stroke: '0 #000',\n" +
                                "    startSize: 8,\n" +
                                "    endSize: 8,\n" +
                                "    radius: 80,\n" +
                                "    zIndex: 1\n" +
                                "  }");

                circularGauge.range(2,
                        "{\n" +
                                "    from: 60,\n" +
                                "    to: 90,\n" +
                                "    position: 'inside',\n" +
                                "    fill: '#5CBD51',\n" +
                                "    stroke: '0 #000',\n" +
                                "    startSize: 8,\n" +
                                "    endSize: 8,\n" +
                                "    radius: 80,\n" +
                                "    zIndex: 1\n" +
                                "  }");

                circularGauge.label(1)
                        .text(getString(R.string.poor))
                        .fontColor("#E85053")
                        .fontSize(14)
                        .offsetY("60%")
                        .offsetX(30)
                        .anchor("center");

                circularGauge.label(2)
                        .text(getString(R.string.average))
                        .fontColor("#FFCF50")
                        .fontSize(14)
                        .offsetY("60%")
                        .offsetX(90)
                        .anchor("center");

                circularGauge.label(3)
                        .text(getString(R.string.good))
                        .fontColor("#5CBD51")
                        .fontSize(14)
                        .offsetY("60%")
                        .offsetX(150)
                        .anchor("center");

                circularGauge.container("container");
                circularGauge.draw(true);
                anyChartView.invalidate();
                anyChartView.refreshDrawableState();

                anyChartView.setChart(circularGauge);
            }
        });`

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.