-
Notifications
You must be signed in to change notification settings - Fork 94
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
BubbleSeries not working #10
Comments
Bubble series require the You should be able to include it by import Highcharts from 'highcharts';
require('highcharts/highcharts-more')(Highcharts); |
Awesome! Its working. Thank you so much for the quick help :) |
Hi @whawker, The bubble series is working fine but I want to create a dynamic bubble series. For e.g I want multiple bubbles but I am not sure how many bubbles will be created. That will depend on my selection of filters. Please help. |
Do you mean an unknown number of Bubbles in a single series? Or multiple Bubble series? The add/remove example demonstrates how you could have an arbitrary number of series, if that helps? |
Unknown number of multiple Bubble series. @whawker Below is the example of AreaSpline Series. In this as well, I want to create multiple Areaspline series depending on the JSON file which has number of categories(Skincare,Haircare etc). I think I am making mistake in loop. Please help.
|
It's hard to say exactly, because I don't know the shape of the JSON being returned. But there are a few issues here, Firstly Secondly Lastly in the code you posted above, every This probably wont work perfectly, because I'm guessing at the shape of your JSON data. But something along the lines of... renderSVTValue ({ somePropertyUniqueToTheSeries, svt }) {
return (
<AreaSplineSeries id={somePropertyUniqueToTheSeries} name="Volume" color="#2fd0b5" data={svt} key={somePropertyUniqueToTheSeries} />
);
}
render () {
return (
<HighchartsChart plotOptions={plotOptions}>
// redacted
{this.state.data.map(this.renderSVTValue)}
// redacted
</HighchartsChart>
);
} |
Ohk great. Thanks, that makes sense. |
JSON DATA: { |
Ok you can either assume the <XAxis categories={["2008-7", "2008-6", "2008-5", "2008-4", "2008-3", "2008-2", "2008-1", "2007-12", "2007-11", "2007-10", "2007-9", "2007-8"]} /> Or use something like lodash.zip to combine the import zip from 'lodash/zip';
renderSVTValue ({ id, name, date, value }) {
const strId = `series-${id}`;
const data = zip(date, value); // Using lodash zip to create multidimensional array
return (
<AreaSplineSeries id={strId} name={name} color="#2fd0b5" data={data} key={strId} />
);
}
render () {
const data = this.state.data;
if (data.hasOwnProperty('svt') === false) return null; // Wait till data is fetched before rendering
return (
<HighchartsChart plotOptions={plotOptions}>
// redacted
{data.svt.map(this.renderSVTValue)}
// redacted
</HighchartsChart>
);
} |
Also, closing this as there is not actually an issue to be fixed here. |
Amazing. Thank you very much @whawker. It worked. Appreciate it 👍 |
Hi @whawker, One more query. Sorry.
|
You don't need to render any additional XAxis components for the Something like: import uniq from 'lodash/uniq';
getDateCategories (svtData) {
const allDates = svtData.reduce((dates, svt) => {
return dates.concat(svt.date); // Combine all svt.date arrays into single array
}, []);
return uniq(allDates.sort()); // Sort combined dates and remove duplicates.
}
render() {
const trendingDate = this.state.data;
if (trendingDate.hasOwnProperty('svt') === false) return null; // Wait till data is fetched before rendering
const categories = this.getDateCategories(trendingData.svt);
return (
<div className="chartApp">
<HighchartsChart plotOptions={plotOptions}>
<Chart />
<XAxis type="category" categories={categories}>
<XAxis.Title>Year-Month</XAxis.Title>
</XAxis>
<YAxis id="number">
<YAxis.Title>Trend Production</YAxis.Title>
{data.svt.map(this.renderTrendingValue)}
</YAxis>
</HighchartsChart>
</div>
);
} |
Can't thank you enough. I tried to make component with XAxis and that worked too. But your way is just perfect. 👍 |
Hi @whawker, just wanted to ask you what if I have categories(names) in XAxis and not dates. The JSON looks like below:
This is the below code you had shared earlier. I tried to tweak it as per the requirement but not sure how to loop inside attribute.
Could you please help? |
The line |
Yes, I had commented it for this example(which doesnt have date on xAxis and has categories instead) considering i don't need any sorting or unique values. |
Yes, but you still need to return something from the function... getDateCategories (behName) {
const allNames = behName.reduce((name, svt) => {
return name.concat(svt.name); // Combine all svt.date arrays into single array
}, []);
return allNames; // Otherwise the function returns undefined
} |
This is showing me only one category i.e the first category "Purchase" from my JSON. How do I make a loop or show all the categories on XAxis? |
Hi @whawker, Could you please help me with the above issue? I tried working around the code and removed the below code as I don't need any sorting or reducing.
I tried the below code:
and in render
Could you please check? |
Hi @whawker ,
I am working with Bubble series and its not generating the chart. If I change the series type to any other type(E.g. Scatter), it works fine. I am not sure if I am passing the data correctly or its some other issue. Please help.
This is the below code:
The text was updated successfully, but these errors were encountered: