Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ public void setDragEnabled(BarLineChartBase chart, boolean enabled) {
chart.setDragEnabled(enabled);
}

@ReactProp(name = "dragYEnabled")
public void setDragYEnabled(BarLineChartBase chart, boolean enabled) {
chart.setDragYEnabled(enabled);
}

@ReactProp(name = "highlightPerDragEnabled")
public void setHighlightPerDragEnabled(BarLineChartBase chart, boolean enabled) {
chart.setHighlightPerDragEnabled(enabled);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ public void setMarker(Chart chart, ReadableMap propMap) {
MarkerView markerView = null;
switch(markerType) {
case "circle":
markerView = circleMarker(chart);
markerView = circleMarker(chart, propMap);

break;
default:
Expand All @@ -295,8 +295,20 @@ private RNRectangleMarkerView rectangleMarker(Chart chart, ReadableMap propMap)
return marker;
}

private RNCircleMarkerView circleMarker(Chart chart) {
return new RNCircleMarkerView(chart.getContext());
private RNCircleMarkerView circleMarker(Chart chart, ReadableMap propMap) {
RNCircleMarkerView marker = new RNCircleMarkerView(chart.getContext());
if (BridgeUtils.validate(propMap, ReadableType.Number, "markerSize")) {
marker.setSize(propMap.getInt("markerSize"));
}

if (BridgeUtils.validate(propMap, ReadableType.Number, "markerStrokeSize")) {
marker.setStroke(propMap.getInt("markerStrokeSize"), propMap.getInt("markerStrokeColor"));
}

if (BridgeUtils.validate(propMap, ReadableType.Number, "markerColor")) {
marker.setColor(propMap.getInt("markerColor"));
}
return marker;
}

private void setMarkerParams(RNRectangleMarkerView marker, ReadableMap propMap) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,50 @@

import com.github.mikephil.charting.components.MarkerView;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.OvalShape;
import android.text.TextUtils;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.util.TypedValue;

import com.github.mikephil.charting.data.CandleEntry;
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.highlight.Highlight;
import com.github.mikephil.charting.utils.MPPointF;
import com.github.mikephil.charting.utils.Utils;
import com.github.wuxudong.rncharts.R;

import java.util.List;
import java.util.Map;

public class RNCircleMarkerView extends MarkerView {
private ImageView ivContent;

public void setSize(int size) {
int dpSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, size, getResources().getDisplayMetrics());
ivContent.setLayoutParams(new LinearLayout.LayoutParams(dpSize, dpSize));
}

public void setStroke(int strokeSize, int strokeColor) {
GradientDrawable background = (GradientDrawable) ivContent.getBackground();
background.mutate(); // only change this instance of the xml, not all components using this xml
int dpSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, strokeSize, getResources().getDisplayMetrics());
background.setStroke(dpSize, strokeColor); // set stroke width and stroke color
}

public void setColor(int markerColor) {
GradientDrawable background = (GradientDrawable) ivContent.getBackground();
background.setColor(markerColor);
}

public RNCircleMarkerView(Context context) {
//the super will take care of displaying the layout
// the super will take care of displaying the layout
super(context, R.layout.circle_marker);

ivContent = (ImageView) findViewById(R.id.circle_ivContent);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ public static void commonLineScatterCandleRadarConfig(LineScatterCandleRadarData
if (BridgeUtils.validate(config, ReadableType.Number, "highlightLineWidth")) {
dataSet.setHighlightLineWidth((float) config.getDouble("highlightLineWidth"));
}
if (BridgeUtils.validate(config, ReadableType.Array, "dashedHighlightLine")) {
float[] args = BridgeUtils.convertToFloatArray(config.getArray("dashedHighlightLine"));
dataSet.enableDashedHighlightLine(args[0], args[1], args[2]);
}
}

public static void commonLineRadarConfig(LineRadarDataSet dataSet, ReadableMap config) {
Expand Down
1 change: 1 addition & 0 deletions android/src/main/res/layout/circle_marker.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
android:layout_height="wrap_content">

<ImageView
android:id="@+id/circle_ivContent"
android:background="@drawable/circle_marker"
android:layout_width="15dp"
android:layout_height="15dp" />
Expand Down
4 changes: 4 additions & 0 deletions docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,10 @@ type lineScatterCandleRadar {
drawVerticalHighlightIndicator: bool,
drawHorizontalHighlightIndicator: bool,
highlightLineWidth: number
// draw Charts(ios) dashed highlight
highlightLineDashLengths: [number],
// draw MPAndroidChart(android) dashed highlight
dashedHighlightLine: [number]
}
```

Expand Down
4 changes: 4 additions & 0 deletions ios/ReactNativeCharts/RNBarLineChartViewBase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ class RNBarLineChartViewBase: RNYAxisChartViewBase {
barLineChart.dragEnabled = enabled
}

func setDragYEnabled(_ enabled: Bool) {
barLineChart.dragYEnabled = enabled
}


func setScaleXEnabled(_ enabled: Bool) {
barLineChart.scaleXEnabled = enabled
Expand Down
4 changes: 4 additions & 0 deletions ios/ReactNativeCharts/utils/ChartDataSetConfigUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ class ChartDataSetConfigUtils: NSObject {
if config["highlightLineWidth"].float != nil {
dataSet.highlightLineWidth = CGFloat(config["highlightLineWidth"].floatValue);
}

if config["highlightLineDashLengths"].arrayObject != nil {
dataSet.highlightLineDashLengths = config["highlightLineDashLengths"].arrayObject as? [CGFloat];
}
}

static func commonLineRadarConfig( _ dataSet:LineRadarChartDataSet, config:JSON) {
Expand Down
1 change: 1 addition & 0 deletions lib/BarLineChartBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const iface = {
scaleXEnabled: PropTypes.bool,
scaleYEnabled: PropTypes.bool,
dragEnabled: PropTypes.bool,
dragYEnabled: PropTypes.bool,
pinchZoom: PropTypes.bool,
doubleTapToZoomEnabled: PropTypes.bool,

Expand Down
5 changes: 4 additions & 1 deletion lib/ChartBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,10 @@ const chartIface = {
markerColor: PropTypes.number,
textColor: PropTypes.number,
textSize: PropTypes.number,

markerType: PropTypes.oneOf(['circle']),
markerSize: PropTypes.number,
markerStrokeSize: PropTypes.number,
markerStrokeColor: PropTypes.number,
}),

// stackIndex for StackBarChart
Expand Down
6 changes: 5 additions & 1 deletion lib/ChartDataSetConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ const chartDataSetConfig = {
lineScatterCandleRadar: {
drawVerticalHighlightIndicator: PropTypes.bool,
drawHorizontalHighlightIndicator: PropTypes.bool,
highlightLineWidth: PropTypes.number
highlightLineWidth: PropTypes.number,
// draw Charts(ios) dashed highlight
highlightLineDashLengths: PropTypes.arrayOf(PropTypes.number),
// draw MPAndroidChart(android) dashed highlight
dashedHighlightLine: PropTypes.arrayOf(PropTypes.number)
},

lineRadar: {
Expand Down