首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ReactNative Fusionchart许可证配置不起作用

ReactNative Fusionchart许可证配置不起作用
EN

Stack Overflow用户
提问于 2021-05-13 15:49:27
回答 1查看 133关注 0票数 0

我尝试在这个URL https://www.npmjs.com/package/react-native-fusioncharts#license-configuration中在ReactNative中配置Fusionchart的许可证。

但是,它仍然显示了本应不可见的水印。有什么我漏掉的吗?

代码语言:javascript
复制
import React, { Component } from 'react';
import { AppRegistry, StyleSheet, Text, View, Platform } from 'react-native';
import ReactNativeFusionCharts from 'react-native-fusioncharts';


global.licenseConfig = {
    key: "license-key",
    creditLabel: false // true/false to show/hide watermark respectively
};

export default class App extends Component {
    constructor(props) {
        super(props);
        //STEP 2 - Chart Data
        const chartData = [
            { label: 'Venezuela', value: '250' },
            { label: 'Saudi', value: '260' },
            { label: 'Canada', value: '180' },
            { label: 'Iran', value: '140' },
            { label: 'Russia', value: '115' },
            { label: 'UAE', value: '100' },
            { label: 'US', value: '30' },
            { label: 'China', value: '30' },
        ];
        //STEP 3 - Chart Configurations
        const chartConfig = {
            type: 'column2d',
            width: 400,
            height: 400,
            dataFormat: 'json',
            dataSource: {
                chart: {
                    caption: 'Countries With Most Oil Reserves [2017-18]',
                    subCaption: 'In MMbbl = One Million barrels',
                    xAxisName: 'Country',
                    yAxisName: 'Reserves (MMbbl)',
                    numberSuffix: 'K',
                    theme: 'fusion',
                    exportEnabled: 1, // to enable the export chart functionality
                },
                data: chartData,
            },
        };
        const events = {
            // Add your events method here:
            // Event name should be in small letters.
            dataPlotClick: (ev, props) => {
                console.log('dataPlotClick');
            },
            dataLabelClick: (ev, props) => {
                console.log('dataLabelClick');
            },
        };
        this.state = {
            chartConfig,
            events
        };
    }

    render() {
        return (
            <View style={styles.container}>
                <Text style={styles.heading}>FusionCharts Integration with React Native</Text>
                <View style={styles.chartContainer}>
                    <ReactNativeFusionCharts chartConfig={this.state.chartConfig} events={this.state.events} />
                </View>
            </View>
        );
    }
}

const styles = StyleSheet.create({
    container: {
        flex: 1,
        paddingTop: 50,
        height: 500,
        backgroundColor: 'white'
    },
    heading: {
        fontSize: 20,
        textAlign: 'center',
        marginBottom: 10,
    },
    chartContainer: {
        borderColor: 'red',
        borderWidth: 1,
        height: 500,
    },
});

// skip this line if using Create React Native App
 AppRegistry.registerComponent('ReactNativeFusionCharts', () => App);

我还在根组件中添加了以下代码,但没有运行。

代码语言:javascript
复制
global.licenseConfig = {
    key: "license-key",
    creditLabel: false // true/false to show/hide watermark respectively
};
EN

回答 1

Stack Overflow用户

发布于 2021-05-13 22:40:26

回答我自己的问题。希望这能对某些人有所帮助。

问题是最新的react-native-Fusionchart5.0.0没有使用Fusionchart3.17.0进行更新。您可能需要手动将fusionchart内容复制到react-native-fusionchart。

node_module/fusionchart内容复制到node_modules/react-native-fusioncharts/src/modules/fusionchart文件夹并在脚本下运行。

代码语言:javascript
复制
find fusioncharts -name "*.js" -exec sh -c 'mv "$0" "${0%.js}.fcscript"' {} \;

然后水印就会像预期的那样消失。这些步骤是在gulp脚本中配置的,但不知何故似乎不起作用。

希望这个问题很快就能解决。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67515679

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档