Giter Site home page Giter Site logo

antvis / f2native Goto Github PK

View Code? Open in Web Editor NEW
213.0 27.0 21.0 43.91 MB

📱📈An elegant, interactive and flexible native charting library for mobile.

Home Page: https://f2native.antv.vision

License: MIT License

CMake 0.59% Java 5.83% C++ 87.60% JavaScript 0.11% Objective-C 1.35% Objective-C++ 3.98% TypeScript 0.22% C 0.19% Ruby 0.12% Shell 0.01%
antv antvis mobile visualization grammer android ios f2 data-vis macos

f2native's Introduction

中文 README

F2Native is born for mobile visual development. It is out-of-the-box,cross-platform, high-performance visualization solution . Support Android, iOS and MacOS perfect,moreover have high-performance experience in low-end mobile. Based on the grammar of graphics, F2Native provides all the chart types you'll need. Our mobile design guidelines enable better user experience in mobile visualzation projects.

Special thanks to Leland Wilkinson, the author of The Grammar Of Graphics, whose book served as the foundation for F2Native and F2.

Features

Focus on the mobile,extreme experience

F2Native supports Android, iOS And MacOS. Using the cross-platform language C++ to generate the underlying drawing commands, can achieve cross-platform, unified experience, high-performance experience. After packaging on Android and iOS, the APK and IPA size are 250KB and 500KB respectively.

Light and natural

make data more alive and chart interactions more natural.

All the chart types you want

With the power of grammar of graphics, F2Native including classical charts such as line, column/bar chart, pie chart. Additionally, F2 also provides feature-riched chart components to meet various needs.

Links

Demos

Chart Demos
[Video Demos]

ios_demo.mp4

iOS

CocoaPod Setup

pod 'F2'

Objective-C

