-
-
Notifications
You must be signed in to change notification settings - Fork 9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ranjith smitch17 patch 1 #5444
base: master
Are you sure you want to change the base?
Ranjith smitch17 patch 1 #5444
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# This workflow uses actions that are not certified by GitHub. | ||
# They are provided by a third-party and are governed by | ||
# separate terms of service, privacy policy, and support | ||
# documentation. | ||
# This workflow will build a package using Gradle and then publish it to GitHub packages when a release is created | ||
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Publishing-using-gradle | ||
|
||
name: Gradle Package | ||
|
||
on: | ||
release: | ||
types: [created] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml | ||
settings-path: ${{ github.workspace }} # location for the settings.xml file | ||
|
||
- name: Setup Gradle | ||
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0 | ||
|
||
- name: Build with Gradle | ||
run: ./gradlew build | ||
|
||
# The USERNAME and TOKEN need to correspond to the credentials environment variables used in | ||
# the publishing section of your build.gradle | ||
- name: Publish to GitHub Packages | ||
run: ./gradlew publish | ||
env: | ||
USERNAME: ${{ github.actor }} | ||
TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
Comment on lines
+1
to
+44
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: Ensure that the new GitHub Actions workflow for publishing the Gradle package is tested in a separate branch before merging into the main branch to avoid disruptions in the CI/CD process.
Comment on lines
+1
to
+44
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Code Structure Issue: The GitHub Actions workflow for publishing the Gradle package is well-defined and follows standard practices for building and publishing Java packages. However, it's important to ensure that the secrets and environment variables used (like GITHUB_TOKEN) are securely managed and have the minimal scopes necessary for their usage to maintain the security of the CI/CD pipeline.
Comment on lines
+1
to
+44
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Optimization Issue: The workflow for publishing the package to GitHub packages upon release creation could benefit from optimization in terms of security and efficiency. Using third-party actions poses a potential risk if not properly managed and versioned. Additionally, the build and publish steps could be optimized to only trigger when necessary, reducing unnecessary runs and potential errors.
Comment on lines
+1
to
+44
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Security Issue: The workflow uses actions that are not certified by GitHub. It's recommended to use actions that are verified by GitHub for security and reliability.
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,12 +65,11 @@ protected void onCreate(Bundle savedInstanceState) { | |
|
||
tvX = findViewById(R.id.tvXMax); | ||
tvY = findViewById(R.id.tvYMax); | ||
|
||
seekBarX = findViewById(R.id.seekBar1); | ||
seekBarX.setOnSeekBarChangeListener(this); | ||
|
||
seekBarY = findViewById(R.id.seekBar2); | ||
seekBarY.setMax(180); | ||
seekBarY.setMax(40); | ||
seekBarY.setOnSeekBarChangeListener(this); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Performance Issue: The 'seekBarY.setMax(40);' adjustment significantly reduces the maximum value for the Y-axis compared to the original 'setMax(180)', which might not accommodate the data range effectively.
|
||
|
||
|
||
|
@@ -126,12 +125,11 @@ protected void onCreate(Bundle savedInstanceState) { | |
yAxis.enableGridDashedLine(10f, 10f, 0f); | ||
|
||
// axis range | ||
yAxis.setAxisMaximum(200f); | ||
yAxis.setAxisMinimum(-50f); | ||
yAxis.setAxisMaximum(40f); | ||
yAxis.setAxisMinimum(0f); | ||
Comment on lines
+128
to
+129
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Performance Issue: Changing the axis maximum from '200f' to '40f' and minimum from '-50f' to '0f' might not accurately represent negative values or larger data ranges.
|
||
} | ||
Comment on lines
126
to
130
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Scalability Issue: Modification of the Y-axis maximum and minimum values from a wider range (-50 to 200) to a narrower range (0 to 40) can significantly impact the scalability of the chart. This change restricts the chart's ability to display data points that fall outside the new limited range, potentially omitting critical data from the visualization.
|
||
|
||
|
||
{ // // Create Limit Lines // // | ||
/* { // // Create Limit Lines // // | ||
LimitLine llXAxis = new LimitLine(9f, "Index 10"); | ||
llXAxis.setLineWidth(4f); | ||
llXAxis.enableDashedLine(10f, 10f, 0f); | ||
|
@@ -162,11 +160,11 @@ protected void onCreate(Bundle savedInstanceState) { | |
yAxis.addLimitLine(ll2); | ||
//xAxis.addLimitLine(llXAxis); | ||
} | ||
|
||
*/ | ||
// add data | ||
seekBarX.setProgress(45); | ||
seekBarY.setProgress(180); | ||
setData(45, 180); | ||
seekBarY.setProgress(30); | ||
setData(25, 30); | ||
|
||
// draw points over time | ||
chart.animateX(1500); | ||
|
@@ -184,12 +182,13 @@ private void setData(int count, float range) { | |
|
||
for (int i = 0; i < count; i++) { | ||
|
||
float val = (float) (Math.random() * range) - 30; | ||
float val = (float) (Math.random() * range); | ||
values.add(new Entry(i, val, getResources().getDrawable(R.drawable.star))); | ||
} | ||
|
||
LineDataSet set1; | ||
|
||
|
||
if (chart.getData() != null && | ||
chart.getData().getDataSetCount() > 0) { | ||
set1 = (LineDataSet) chart.getData().getDataSetByIndex(0); | ||
|
@@ -202,24 +201,26 @@ private void setData(int count, float range) { | |
set1 = new LineDataSet(values, "DataSet 1"); | ||
|
||
set1.setDrawIcons(false); | ||
|
||
set1.setMode(LineDataSet.Mode.GRADIENT_CUBIC_BEZIER); | ||
set1.setGradientColor(getResources().getColor(android.R.color.holo_green_dark), | ||
getResources().getColor(android.R.color.holo_blue_dark)); | ||
// draw dashed line | ||
Comment on lines
+205
to
207
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Performance Issue: Disabling the dashed line with 'set1.enableDashedLine(10f, 5f, 0f);' and modifying the line width from '1f' to '5f' could impact the chart's readability and visual appeal.
|
||
set1.enableDashedLine(10f, 5f, 0f); | ||
/* set1.enableDashedLine(10f, 5f, 0f);*/ | ||
|
||
// black lines and points | ||
set1.setColor(Color.BLACK); | ||
set1.setCircleColor(Color.BLACK); | ||
|
||
// line thickness and point size | ||
set1.setLineWidth(1f); | ||
set1.setLineWidth(5f); | ||
set1.setCircleRadius(3f); | ||
|
||
// draw points as solid circles | ||
set1.setDrawCircleHole(false); | ||
set1.setDrawCircles(false); | ||
|
||
// customize legend entry | ||
set1.setFormLineWidth(1f); | ||
set1.setFormLineDashEffect(new DashPathEffect(new float[]{10f, 5f}, 0f)); | ||
//set1.setFormLineDashEffect(new DashPathEffect(new float[]{10f, 5f}, 0f)); | ||
set1.setFormSize(15.f); | ||
Comment on lines
202
to
224
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Code Structure Issue: The introduction of gradient cubic bezier mode and gradient color for the line dataset, along with disabling the dashed line, represents a significant visual change. While this can enhance the visual appeal, it's important to consider its impact on readability and the overall user experience.
|
||
|
||
// text size of values | ||
Comment on lines
202
to
226
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Scalability Issue: The introduction of 'LineDataSet.Mode.GRADIENT_CUBIC_BEZIER' and gradient colors for the line chart can impact performance, especially for large datasets. While gradient colors can enhance visual appeal, rendering gradients is more computationally intensive than rendering solid colors. This change could lead to scalability issues, such as slower rendering times and decreased responsiveness, particularly when visualizing large or complex datasets.
|
||
|
@@ -229,34 +230,35 @@ private void setData(int count, float range) { | |
set1.enableDashedHighlightLine(10f, 5f, 0f); | ||
|
||
// set the filled area | ||
set1.setDrawFilled(true); | ||
set1.setFillFormatter(new IFillFormatter() { | ||
@Override | ||
public float getFillLinePosition(ILineDataSet dataSet, LineDataProvider dataProvider) { | ||
return chart.getAxisLeft().getAxisMinimum(); | ||
} | ||
}); | ||
|
||
// set color of filled area | ||
/* // set color of filled area | ||
if (Utils.getSDKInt() >= 18) { | ||
// drawables only supported on api level 18 and above | ||
Drawable drawable = ContextCompat.getDrawable(this, R.drawable.fade_red); | ||
set1.setFillDrawable(drawable); | ||
} else { | ||
set1.setFillColor(Color.BLACK); | ||
} | ||
}*/ | ||
|
||
ArrayList<ILineDataSet> dataSets = new ArrayList<>(); | ||
/* dataSets.add(ds1);*/ | ||
dataSets.add(set1); // add the data sets | ||
|
||
// create a data object with the data sets | ||
LineData data = new LineData(dataSets); | ||
|
||
// set data | ||
chart.setData(data); | ||
} | ||
|
||
} | ||
|
||
|
||
@Override | ||
public boolean onCreateOptionsMenu(Menu menu) { | ||
getMenuInflater().inflate(R.menu.line, menu); | ||
|
@@ -300,7 +302,7 @@ public boolean onOptionsItemSelected(MenuItem item) { | |
break; | ||
} | ||
case R.id.actionToggleHighlight: { | ||
if(chart.getData() != null) { | ||
if (chart.getData() != null) { | ||
chart.getData().setHighlightEnabled(!chart.getData().isHighlightEnabled()); | ||
chart.invalidate(); | ||
} | ||
|
@@ -346,7 +348,7 @@ public boolean onOptionsItemSelected(MenuItem item) { | |
LineDataSet set = (LineDataSet) iSet; | ||
set.setMode(set.getMode() == LineDataSet.Mode.CUBIC_BEZIER | ||
? LineDataSet.Mode.LINEAR | ||
: LineDataSet.Mode.CUBIC_BEZIER); | ||
: LineDataSet.Mode.CUBIC_BEZIER); | ||
} | ||
chart.invalidate(); | ||
break; | ||
|
@@ -360,7 +362,7 @@ public boolean onOptionsItemSelected(MenuItem item) { | |
LineDataSet set = (LineDataSet) iSet; | ||
set.setMode(set.getMode() == LineDataSet.Mode.STEPPED | ||
? LineDataSet.Mode.LINEAR | ||
: LineDataSet.Mode.STEPPED); | ||
: LineDataSet.Mode.STEPPED); | ||
} | ||
chart.invalidate(); | ||
break; | ||
|
@@ -374,7 +376,7 @@ public boolean onOptionsItemSelected(MenuItem item) { | |
LineDataSet set = (LineDataSet) iSet; | ||
set.setMode(set.getMode() == LineDataSet.Mode.HORIZONTAL_BEZIER | ||
? LineDataSet.Mode.LINEAR | ||
: LineDataSet.Mode.HORIZONTAL_BEZIER); | ||
: LineDataSet.Mode.HORIZONTAL_BEZIER); | ||
} | ||
chart.invalidate(); | ||
break; | ||
|
@@ -435,10 +437,12 @@ protected void saveToGallery() { | |
} | ||
|
||
@Override | ||
public void onStartTrackingTouch(SeekBar seekBar) {} | ||
public void onStartTrackingTouch(SeekBar seekBar) { | ||
} | ||
|
||
@Override | ||
public void onStopTrackingTouch(SeekBar seekBar) {} | ||
public void onStopTrackingTouch(SeekBar seekBar) { | ||
} | ||
|
||
@Override | ||
public void onValueSelected(Entry e, Highlight h) { | ||
|
@@ -451,4 +455,4 @@ public void onValueSelected(Entry e, Highlight h) { | |
public void onNothingSelected() { | ||
Log.i("Nothing selected", "Nothing selected."); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
import com.github.mikephil.charting.components.YAxis; | ||
import com.github.mikephil.charting.formatter.IValueFormatter; | ||
import com.github.mikephil.charting.interfaces.datasets.IDataSet; | ||
import com.github.mikephil.charting.model.GradientColor; | ||
import com.github.mikephil.charting.utils.ColorTemplate; | ||
import com.github.mikephil.charting.utils.MPPointF; | ||
import com.github.mikephil.charting.utils.Utils; | ||
|
@@ -28,6 +29,8 @@ public abstract class BaseDataSet<T extends Entry> implements IDataSet<T> { | |
*/ | ||
protected List<Integer> mColors = null; | ||
|
||
protected GradientColor mGradientColor = null; | ||
|
||
/** | ||
* List representing all colors that are used for drawing the actual values for this DataSet | ||
*/ | ||
|
@@ -141,6 +144,11 @@ public int getColor(int index) { | |
return mColors.get(index % mColors.size()); | ||
} | ||
|
||
@Override | ||
public GradientColor getGradientColor() { | ||
return mGradientColor; | ||
} | ||
|
||
/** | ||
* ###### ###### COLOR SETTING RELATED METHODS ##### ###### | ||
*/ | ||
|
@@ -226,6 +234,16 @@ public void setColor(int color, int alpha) { | |
setColor(Color.argb(alpha, Color.red(color), Color.green(color), Color.blue(color))); | ||
} | ||
|
||
/** | ||
* Sets the start and end color for gradient color, ONLY color that should be used for this DataSet. | ||
* | ||
* @param startColor | ||
* @param endColor | ||
*/ | ||
public void setGradientColor(int startColor, int endColor) { | ||
mGradientColor = new GradientColor(startColor, endColor); | ||
} | ||
Comment on lines
+243
to
+245
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: The introduction of gradient coloring to datasets is a significant enhancement. Ensure that this feature is compatible with all chart types in the library and does not interfere with existing coloring options.
|
||
|
||
/** | ||
* Sets colors with a specific alpha value. | ||
* | ||
|
@@ -495,6 +513,7 @@ protected void copy(BaseDataSet baseDataSet) { | |
baseDataSet.mFormLineDashEffect = mFormLineDashEffect; | ||
baseDataSet.mFormLineWidth = mFormLineWidth; | ||
baseDataSet.mFormSize = mFormSize; | ||
baseDataSet.mGradientColor = mGradientColor; | ||
baseDataSet.mHighlightEnabled = mHighlightEnabled; | ||
baseDataSet.mIconsOffset = mIconsOffset; | ||
baseDataSet.mValueColors = mValueColors; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
package com.github.mikephil.charting.interfaces.datasets; | ||
|
||
import android.graphics.DashPathEffect; | ||
import android.graphics.PointF; | ||
import android.graphics.Typeface; | ||
|
||
import com.github.mikephil.charting.components.Legend; | ||
import com.github.mikephil.charting.components.YAxis; | ||
import com.github.mikephil.charting.data.DataSet; | ||
import com.github.mikephil.charting.data.Entry; | ||
import com.github.mikephil.charting.formatter.IValueFormatter; | ||
import com.github.mikephil.charting.model.GradientColor; | ||
import com.github.mikephil.charting.utils.MPPointF; | ||
|
||
import java.util.List; | ||
|
@@ -285,6 +285,13 @@ public interface IDataSet<T extends Entry> { | |
*/ | ||
int getColor(); | ||
|
||
/** | ||
* Returns the Gradient color model | ||
* | ||
* @return | ||
*/ | ||
GradientColor getGradientColor(); | ||
Comment on lines
285
to
+293
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: Adding the getGradientColor method to the IDataSet interface increases the flexibility of the library. Ensure that all implementations of IDataSet properly support this method, returning meaningful gradient information or a default if not applicable.
|
||
|
||
/** | ||
* Returns the color at the given index of the DataSet's color array. | ||
* Performs a IndexOutOfBounds check by modulus. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Performance Issue: The workflow comment suggests that actions not certified by GitHub are being used. This could introduce security vulnerabilities or maintenance issues if these third-party actions are not properly managed or become deprecated.
Fix: Consider using GitHub-certified actions where possible. If third-party actions must be used, ensure they are from reputable sources and actively maintained. Regularly review and update these actions to their latest versions to mitigate potential security vulnerabilities.
Code Suggestion: