How to use HighChart.getOption() with react-native-highchart











up vote
0
down vote

favorite












I am using highchart on react-native with this library. I have created simple activity gauge component from high chart official site. Here is the code of component.



import ChartView from 'react-native-highcharts';
import React, { Component } from 'react';

export default class Speedometer extends Component {



render() {
var Highcharts='Highcharts';
var conf={


chart: {
type: 'solidgauge',
height: '110%',

},
....
series: [{
name: 'Move',
data: [{
color: Highcharts.getOptions().colors[0],
radius: '112%',
innerRadius: '88%',
y: 80
}]
}, {
name: 'Exercise',
data: [{
color: Highcharts.getOptions().colors[1],
radius: '87%',
innerRadius: '63%',
y: 65
}]
}, {
name: 'Stand',
data: [{
color: Highcharts.getOptions().colors[2],
radius: '62%',
innerRadius: '38%',
y: 50
}]
}]
};

const options = {
global: {
useUTC: false
},
lang: {
decimalPoint: ',',
thousandsSep: '.'
}
};

return (
<ChartView style={{height:300}} more guage config={conf} options={options}></ChartView>
);
}
}


When i render this component on my screen i get the error



TypeError: TypeError: TypeError: TypeError: undefined is not a function (evaluating 'Highcharts.getOptions()')


How can i use getOptions or colors or theme or other variable with highchart inside react-native component.










share|improve this question






















  • you still need to import Highcharts from 'highcharts' - the other is a wrapper.
    – Dimitar Christoff
    yesterday










  • after the import i am getting this error TypeError: undefined is not a function (evaluating '_highcharts.default.getOptions()')
    – Ahsan Sohail
    yesterday










  • REMEMBER to declare the variable Highcharts='Highcharts' - this has overwritten it. dunno what it's supposed to do when it assigns it to a string...
    – Dimitar Christoff
    yesterday












  • you mean i need to add the import Highcharts from 'highcharts' and Highcharts='Highcharts' both ?
    – Ahsan Sohail
    yesterday










  • no, not tried the react native one but in react web port, you need to only do the import, not the var Highcharts = 'Highcharts'.
    – Dimitar Christoff
    yesterday















up vote
0
down vote

favorite












I am using highchart on react-native with this library. I have created simple activity gauge component from high chart official site. Here is the code of component.



import ChartView from 'react-native-highcharts';
import React, { Component } from 'react';

export default class Speedometer extends Component {



render() {
var Highcharts='Highcharts';
var conf={


chart: {
type: 'solidgauge',
height: '110%',

},
....
series: [{
name: 'Move',
data: [{
color: Highcharts.getOptions().colors[0],
radius: '112%',
innerRadius: '88%',
y: 80
}]
}, {
name: 'Exercise',
data: [{
color: Highcharts.getOptions().colors[1],
radius: '87%',
innerRadius: '63%',
y: 65
}]
}, {
name: 'Stand',
data: [{
color: Highcharts.getOptions().colors[2],
radius: '62%',
innerRadius: '38%',
y: 50
}]
}]
};

const options = {
global: {
useUTC: false
},
lang: {
decimalPoint: ',',
thousandsSep: '.'
}
};

return (
<ChartView style={{height:300}} more guage config={conf} options={options}></ChartView>
);
}
}


When i render this component on my screen i get the error



TypeError: TypeError: TypeError: TypeError: undefined is not a function (evaluating 'Highcharts.getOptions()')


How can i use getOptions or colors or theme or other variable with highchart inside react-native component.










share|improve this question






















  • you still need to import Highcharts from 'highcharts' - the other is a wrapper.
    – Dimitar Christoff
    yesterday










  • after the import i am getting this error TypeError: undefined is not a function (evaluating '_highcharts.default.getOptions()')
    – Ahsan Sohail
    yesterday










  • REMEMBER to declare the variable Highcharts='Highcharts' - this has overwritten it. dunno what it's supposed to do when it assigns it to a string...
    – Dimitar Christoff
    yesterday












  • you mean i need to add the import Highcharts from 'highcharts' and Highcharts='Highcharts' both ?
    – Ahsan Sohail
    yesterday










  • no, not tried the react native one but in react web port, you need to only do the import, not the var Highcharts = 'Highcharts'.
    – Dimitar Christoff
    yesterday













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I am using highchart on react-native with this library. I have created simple activity gauge component from high chart official site. Here is the code of component.



import ChartView from 'react-native-highcharts';
import React, { Component } from 'react';

export default class Speedometer extends Component {



render() {
var Highcharts='Highcharts';
var conf={


chart: {
type: 'solidgauge',
height: '110%',

},
....
series: [{
name: 'Move',
data: [{
color: Highcharts.getOptions().colors[0],
radius: '112%',
innerRadius: '88%',
y: 80
}]
}, {
name: 'Exercise',
data: [{
color: Highcharts.getOptions().colors[1],
radius: '87%',
innerRadius: '63%',
y: 65
}]
}, {
name: 'Stand',
data: [{
color: Highcharts.getOptions().colors[2],
radius: '62%',
innerRadius: '38%',
y: 50
}]
}]
};

const options = {
global: {
useUTC: false
},
lang: {
decimalPoint: ',',
thousandsSep: '.'
}
};

return (
<ChartView style={{height:300}} more guage config={conf} options={options}></ChartView>
);
}
}


When i render this component on my screen i get the error



TypeError: TypeError: TypeError: TypeError: undefined is not a function (evaluating 'Highcharts.getOptions()')


How can i use getOptions or colors or theme or other variable with highchart inside react-native component.










share|improve this question













I am using highchart on react-native with this library. I have created simple activity gauge component from high chart official site. Here is the code of component.



import ChartView from 'react-native-highcharts';
import React, { Component } from 'react';

export default class Speedometer extends Component {



render() {
var Highcharts='Highcharts';
var conf={


chart: {
type: 'solidgauge',
height: '110%',

},
....
series: [{
name: 'Move',
data: [{
color: Highcharts.getOptions().colors[0],
radius: '112%',
innerRadius: '88%',
y: 80
}]
}, {
name: 'Exercise',
data: [{
color: Highcharts.getOptions().colors[1],
radius: '87%',
innerRadius: '63%',
y: 65
}]
}, {
name: 'Stand',
data: [{
color: Highcharts.getOptions().colors[2],
radius: '62%',
innerRadius: '38%',
y: 50
}]
}]
};

const options = {
global: {
useUTC: false
},
lang: {
decimalPoint: ',',
thousandsSep: '.'
}
};

return (
<ChartView style={{height:300}} more guage config={conf} options={options}></ChartView>
);
}
}


When i render this component on my screen i get the error



TypeError: TypeError: TypeError: TypeError: undefined is not a function (evaluating 'Highcharts.getOptions()')


How can i use getOptions or colors or theme or other variable with highchart inside react-native component.







javascript reactjs react-native highcharts






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked yesterday









Ahsan Sohail

390110




390110












  • you still need to import Highcharts from 'highcharts' - the other is a wrapper.
    – Dimitar Christoff
    yesterday










  • after the import i am getting this error TypeError: undefined is not a function (evaluating '_highcharts.default.getOptions()')
    – Ahsan Sohail
    yesterday










  • REMEMBER to declare the variable Highcharts='Highcharts' - this has overwritten it. dunno what it's supposed to do when it assigns it to a string...
    – Dimitar Christoff
    yesterday












  • you mean i need to add the import Highcharts from 'highcharts' and Highcharts='Highcharts' both ?
    – Ahsan Sohail
    yesterday










  • no, not tried the react native one but in react web port, you need to only do the import, not the var Highcharts = 'Highcharts'.
    – Dimitar Christoff
    yesterday


















  • you still need to import Highcharts from 'highcharts' - the other is a wrapper.
    – Dimitar Christoff
    yesterday










  • after the import i am getting this error TypeError: undefined is not a function (evaluating '_highcharts.default.getOptions()')
    – Ahsan Sohail
    yesterday










  • REMEMBER to declare the variable Highcharts='Highcharts' - this has overwritten it. dunno what it's supposed to do when it assigns it to a string...
    – Dimitar Christoff
    yesterday












  • you mean i need to add the import Highcharts from 'highcharts' and Highcharts='Highcharts' both ?
    – Ahsan Sohail
    yesterday










  • no, not tried the react native one but in react web port, you need to only do the import, not the var Highcharts = 'Highcharts'.
    – Dimitar Christoff
    yesterday
















