diff --git a/HorizontalBarChart.android.js b/HorizontalBarChart.android.js new file mode 100644 index 0000000..c431b56 --- /dev/null +++ b/HorizontalBarChart.android.js @@ -0,0 +1,15 @@ +import React, {Component, PropTypes} from 'react'; +import {requireNativeComponent, View} from 'react-native'; +import BarChart from './BarChart'; + +class HorizontalBarChart extends BarChart { + render() { + return ( + + ); + } +} + +var MPHorizontalBarChart = requireNativeComponent('MPHorizontalBarChart', HorizontalBarChart); + +export default HorizontalBarChart; diff --git a/android/src/main/java/cn/mandata/react_native_mpchart/MPChartPackage.java b/android/src/main/java/cn/mandata/react_native_mpchart/MPChartPackage.java index d3e4431..ca479f2 100644 --- a/android/src/main/java/cn/mandata/react_native_mpchart/MPChartPackage.java +++ b/android/src/main/java/cn/mandata/react_native_mpchart/MPChartPackage.java @@ -31,6 +31,7 @@ public List createViewManagers(ReactApplicationContext reactContext return Arrays.asList( new ChartViewManager(), new MPBarChartManager(), + new MPHorizontalBarChartManager(), new MPLineChartManager(), new MPCombinedChartManager(), new MPCandleStickChartManager(), diff --git a/android/src/main/java/cn/mandata/react_native_mpchart/MPHorizontalBarChartManager.java b/android/src/main/java/cn/mandata/react_native_mpchart/MPHorizontalBarChartManager.java new file mode 100644 index 0000000..627f46b --- /dev/null +++ b/android/src/main/java/cn/mandata/react_native_mpchart/MPHorizontalBarChartManager.java @@ -0,0 +1,24 @@ +package cn.mandata.react_native_mpchart; + +import com.facebook.react.uimanager.ThemedReactContext; +import com.github.mikephil.charting.charts.HorizontalBarChart; + +import java.util.ArrayList; +import java.util.Random; + +public class MPHorizontalBarChartManager extends MPBarChartManager { + private String CLASS_NAME="MPHorizontalBarChart"; + + @Override + public String getName() { + return this.CLASS_NAME; + } + + @Override + protected HorizontalBarChart createViewInstance(ThemedReactContext reactContext) { + HorizontalBarChart chart=new HorizontalBarChart(reactContext); + new MPChartSelectionEventListener(chart); + return chart; + } + +} diff --git a/index.android.js b/index.android.js index b30a65e..4e22bf0 100644 --- a/index.android.js +++ b/index.android.js @@ -1,13 +1,15 @@ import BarChart from './BarChart.android'; +import HorizontalBarChart from './HorizontalBarChart.android'; import LineChart from './LineChart.android'; import CandleStickChart from './CandleStickChart.android'; import CombinedChart from './CombinedChart.android'; import PieChart from './PieChart.android'; export { - BarChart, - LineChart, - CandleStickChart, - CombinedChart, - PieChart + BarChart, + HorizontalBarChart, + LineChart, + CandleStickChart, + CombinedChart, + PieChart }