score:0
Accepted answer
i would process data further in the then
callback and then store results in state.
const url = (() => {
const data = [{"pk_id":1,"acct_doc_header_id":539592086,"company_id":60,"document_number":39439082,"document_number_norm":39439082,"business_code":"pier9","create_year":"","document_line_number":0,"doctype":"ri","customer_number":218994,"customer_number_norm":218994,"fk_customer_map_id":-1,"customer_name":"pied piper","division":"","documentcreatedate":"jul 5, 2018","documentcreatedatenorm":"jul 5, 2018","posting_id":"","invoice_id":39439082,"invoice_id_norm":39439082,"totalopenamount":0.0,"totalopenamountnorm":0.0,"cust_payment_terms":60,"business_area":"","ship_to":"","clearingdate":"sep 5, 2018","clearingdatenorm":"sep 5, 2018","reason_code":"","isopen":0,"debit_credit_indicator":"","payment_method":"","invoiceamountdoccurrency":3925.91,"document_id":539592086,"actualopenamount":3925.91,"paidamount":3925.91,"dayspast_due":2,"invoice_age":62,"disputed_amount":0.0}]
const blob = new blob([json.stringify(data)], {
type: 'application/json'
})
return url.createobjecturl(blob);
})()
const options = ({data, categories}) => ({
chart: {
type : 'bar',
backgroundcolor:'#1b1f38',
minwidth: 275,
height: '222px',
},
title : {
text : "total amount by company code",
style:{
color: '#ffffffa5'
}
},
xaxis : {
type : 'category',
categories,
title: {
text: null
},
overflow : 'auto'
},
yaxis : {
min: 0,
},
tooltip: {
valuesuffix: ' dollars'
},
series : [{
data
}],
legend : {
enabled : false,
},
credits: {
enabled : false,
},
exporting: {
enabled : false,
},
plotoptions: {}
})
const preparedataforhighcharts = (groups) => {
const categories = [];
const data = [];
const gdata = groups.top(4);
for(const {key, value} of gdata) {
categories.push(key);
data.push(value);
}
return {
categories,
data
}
}
const reacthighcharts = reacthighcharts;
const { component, usestate, useeffect } = react;
class analyticssection extends component {
constructor(props) {
super(props);
this.state = {
isloading: true,
dataresults: [],
config: {}
}
}
componentdidmount() {
this.mounted = true;
axios.get(url)
.then(response => {
const dataresults = response.data;
if(!this.mounted) {
return;
}
const dataset = crossfilter(dataresults);
const bcodedim = dataset
.dimension(({business_code}) => business_code);
const bcodegrp = bcodedim.group()
.reducesum(({actualopenamount}) => actualopenamount);
const obj = preparedataforhighcharts(bcodegrp);
const config = options(obj);
this.setstate(state => ({
isloading: false,
config
}));
})
.catch(error => {
console.log(error);
});
}
componentwillunmount() {
this.mounted = false;
}
render() {
const { isloading, config } = this.state;
return <div>
{isloading ? <div>loading</div> : <reacthighcharts config = {config}></reacthighcharts>}
</div>
}
}
reactdom.render(
<analyticssection />,
document.getelementbyid('root')
);
<script src="https://unpkg.com/react/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom/umd/react-dom.development.js"></script>
<script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://unpkg.com/react-highcharts@16.0.2/bundle/reacthighcharts.js"></script>
<script src="https://unpkg.com/crossfilter2@latest/crossfilter.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.19.2/axios.js"></script>
<div id="root"></div>
Source: stackoverflow.com
Related Query
- How to use axios to fetch data from servlet and then crossfilter it and display via highcharts
- How to hardcode chart data in my Model then have my Controller pull it from there to display it. Using Highcharts
- How to display historical data and live data from database using Highcharts
- How to get data from multiple tables of MySQL DB and manuplate it using PHP to display graphs?
- How to Plot chart from two different webform Submission data And Wand to Display annotated point
- How to use the tooltip formatter and still display chart color (like it does by default)?
- Highcharts: How to load data from JSON to xAxis.categories and series.data?
- Ajax and Highcharts - Display 'loading' until data is retrieved, then populate chart
- How to make Highcharts fetch data from external JSON file?
- Fetch data from firebase firestore and plot histogram using highcharts when cardview clicked - android
- How to do In highchart tooltip display the first 100 characters and then say "See more .."?
- How to fetch JSON data from HTML DIV on same page for Highcharts?
- How to make the Y Axis values not start from 0 in highcharts? How to display forcefully display the last category data on X axis in HighCharts ?
- How can I unescape and remove quot; from data served by rails into javascript
- How to create seriesfor Highcharts from JSON data to use
- How to fetch value from another series or data
- How do I calculate the total Data values for both and display in Legend
- How can I use data.table or data.csv and extra data for click event handling
- How can i export row data from highchart to excel file and not csv?
- On HighMaps, how do I show state abbreviations instead of state name on a U.S. map and remove data label from point
- How to use highcharts in reactjs with fetched data from API
- How to efficiently remove all series from highchart/highstock and then add many more
- How to get Pie Chart data to display using AppCoda example and iOS Charts?
- How to get data for series and categories in highcharts-convert.js from mysql
- how to add data from database and set it to data serie in highchart C#
- how to fetch data from json file in highchart
- Highcharts Highstock How to Plot OHLC and Line Charts from One Set of Embedded CSV Data Using Series Map Tools?
- how to pull json data from a server/url and set equal to a variable?
- How to scrape data from Highcharts charts using selenium and python?
- Highcharts to display area range and line chart with data from a CSV file
More Query from same tag
- Drill down in Line Chart Highcharts
- Making columns wider in Highcharts
- How to change background color of every single bubble in highcharts?
- Highmaps limit zoom range breaks zooming out
- String with multiple whitespaces on javascript
- bubble chart with highstock
- Highchart: show seconday y-axis tick positions 0 to 12
- Highcharts overwrite default DataLabel
- How To Merge Highcharts Legends With All Unique Entries
- How would I overlay a scatter plot on a mirrored bar chart in Highcharts?
- How to initiate AngularJs directive when its name is set with ng-class
- Highcharts export chart using node.js
- How to convert array values of console into highcharts
- In PHP , How to convert JSON into highchart supported format
- Incorrect values on Highcharts (compared to input)
- display vertical lines and horizontal lines on plots
- Highchart StockChart - Update last point value
- Highcharts column width on a time series axis
- How to capture the hover event in highcharts labels?
- How to force tooltip to show in multiple graphs in highcharts with Vue 3?
- Highchart is not working on Google chrome
- In highcharts, how do I get all categories showing with multiple series and xAxis type set to category?
- Highcharts - Legend width will not update
- spline chart highchart to fill the color in series
- Highchart - adding more series to one of multiple synced highstock charts
- How can I highlight every data point in Highcharts fixed width container?
- Highcharts polar steps
- How to make two charts using highchart show up in the same line side by side using div
- How to display only last data point on highcharts?
- Highcharts dont display statistics with MySQL Query