you still need to import Highcharts from 'highcharts' - the other is a wrapper.
– Dimitar Christoff
yesterday




you still need to import Highcharts from 'highcharts' - the other is a wrapper.
– Dimitar Christoff
yesterday












after the import i am getting this error TypeError: undefined is not a function (evaluating '_highcharts.default.getOptions()')
– Ahsan Sohail
yesterday




after the import i am getting this error TypeError: undefined is not a function (evaluating '_highcharts.default.getOptions()')
– Ahsan Sohail
yesterday












REMEMBER to declare the variable Highcharts='Highcharts' - this has overwritten it. dunno what it's supposed to do when it assigns it to a string...
– Dimitar Christoff
yesterday






REMEMBER to declare the variable Highcharts='Highcharts' - this has overwritten it. dunno what it's supposed to do when it assigns it to a string...
– Dimitar Christoff
yesterday














you mean i need to add the import Highcharts from 'highcharts' and Highcharts='Highcharts' both ?
– Ahsan Sohail
yesterday




you mean i need to add the import Highcharts from 'highcharts' and Highcharts='Highcharts' both ?
– Ahsan Sohail
yesterday












no, not tried the react native one but in react web port, you need to only do the import, not the var Highcharts = 'Highcharts'.
– Dimitar Christoff
yesterday




no, not tried the react native one but in react web port, you need to only do the import, not the var Highcharts = 'Highcharts'.
– Dimitar Christoff
yesterday












1 Answer
1






active

oldest

votes

















up vote
1
down vote



accepted










You need to understand a few things here:





  1. react-native-highcharts library create a dynamic html content and then inject into webview. Whatever is passed in the config props of ChartView is converted in to string content after flattenObject function inside the library.

  2. If you look at the starting code of html content inside the library you would see that some javascript dependencies has been included and one of them is highcharts. This highcharts library will make the variable Highcharts in the local scope of javascript inside webview.

  3. You are getting this error because React thinks that Highchart must be define somewhere in the component and define Highchart as a string, so if you access string.function it will throw error.

  4. (Solution) you have two option here either to tweak the code inside the library and make it to accept flat string as props and pass this string directly to the ChartView, or you can create dummy Highchart object inside your root component to make the React stop complaining about the Highchart object. Once this object is passed through CharView highchart would be available in javascript scope inside webview and BOOM you Charts are loading.


Now you know the problem you can come up with more solutions. Hope this helps!






share|improve this answer








New contributor




Hamza Ahmed is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.


















  • Thank you for the explanation!
    – Ahsan Sohail
    47 mins ago











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53372627%2fhow-to-use-highchart-getoption-with-react-native-highchart%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote



accepted










You need to understand a few things here:





  1. react-native-highcharts library create a dynamic html content and then inject into webview. Whatever is passed in the config props of ChartView is converted in to string content after flattenObject function inside the library.

  2. If you look at the starting code of html content inside the library you would see that some javascript dependencies has been included and one of them is highcharts. This highcharts library will make the variable Highcharts in the local scope of javascript inside webview.

  3. You are getting this error because React thinks that Highchart must be define somewhere in the component and define Highchart as a string, so if you access string.function it will throw error.

  4. (Solution) you have two option here either to tweak the code inside the library and make it to accept flat string as props and pass this string directly to the ChartView, or you can create dummy Highchart object inside your root component to make the React stop complaining about the Highchart object. Once this object is passed through CharView highchart would be available in javascript scope inside webview and BOOM you Charts are loading.


