highcharts / highcharts-react-native

Other
103 stars 81 forks source link

Can it rotate 3d scatter chart? #132

Closed hungdev closed 3 years ago

hungdev commented 3 years ago

@Denyllon I want to drag to rotate chart like this:

https://www.highcharts.com/demo/3d-scatter-draggable

Thank you. here is my code:

import React from 'react';
import { StyleSheet, View } from 'react-native';
import HighchartsReactNative from '@highcharts/highcharts-react-native'

export default class App extends React.Component {
  constructor(props) {
    super(props);

    this.state = {
      chartOptions: {
        chart: {
          type: 'scatter3d',
          options3d: {
            enabled: true,
            alpha: 20,
            beta: 30,
            depth: 200,
            viewDistance: 10,
            frame: {
              bottom: {
                size: 1,
                color: 'rgba(0,0,0,0.05)'
              }
            }
          }
        },
        title: {
          text: 'a 3D Scatter Chart'
        },
        subtitle: {
          text: 'using x y z coordinates'
        },
        yAxis: {
          min: 0,
          max: 10
        },
        xAxis: {
          min: 0,
          max: 10,
          gridLineWidth: 1
        },
        zAxis: {
          min: 0,
          max: 10,
          showFirstLabel: false
        },
        series: [{
          data: [
            // [X, Y, Z]
            [1, 1, 1],
            [1, 1, 2],
            [1, 1, 5],
            [2, 3, 2],
            [2, 6, 4],
            [4, 5, 7],
            [4, 2, 8],
            [7, 1, 3],
            [7, 1, 5],
            [8, 1, 5]
          ]
        }]
      }
    };
  }

  render() {
    return (
      <View style={styles.container}>
        <HighchartsReactNative
          styles={styles.container}
          options={this.state.chartOptions}
          modules={['highcharts-3d']}
        />
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    backgroundColor: '#fff',
    justifyContent: 'center',
    flex: 1
  }
});
KacperMadej commented 3 years ago

Hi @hungdev

The code that adds the rotate on drag functionality could be placed in the chart's callback or in options - chart.events.load.

You will need to get Highcharts instance reference to add the events or change the base code from the working demo to use React Native events management.

This project is no longer actively maintained. For Highcharts technical support see: https://www.highcharts.com/blog/support/

This issue is a support question and not a bug or feature request, so I am closing it but feel free to reopen.