#import <F2/F2.h>
@interface F2Demo : UIView
@property (nonatomic, strong) F2CanvasView *canvasView;
@end
@implementation  F2Demo
-(NSString *)jsonData {
    return @"[
      {\"genre\":\"Sports\",\"sold\":275},
      {\"genre\":\"Strategy\",\"sold\":115},
      {\"genre\":\"Action\",\"sold\":120},
      {\"genre\":\"Shooter\",\"sold\":350},
      {\"genre\":\"Other\",\"sold\":150}]";
}
- (void)chartRender {
    self.chart.canvas(self.canvasView);
    self.chart.padding(10, 20, 10, 0.f);
    self.chart.source([self jsonData]);
    self.chart.interval().position(@"genre*sold").color(@"genre", @[]);
    self.chart.scale(@"sold", @{@"min": @(0)});
    self.chart.scale(@"genre", @{@"range": @[@(0.1), @(0.9)]});
    self.chart.render();
}

Swift

func chartRender() {
    self.chart!.canvas()(self.canvasView!)
    self.chart!.padding()(10, 20, 10, 0)
    self.chart!.source()(jsonData)
    self.chart!.interval()().position()("genre*sold").color()("genre", [])
    self.chart!.scale()("sold", ["min":0])
    self.chart!.scale()("genre", ["range": [0.1, 0.9]])
    self.chart!.render()();
}

Android

Gradle Setup

repositories {
    maven { url 'https://jitpack.io' }
}

dependencies {
      implementation 'com.github.antvis:F2Native:latest.release'
}

XML

<com.antgroup.antv.f2.F2CanvasView
    android:id="@+id/canvasView"
    android:layout_width="match_parent"
    android:layout_height="220dp"/>

Java

F2CanvasView canvasView = findViewById(R.id.canvasView);
canvasView.initCanvasContext();

canvasView.setAdapter(new F2CanvasView.Adapter() {
    private F2Chart mChart;
    @Override
    public void onCanvasDraw(F2CanvasView canvasView) {
       if (mChart == null) {
            mChart = F2Chart.create(canvasView.getContext(), "SingleIntervalChart_2", canvasView.getWidth(), canvasView.getHeight());
        }
        mChart.setCanvas(canvasView);
        mChart.padding(20, 10, 10, 10);
        mChart.source(Utils.loadAssetFile(canvasView.getContext(), "mockData_singleIntervalChart_2.json"));
        mChart.interval().position("genre*sold").color("genre");
        mChart.setScale("sold", new F2Chart.ScaleConfigBuilder().min(0));
        mChart.setScale("genre", new F2Chart.ScaleConfigBuilder().range(new double[]{0.1, 0.9}));
        mChart.render();
    }

    @Override
    public void onDestroy() {
        if (mChart != null) {
            mChart.destroy();
        }
    }
});

Kotlin

mCanvasView = findViewById(R.id.canvasView)
mCanvasView!!.initCanvasContext()

private var mChart: F2Chart? = null
    override fun onCanvasDraw(canvasView: F2CanvasView) {
        if (mChart == null) {
            mChart = F2Chart.create(
                canvasView.context,
                "SingleIntervalChart_2",
                canvasView.width.toDouble(),
                canvasView.height.toDouble()
            )
        }
        mChart!!.setCanvas(canvasView)
        mChart!!.padding(20.0, 10.0, 10.0, 10.0)
        mChart!!.source(loadAssetFile(canvasView.context, "mockData_singleIntervalChart_2.json"))
        mChart!!.interval().position("genre*sold").color("genre")
        mChart!!.setScale("sold", ScaleConfigBuilder().min(0.0))
        mChart!!.setScale("genre", ScaleConfigBuilder().range(doubleArrayOf(0.1, 0.9)))
        mChart!!.legend(
            "genre",
            LegendConfigBuild().enable(true).position("top").symbol("circle").setOption("radius", 3)
        )
        mChart!!.render()
    }

    override fun onDestroy() {
        if (mChart != null) {
            mChart!!.destroy()
        }
    }

How to Contribute

Please let us know how can we help. Do check out issues for bug reports or suggestions first.

To become a contributor, please follow our contributing guide.

License

MIT license

f2native's People

Contributors

afc163 avatar janezhong avatar weiqingtangx avatar yanglbme avatar yangxlei avatar yasic 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

f2native's Issues

如何更新数据,

项目demo例子中全部都是本地json文件加载数据, 实际情况中都是通过网络加载数据, 首次设置数据后要进行数据更新, 没有对应的方法, 并且在之前文档找到说更新数据的方法 chart.repaint(); 但是根本找不到对应的api

ToolTipConfigBuilder

你好,1.指定长按交互属性 ToolTipConfigBuilder 方法里没有属性,怎么设置?
2.可以设置点击交互吗?
3.X轴 设置tickCount 好像没有作用,是有什么必要的设置吗?

ios: F2 conflict with LBXZBarSDK

Describe the bug
In Demos provided by the Offical, i met the error that The Xcode can't find "vector" in File "CanvasContext.h" , by adding F2( #pod 'F2' ) and LBXZBarSDK( #pod 'LBXZBarSDK').

To Reproduce ( 100% reproduce )
Steps to reproduce the behavior:

  1. Go to 'ios Demos provided by the Offical'
  2. open "podfile", we can see "pod 'F2'" in the file
  3. copy "pod 'LBXZBarSDK'" below "pod 'F2'".
  4. open terminal, execute "pod install"

Expected behavior
no error and run normal

Screenshots
image

Angle for legend

I would like to attach an example image rather than anything else.
Can we do this?
image

如何编译运行?

Android按照https://f2native.antv.vision/zh/docs/tutorial/getting-started方式开始
发现以下问题:
1.build_gcanvas_android.sh不存在
2./gradlew :android:f2native:assembleStandalone报错
Task 'assembleStandalone' not found in project ':android:f2native'.
3./gradlew :android:sample:installStandaloneDebug报错
Task 'installStandaloneDebug' not found in project ':android:sample'.
另:有没有 maven仓库版本直接远程依赖,或编译好的so

iOS集成报错

iOS报错:
Showing Recent Errors Only
/Users/user/Downloads/F2Native-master/core/graphics/util/json.h:9:10: 'nlohmann/json.hpp' file not found

In file included from /Users/user/Downloads/F2Native-master/core/graphics/util/json.cpp:9:
/Users/user/Downloads/F2Native-master/core/graphics/util/json.h:9:10: fatal error: 'nlohmann/json.hpp' file not found
#include <nlohmann/json.hpp>
^~~~~~~~~~~~~~~~~~~
1 error generated.

Support HarmonyOS

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
Support HarmonyOS
Describe the solution you'd like
A clear and concise description of what you want to happen.
Support HarmonyOS
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Support HarmonyOS
Additional context
Add any other context or screenshots about the feature request here.
Support HarmonyOS

chart.guide().background().color(), 这里设置渐变色会导致崩溃

com.antgroup.antv.f2.F2Guide.GuideBackgroundConfigBuilder#color(com.antgroup.antv.f2.F2Util.ColorGradient)

机型:Android 11,华为P50

测试程序:samples

测试代码:
在对比折线图中增加代码:

F2Guide.GuideBackgroundConfigBuilder backgroundConfigBuilder = new F2Guide.GuideBackgroundConfigBuilder();
        backgroundConfigBuilder.color(new F2Util.ColorLinearGradient()
                .addColorStop(0f, "#FF0033")
                .addColorStop(1f, "#FFFFFF")
                .setPosition(0, 0, 0, canvasView.getHeight())
        );
        backgroundConfigBuilder.leftBottom(new String[]{"min", "min"});
        backgroundConfigBuilder.rightTop(new String[]{"2011-12-11", "max"});

y轴坐标值不是累加的,出现了0.04->0.05->0.06->0.02,0.02出现在了y轴的最大值处

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

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.