Now you know the problem you can come up with more solutions. Hope this helps!






share|improve this answer








New contributor




Hamza Ahmed is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.


















  • Thank you for the explanation!
    – Ahsan Sohail
    47 mins ago















up vote
1
down vote



accepted










You need to understand a few things here:





  1. react-native-highcharts library create a dynamic html content and then inject into webview. Whatever is passed in the config props of ChartView is converted in to string content after flattenObject function inside the library.

  2. If you look at the starting code of html content inside the library you would see that some javascript dependencies has been included and one of them is highcharts. This highcharts library will make the variable Highcharts in the local scope of javascript inside webview.

  3. You are getting this error because React thinks that Highchart must be define somewhere in the component and define Highchart as a string, so if you access string.function it will throw error.

  4. (Solution) you have two option here either to tweak the code inside the library and make it to accept flat string as props and pass this string directly to the ChartView, or you can create dummy Highchart object inside your root component to make the React stop complaining about the Highchart object. Once this object is passed through CharView highchart would be available in javascript scope inside webview and BOOM you Charts are loading.


Now you know the problem you can come up with more solutions. Hope this helps!






share|improve this answer








New contributor




Hamza Ahmed is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.


















  • Thank you for the explanation!
    – Ahsan Sohail
    47 mins ago













up vote
1
down vote



accepted







up vote
1
down vote



accepted






You need to understand a few things here:





  1. react-native-highcharts library create a dynamic html content and then inject into webview. Whatever is passed in the config props of ChartView is converted in to string content after flattenObject function inside the library.

  2. If you look at the starting code of html content inside the library you would see that some javascript dependencies has been included and one of them is highcharts. This highcharts library will make the variable Highcharts in the local scope of javascript inside webview.

  3. You are getting this error because React thinks that Highchart must be define somewhere in the component and define Highchart as a string, so if you access string.function it will throw error.

  4. (Solution) you have two option here either to tweak the code inside the library and make it to accept flat string as props and pass this string directly to the ChartView, or you can create dummy Highchart object inside your root component to make the React stop complaining about the Highchart object. Once this object is passed through CharView highchart would be available in javascript scope inside webview and BOOM you Charts are loading.


Now you know the problem you can come up with more solutions. Hope this helps!






share|improve this answer








New contributor




Hamza Ahmed is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









You need to understand a few things here:





  1. react-native-highcharts library create a dynamic html content and then inject into webview. Whatever is passed in the config props of ChartView is converted in to string content after flattenObject function inside the library.

  2. If you look at the starting code of html content inside the library you would see that some javascript dependencies has been included and one of them is highcharts. This highcharts library will make the variable Highcharts in the local scope of javascript inside webview.

  3. You are getting this error because React thinks that Highchart must be define somewhere in the component and define Highchart as a string, so if you access string.function it will throw error.

  4. (Solution) you have two option here either to tweak the code inside the library and make it to accept flat string as props and pass this string directly to the ChartView, or you can create dummy Highchart object inside your root component to make the React stop complaining about the Highchart object. Once this object is passed through CharView highchart would be available in javascript scope inside webview and BOOM you Charts are loading.


Now you know the problem you can come up with more solutions. Hope this helps!







share|improve this answer








New contributor




Hamza Ahmed is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this answer



share|improve this answer






New contributor




Hamza Ahmed is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









answered 2 hours ago









Hamza Ahmed

262




262




New contributor




Hamza Ahmed is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Hamza Ahmed is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Hamza Ahmed is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • Thank you for the explanation!
    – Ahsan Sohail
    47 mins ago


















  • Thank you for the explanation!
    – Ahsan Sohail
    47 mins ago
















Thank you for the explanation!
– Ahsan Sohail
47 mins ago




Thank you for the explanation!
– Ahsan Sohail
47 mins ago


















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53372627%2fhow-to-use-highchart-getoption-with-react-native-highchart%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

'app-layout' is not a known element: how to share Component with different Modules

android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

SQL update select statement