{"id":20753522,"url":"https://github.com/swapnil1104/curvegraphview","last_synced_at":"2025-04-05T05:09:17.732Z","repository":{"id":49837219,"uuid":"231737860","full_name":"swapnil1104/CurveGraphView","owner":"swapnil1104","description":"A highly customizable and performant custom view to render curved line graph.","archived":false,"fork":false,"pushed_at":"2020-05-23T18:53:27.000Z","size":699,"stargazers_count":357,"open_issues_count":6,"forks_count":55,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-05T05:09:11.630Z","etag":null,"topics":["android-development","android-library","animation","curvegraph","custom-view","graph","graphview","linegraph"],"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/swapnil1104.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["swapnil1104"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2020-01-04T09:21:42.000Z","updated_at":"2024-10-22T06:56:21.000Z","dependencies_parsed_at":"2022-09-14T08:41:01.531Z","dependency_job_id":null,"html_url":"https://github.com/swapnil1104/CurveGraphView","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swapnil1104%2FCurveGraphView","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swapnil1104%2FCurveGraphView/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swapnil1104%2FCurveGraphView/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swapnil1104%2FCurveGraphView/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/swapnil1104","download_url":"https://codeload.github.com/swapnil1104/CurveGraphView/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247289429,"owners_count":20914464,"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":["android-development","android-library","animation","curvegraph","custom-view","graph","graphview","linegraph"],"created_at":"2024-11-17T09:13:52.430Z","updated_at":"2025-04-05T05:09:17.700Z","avatar_url":"https://github.com/swapnil1104.png","language":"Java","funding_links":["https://github.com/sponsors/swapnil1104"],"categories":[],"sub_categories":[],"readme":"# CurveGraphView\n\n[![](https://jitpack.io/v/swapnil1104/CurveGraphView.svg)](https://jitpack.io/#swapnil1104/CurveGraphView)\n[![](https://jitpack.io/v/swapnil1104/CurveGraphView/month.svg)](https://jitpack.io/#swapnil1104/CurveGraphView)\n[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-CurveGraphView-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/8037)\n\nA highly customizable and performant custom view to render curved line graph.\n\n![Animation demo](documentation/images/animation_demo.gif)\n![Animation with straight \u0026 curved](documentation/images/straight_curved_demo.gif)\n![Animation with opaque color](documentation/images/animation_demo2.gif)\n![Animated and non animated graph](documentation/images/static_dynamic_graph_demo.gif)\n![Horizontal guidelines](documentation/images/horizontal_guidelines.png)\n\n## Packed with features\n- Add multiple line graphs within one graph plane.\n- Extensible styling options.\n- Performant and light weight.\n\n## How to integrate the library in your app?\nStep 1: Add it in your root build.gradle at the end of repositories:\n\n```\nallprojects {\n    repositories {\n        maven { url \"https://jitpack.io\" }\n    }\n}\n```\nStep 2. Add the dependency\n\n```\ndependencies {\n    implementation 'com.github.swapnil1104:CurveGraphView:{current_lib_ver}'\n}\n```\nStep 3. Add CurveGraphView to your layout file\n\n```\n \u003ccom.broooapps.graphview.CurveGraphView\n        android:id=\"@+id/cgv\"\n        android:layout_width=\"0dp\"\n        android:layout_height=\"250dp\"\n        app:layout_constraintBottom_toBottomOf=\"parent\"\n        app:layout_constraintEnd_toEndOf=\"parent\"\n        app:layout_constraintStart_toStartOf=\"parent\"\n        app:layout_constraintTop_toTopOf=\"parent\" /\u003e\n```\n\n## How to customize the view.\n\n```\ncurveGraphView = findViewById(R.id.cgv);\n\ncurveGraphView.configure(\n    new CurveGraphConfig.Builder(this)\n            .setAxisColor(R.color.Blue)                                             // Set number of values to be displayed in X ax\n            .setVerticalGuideline(4)                                                // Set number of background guidelines to be shown.\n            .setHorizontalGuideline(2)\n            .setGuidelineColor(R.color.Red)                                         // Set color of the visible guidelines.\n            .setNoDataMsg(\" No Data \")                                              // Message when no data is provided to the view.\n            .setxAxisScaleTextColor(R.color.Black)                                  // Set X axis scale text color.\n            .setyAxisScaleTextColor(R.color.Black)                                  // Set Y axis scale text color\n            .setAnimationDuration(2000)                                             // Set Animation Duration\n            .build()\n);\n```\n## How to provide data to the view.\n### Create PointMap object\n\nThe graph view points the plot with keeping 2 values in mind, **span** and **value**\n**span** relates to the x-coordinate, and **value** relates to the y-coordinate.\nCreate the object by providing values as shown below.\n```\nPointMap pointMap = new PointMap();\n        pointMap.addPoint(0, 100);\n        pointMap.addPoint(1, 500);\n        pointMap.addPoint(5, 800);\n        pointMap.addPoint(4, 600);\n\n```\n\n### Create GraphData object for each PointMap\n\nA GraphData object expects a **PointMap**, **strokeColor** of the graph, and an optional **gradientColor**.\nCreate a GraphData object as shown below.\n```\nGraphData gd = GraphData.builder(this)\n       .setPointMap(pointMap)                                                   // PointMap datqa\n       .setGraphStroke(R.color.Black)                                           // Graph line stroke color\n       .setGraphGradient(R.color.BlueViolet, R.color.RoyalBlue)                 // Graph fill gradient color\n       .setStraightLine(true)                                                   // true for straight line; false for curved line graph\n       .setPointRadius(10)                                                      // set point radius\n       .setPointColor(R.color.Red)                                              // set point color\n       .animateLine(true)                                                       // Trigger animation for the particular graph line!\n       .build();\n```\n\n### Provide the array of GraphData to CurveGraphView\nProvide the above constructed data to CurveGraphView via the **curveGraphView.setData(int span, int maxVal, GraphData... gds)** method.\ndscription of the params:\n- span: is the range from 0...\u003cspan_value\u003e i.e. this is the range of x-axis.\n- maxVal: is the maximum plottable value for Y axis.\n- gds... : is the array of GraphData objects.\n\n\n## Sample Code\n```\ncurveGraphView = findViewById(R.id.cgv);\n\ncurveGraphView.configure(\n        new CurveGraphConfig.Builder(this)\n                .setAxisColor(R.color.Blue)                                             // Set X and Y axis line color stroke.\n                .setIntervalDisplayCount(7)                                             // Set number of values to be displayed in X ax\n                .setGuidelineCount(2)                                                   // Set number of background guidelines to be shown.\n                .setGuidelineColor(R.color.GreenYellow)                                 // Set color of the visible guidelines.\n                .setNoDataMsg(\" No Data \")                                              // Message when no data is provided to the view.\n                .setxAxisScaleTextColor(R.color.Black)                                  // Set X axis scale text color.\n                .setyAxisScaleTextColor(R.color.Black)                                  // Set Y axis scale text color\n                .setAnimationDuration(2000)                                             // Set animation duration to be used after set data.\n                .build()\n);\n\n\nPointMap pointMap = new PointMap();\npointMap.addPoint(0, 100);\npointMap.addPoint(1, 500);\npointMap.addPoint(4, 600);\npointMap.addPoint(5, 800);\n\nGraphData gd = GraphData.builder(this)\n        .setPointMap(pointMap)\n        .setGraphStroke(R.color.Black)\n        .setGraphGradient(R.color.BlueViolet, R.color.RoyalBlue)\n        .build();\n\nPointMap p2 = new PointMap();\np2.addPoint(0, 140);\np2.addPoint(1, 700);\np2.addPoint(2, 100);\np2.addPoint(3, 0);\np2.addPoint(4, 190);\n\nGraphData gd2 = GraphData.builder(this)\n        .setPointMap(p2)\n        .setGraphStroke(R.color.Green)\n        .setGraphGradient(R.color.gradientStartColor, R.color.gradientEndColor)\n        .build();\n\n\n//TODO(Swapnil) Optimize the setting logic code.\n/** This needs to be done, onMeasure of Layout isn't called if setData is called in onCreate \n  * If anyone can take this up as their first issue, it'd be great!\n  */\nnew Handler().postDelayed(new Runnable() {\n    @Override\n    public void run() {\n        curveGraphView.setData(5, 1000, gd, gd2);\n    }\n}, 250);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswapnil1104%2Fcurvegraphview","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fswapnil1104%2Fcurvegraphview","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswapnil1104%2Fcurvegraphview/lists"}