
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
github.com/mskec/react-native-mp-android-chart
This library is React Native wrapper of popular Android charting library MPAndroidChart.
Library can be easily installed using NPM:
npm i react-native-mp-android-chart --save
Additional setup is required because library is using native Android code.
android/build.gradle
allprojects {
repositories {
...
maven { url "https://jitpack.io" } // used for MPAndroidChart
}
}
android/settings.gradle
include ':reactNativeMPAndroidChart'
project(':reactNativeMPAndroidChart').projectDir = new File(
rootProject.projectDir,
'../node_modules/react-native-mp-android-chart/android'
)
android/app/build.gradle
dependencies {
...
compile project(':reactNativeMPAndroidChart')
}
MainApplication.java
On top where imports are:
import com.github.reactNativeMPAndroidChart.MPAndroidChartPackage;
Add package in getPackages
method:
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new MPAndroidChartPackage() // <----- Add this
);
}
There are 8 supported charts with many configuration options. Almost all configuration available in base MPAndroidChart library are available through this wrapper. More details on available configuration can be found on their wiki.
Example of how charts are used and how to apply configuration can be found in example Android application.
Supported charts with examples:
This is simple example of how BarChart
is used.
import {BarChart} from 'react-native-mp-android-chart';
class BarChartScreen extends React.Component {
constructor() {
super();
this.state = {
data: {
datasets: [{
yValues: [100, 105, 102, 110],
label: 'Data set 1',
config: {
color: 'teal'
}
}, {
yValues: [110, 100, 105, 108],
label: 'Data set 2',
config: {
color: 'orange'
}
}],
xValues: ['Q1', 'Q2', 'Q3', 'Q4']
}
};
}
render() {
return (
<View>
<BarChart
style={styles.chart}
data={this.state.data}
animation={{durationX: 2000}}
/>
</View>
);
}
}
const styles = StyleSheet.create({
chart: {
height: 300,
width: 300
}
});
Example Android application with source code and apk
is available here.
The MIT License
Copyright (c) 2016 Martin Skec
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.