Skip to content
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

Add support for Horizontal Bar Charts. #41

Merged
merged 2 commits into from
Oct 10, 2016
Merged
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
15 changes: 15 additions & 0 deletions HorizontalBarChart.android.js
Original file line number Diff line number Diff line change
@@ -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 (
<MPHorizontalBarChart {...this.props}/>
);
}
}

var MPHorizontalBarChart = requireNativeComponent('MPHorizontalBarChart', HorizontalBarChart);

export default HorizontalBarChart;
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public List<ViewManager> createViewManagers(ReactApplicationContext reactContext
return Arrays.<ViewManager>asList(
new ChartViewManager(),
new MPBarChartManager(),
new MPHorizontalBarChartManager(),
new MPLineChartManager(),
new MPCombinedChartManager(),
new MPCandleStickChartManager(),
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}

}
12 changes: 7 additions & 5 deletions index.android.js
Original file line number Diff line number Diff line change
@@ -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
}