{"id":24999812,"url":"https://github.com/aghajari/axgraphview","last_synced_at":"2026-03-08T11:36:27.859Z","repository":{"id":57732268,"uuid":"328334891","full_name":"Aghajari/AXGraphView","owner":"Aghajari","description":"AXGraphView creates zoomable and scrollable graphs based on function or custom draw.","archived":false,"fork":false,"pushed_at":"2021-08-14T06:36:20.000Z","size":15890,"stargazers_count":50,"open_issues_count":1,"forks_count":6,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-26T03:33:22.947Z","etag":null,"topics":["chart","chartview","formula","function","graph","graphview","math"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Aghajari.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-01-10T08:16:37.000Z","updated_at":"2024-12-03T00:53:18.000Z","dependencies_parsed_at":"2022-09-10T22:02:11.924Z","dependency_job_id":null,"html_url":"https://github.com/Aghajari/AXGraphView","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aghajari%2FAXGraphView","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aghajari%2FAXGraphView/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aghajari%2FAXGraphView/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aghajari%2FAXGraphView/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Aghajari","download_url":"https://codeload.github.com/Aghajari/AXGraphView/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248540367,"owners_count":21121347,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chart","chartview","formula","function","graph","graphview","math"],"created_at":"2025-02-04T19:19:16.301Z","updated_at":"2025-10-16T07:37:23.548Z","avatar_url":"https://github.com/Aghajari.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AXGraphView\n![AXGraphView](./images/Header.jpg)\n\n[![Platform](https://img.shields.io/badge/platform-android-green.svg)](http://developer.android.com/index.html)\n[![API](https://img.shields.io/badge/API-16%2B-brightgreen.svg?style=flat)](https://android-arsenal.com/api?level=16)\n[![Maven Central](https://img.shields.io/maven-central/v/io.github.aghajari/AXGraphView.svg?label=Maven%20Central)](https://search.maven.org/artifact/io.github.aghajari/AXGraphView/1.1.0/aar)\n[![Join the chat at https://gitter.im/Aghajari/community](https://badges.gitter.im/Aghajari/community.svg)](https://gitter.im/Aghajari/community?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n\n **AXGraphView** creates zoomable and scrollable graphs.\n\n## Screenshot\n\n\u003cdiv align=\"center\"\u003e\n\u003cimg src=\"./images/1.jpg\" title=\"Screen\"\u003e\n\u003cimg src=\"./images/2.jpg\" title=\"Screen\"\u003e\n\u003c/div\u003e\n\n## Preview (GIF)\n\u003cimg src=\"./images/AXGraphView.gif\" width=300 title=\"Preview\"\u003e\n\n## Table of Contents  \n- [Installation](#installation)  \n- [Quick Start](#quick-start)\n- [FormulaParser](#formulaparser)\n- [Graph Axis](#graph-axis)\n- [Domain of Graph](#domain-of-graph)\n- [Custom Points](#custom-points)\n- [Transform](#transform)\n- [MultiFormula](#multiformula)\n- [Custom Draw](#custom-draw)\n- [Famous Graphs](#famous-graphs)\n- [Multi Formula Graphs](#multi-formula-graphs)\n- [Author](#author)\n- [License](#license)\n\n## Installation\nAXGraphView is available in the `mavenCentral()`, so you just need to add it as a dependency (Module gradle)\n\nGradle\n```gradle\nimplementation 'io.github.aghajari:AXGraphView:1.1.0'\n```\n\nMaven\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003eio.github.aghajari\u003c/groupId\u003e\n  \u003cartifactId\u003eAXGraphView\u003c/artifactId\u003e\n  \u003cversion\u003e1.1.0\u003c/version\u003e\n  \u003ctype\u003epom\u003c/type\u003e\n\u003c/dependency\u003e\n```\n\n# Quick Start\n\n1. Add view to your layout :\n```xml\n\u003ccom.aghajari.graphview.AXGraphView\n    android:id=\"@+id/graph_view\"\n    android:background=\"@android:color/white\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"/\u003e\n```\n\n2. Set Graph Options\n```java\nAXGraphView graphView = findViewById(R.id.graph_view);\nAXGraphOptions options = new AXGraphOptions(this);\n\noptions.scrollEnabled = true;\noptions.xDividerIntervalInPx = 100;\noptions.xDividerInterval = 0.5f;\noptions.yDividerIntervalInPx = 100;\noptions.yDividerInterval = 0.5f;\noptions.maxZoom = 6f;\noptions.minZoom = 0.5f\noptions.drawAxis = true;\n...\n\ngraphView.setGraphOptions(options);\n```\n\n3. Add Graph Formula\n```java\ngraphView.addFormula(new AXGraphFormula() { // x^2\n    @Override\n    public float function(float x) {\n        return (float) Math.pow(x,2);\n    }\n});\n\ngraphView.addFormula(new AXGraphFormula() { \n    @Override\n    public float function(float x) { // x^3\n        return (float) Math.pow(x,3);\n    }\n});\n```\n\nOr simply use Graph Formula Parser :\n```java\ngraphView.addFormula(new GraphFormulaParser(this,\"(x)^2\"));\ngraphView.addFormula(new GraphFormulaParser(this,\"(x)^3\"));\n```\n\n## FormulaParser \nCurrently i'm using this [Eval Method](https://stackoverflow.com/a/26227947) for parsing a formula in sample of AXGraphView, you can also use other libraries to parse the formula and draw it in AXGraphView.\n\n## Graph Axis\n\n- Change Axis Position :\nYou can change the default axis position in options.\n\n![Image](./images/axis.png)\n\n```java\noptions.axis = new PointF(-300,AXGraphOptions.DEFAULT);\n```\n\n- Disable drawing Axis and grid lines :\n```java\noptions.drawAxisX = false;\noptions.drawAxisY = false;\noptions.drawGridXLines = false;\noptions.drawGridYLines = false;\noptions.drawAxisXDivider = false;\noptions.drawAxisYDivider = false;\noptions.drawXText = false;\noptions.drawYText = false;\n```\n\n- Change axis color :\n```java\noptions.axisPaint.setColor(Color.RED);\noptions.textPaint.setColor(Color.RED);\noptions.gridLinePaint.setColor(Color.GRAY);\n```\n\n## Domain of Graph\nYou can limit domain of the Graph.\n\n![Image](./images/domain.png)\n\n```java\ngraphView.addFormula(new AXGraphFormula() { // x^2\n    @Override\n    public float function(float x) {\n        return (float) Math.pow(x,2);\n    }\n    \n    @Override\n    public boolean isInDomain(float x) {\n        return Math.abs(x) \u003c 1;\n    }\n});\n```\n\n## Custom Points\nYou can customize an Specific Point in Graph.\n\n```java\ngraphView.addFormula(new AXGraphFormula() { // Sin(x)\n\n    @Override\n    protected void init() {\n        super.init();\n        addCustomFunctionPoint(1);\n        addCustomFunctionPoint(-1);\n        addCustomPoint(0,3);\n    }\n    \n    @Override\n    public float function(float x) {\n        return (float) Math.sin(x);\n    }\n    \n    @Override\n    public AXGraphPointType getPointType(float x, float y) {\n        if (x==0) return AXGraphPointType.EMPTY;\n        return super.getPointType(x, y);\n    }\n});\n```\n\n## Transform\nYou can move(x\u0026y) or change scale(x\u0026y) of the function on graph!\n\n```java\nformula.applyTransformMove(3f,2.5f);\nformula.applyTransformScale(1.5f,1.5f);\n```\n\n## MultiFormula\nYou can also draw multi functions together.\n\n```java\npublic class HeartGraphFormula extends AXGraphMultiFormula {\n\n@Override\n    public float[] multiFunction(float x) {\n        return new float[] {\n                function1(x),\n                function2(x)\n        };\n    }\n\n    public float function1(float x) {\n        return (float) Math.sqrt(1 - Math.pow(Math.abs(x) - 1,2));\n    }\n\n    public float function2(float x) {\n        return (float) (Math.acos(1 - Math.abs(x)) - Math.PI);\n    }\n}\n```\n\nOutput :\n\n\u003cimg src=\"./images/graphs2/screen_heart.png\" width=250 title=\"Heart\"\u003e\n\n## Custom Draw\nYou can draw custom shapes using AXGraphCanvas (by graph x,y) :\n\n![Image](./images/custom_draw.png)\n\n\u003cdetails\u003e\u003csummary\u003e\u003cb\u003eCircleGraphFormula (click to expand)\u003c/b\u003e\u003c/summary\u003e\n\u003cp\u003e\n  \n````java\npublic class CircleGraphFormula extends PaintedGraphFormula {\n\n    private float r;\n    private int angle;\n    Paint paint;\n\n    public CircleGraphFormula(Context context,float r,int angle){\n        super(context);\n        this.r = r;\n        this.angle = angle;\n        paint = new Paint();\n\n        getGraphPaint().setStyle(Paint.Style.STROKE);\n        getPointPaint().setColor(getGraphPaint().getColor());\n        setPointCircleRadius(getPointCircleRadius()*1.2f);\n\n        addCustomPoint(0,r);\n        addCustomPoint(0,-r);\n        addCustomPoint(r,0);\n        addCustomPoint(-r,0);\n    }\n\n    @Override\n    protected boolean onDraw(AXGraphCanvas canvas) {\n        canvas.setRadiusFromAxis(true);\n        canvas.drawCircle(0,0,r, getGraphPaint());\n\n        if (angle!=0) {\n            float angleR = (float) Math.toRadians(angle);\n            String text = angle+\"°\";\n\n            paint.setColor(Color.parseColor(\"#03DAC5\"));\n            paint.setStrokeWidth(getGraphPaint().getStrokeWidth());\n            final float x = (float) Math.cos(angleR) * r;\n            final float y = (float) Math.sin(angleR) * r;\n\n            float r2 = r/5;\n            paint.setStyle(Paint.Style.STROKE);\n            canvas.drawArc(-r2,-r2,r2,r2,-angle,angle,true,paint);\n\n            paint.setStyle(Paint.Style.FILL);\n            paint.setTextSize(canvas.findGraphX(r)/10);\n            canvas.drawText(text,r2,r2/1.5f, Gravity.CENTER_VERTICAL|Gravity.LEFT,paint);\n\n            canvas.drawLine(0,0,x,0,paint);\n            paint.setPathEffect(new DashPathEffect(new float[] {20f/canvas.getGraphScale(),20f/canvas.getGraphScale()}, 0f));\n            canvas.drawLine(x,y,x,0,paint);\n            canvas.drawLine(0,y,x,y,paint);\n            paint.setPathEffect(null);\n\n            paint.setColor(canvas.getGraphView().getContext().getResources().getColor(R.color.colorPrimary));\n            canvas.drawLine(0,0,x,y,paint);\n\n            int savedColor = getPointPaint().getColor();\n            getPointPaint().setColor(paint.getColor());\n            drawPoint(canvas,x,y, AXGraphPointType.CUSTOM);\n            getPointPaint().setColor(savedColor);\n        }\n        return true; //skip drawing function\n    }\n\n    @Override\n    public float function(float x) {\n        return Float.POSITIVE_INFINITY; //undefined\n    }\n}\n````\n\u003c/p\u003e\u003c/details\u003e\n\n## Famous Graphs\n\n|Name|Formula|AXGraphView|\n| :----: | :----: | :----: |\n|Quadratic|x^2|\u003cimg src=\"./images/graphs/quadratic.png\" height=150 title=\"Graph\"\u003e|\n|Cubic|x^3|\u003cimg src=\"./images/graphs/cubic.png\" height=150 title=\"Graph\"\u003e|\n|Quadratic And Cubic|x^2 , x^3|\u003cimg src=\"./images/graphs/quadratic_and_cubic.png\" height=150 title=\"Graph\"\u003e|\n|Homographic|1/x|\u003cimg src=\"./images/graphs/homographic.png\" height=150 title=\"Graph\"\u003e|\n|Square|√x|\u003cimg src=\"./images/graphs/square.png\" height=150 title=\"Graph\"\u003e|\n|Cubic Root|3√x|\u003cimg src=\"./images/graphs/cubic_root.png\" height=150 title=\"Graph\"\u003e|\n|Cubic Root|3√(x^2)|\u003cimg src=\"./images/graphs/cubic_root_x2.png\" height=150 title=\"Graph\"\u003e|\n|Bracket|[x]|\u003cimg src=\"./images/graphs/bracket.png\" height=150 title=\"Graph\"\u003e|\n|Absolute Value|\\|x\\||\u003cimg src=\"./images/graphs/absolute_value.png\" height=150 title=\"Graph\"\u003e|\n|\\|x+1\\| - \\|x-1\\||\\|x+1\\| - \\|x-1\\||\u003cimg src=\"./images/graphs/abs_custom.png\" height=150 title=\"Graph\"\u003e|\n|Exponential|2^x|\u003cimg src=\"./images/graphs/exponential.png\" height=150 title=\"Graph\"\u003e|\n|Logarithm|log(x)|\u003cimg src=\"./images/graphs/logarithm.png\" height=150 title=\"Graph\"\u003e|\n|Sine|sin(x)|\u003cimg src=\"./images/graphs/sin.png\" height=150 title=\"Graph\"\u003e|\n|Cosine|cos(x)|\u003cimg src=\"./images/graphs/cos.png\" height=150 title=\"Graph\"\u003e|\n|Sine And Cosine|sin(x) , cos(x)|\u003cimg src=\"./images/graphs/sin_and_cos.png\" height=150 title=\"Graph\"\u003e|\n|Tangent|tan(x)|\u003cimg src=\"./images/graphs/tan.png\" height=150 title=\"Graph\"\u003e|\n|Cotangent|cot(x)|\u003cimg src=\"./images/graphs/cot.png\" height=150 title=\"Graph\"\u003e|\n|Tangent And Cotangent|tan(x) , cot(x)|\u003cimg src=\"./images/graphs/tan_and_cot.png\" height=150 title=\"Graph\"\u003e|\n\n## Multi Formula Graphs\n\n|Name|AXGraphView|\n| :----: | :----: |\n|Heart|\u003cimg src=\"./images/graphs2/heart.png\" height=150 title=\"Graph\"\u003e|\n|Captain America|\u003cimg src=\"./images/graphs2/captain_america.png\" height=150 title=\"Graph\"\u003e|\n|Superman|\u003cimg src=\"./images/graphs2/superman.png\" height=150 title=\"Graph\"\u003e|\n|Batman|\u003cimg src=\"./images/graphs2/batman.png\" height=150 title=\"Graph\"\u003e|\n|The Flash|\u003cimg src=\"./images/graphs2/flash.png\" height=150 title=\"Graph\"\u003e|\n|Wonder Woman|\u003cimg src=\"./images/graphs2/wonder_woman.png\" height=150 title=\"Graph\"\u003e|\n\n## Author \n- **Amir Hossein Aghajari**\n\nLicense\n=======\n\n    Copyright 2021 Amir Hossein Aghajari\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n\n\n\u003cbr\u003e\u003cbr\u003e\n\u003cdiv align=\"center\"\u003e\n  \u003cimg width=\"64\" alt=\"LCoders | AmirHosseinAghajari\" src=\"https://user-images.githubusercontent.com/30867537/90538314-a0a79200-e193-11ea-8d90-0a3576e28a18.png\"\u003e\n  \u003cbr\u003e\u003ca\u003eAmir Hossein Aghajari\u003c/a\u003e • \u003ca href=\"mailto:amirhossein.aghajari.82@gmail.com\"\u003eEmail\u003c/a\u003e • \u003ca href=\"https://github.com/Aghajari\"\u003eGitHub\u003c/a\u003e\n\u003c/div\u003e\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faghajari%2Faxgraphview","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faghajari%2Faxgraphview","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faghajari%2Faxgraphview/lists"}