score:1
Assuming your data object is:
const obj = {'jan':100,'feb':200, 'mar':-100,'apr':250};
You can filter and map your Object.entries result like:
Object.entries(obj)
.filter(arr=> +arr[1] >= 0)
.map(arr=>{return{name:arr[0],data:+arr[1],type:'line'}});
The result would be:
[
{"name": "jan","data": 100,"type": "line"},
{"name": "feb","data": 200,"type": "line"},
{"name": "apr","data": 250,"type": "line"}
]
Or if you want to floor the negative values:
Object.entries(obj)
.map(arr=>{return{name:arr[0],data:+arr[1] >= 0 ? +arr[1] : 0,type:'line'}});
Result:
[
{"name": "jan","data": 100,"type": "line"},
{"name": "feb","data": 200,"type": "line"},
{"name": "mar","data": 0,"type": "line"},
{"name": "apr","data": 250,"type": "line"}
]
Source: stackoverflow.com
Related Query
- Handle API to not receive value less than 0 (negative values)
- Label is not being shown if I set the max y value to 100% and I have values higher than that
- Highcharts - Stacked Bar Column - Total Value of Stacked Bar not Correct with Negative and Positive Values
- Negative values in the data not showing in highcharts linechart
- Column Chart is not Printing when all values are negative
- Highchart: Plot negative values on negative Y Axis ans set initial value
- How can I change the background color of horizontal bar if date value is less than to current date?
- highcharts-ng, gauge that can handle negative values
- highcharter heatmap not following hc_coloraxis when there's negative values
- Highcharts packed bubble chart not working for negative values
- How to increase weight of wordcloud for weight value less than 5 in highcharts
- HighCharts/Maps: How to display values lower than a certain value appear different from the rest of the graphic?
- HighStock x-axis displays numbers when category length is less than max value
- Set highcharts y-axis min value to 0, unless there is negative data
- Highcharts - Keep Zero Centered on Y-Axis with Negative Values
- Highcharts - best way to handle and display zero (or negative) values in a line chart series with logarithmic Y axis
- Highcharts - Column With Negative Values - Column Color
- Highcharts - Issue with negative values when displaying multiple axes
- Highcharts - Negative values, set y-axis to greater than 0?
- Change Datalabel Color, Rotation and Align values based on Column value in highcharts
- Why is the my "max" value not accepted in Highcharts?
- Code works on fiddle but not when I do /show
- Highcharts: having trouble recreating stacked area chart from Excel with positive and negative values
- JavaScript code inside TypeScript file .ts not working
- Highcharts navigator error: Invalid negative value for <rect> attribute width
- Heatmap 0 data values are not aligned properly
- how to pass values to tooltip which not in x and y axis in highcharts
- HighCharts scatter plot with Datetime on X Axis not plotting values correctly
- Is there a way how to dynamically create a plotline in highchart when the value is lower than previous one?
- Highcharts - Area Chart - Stacking with series containing negative and positive values
More Query from same tag
- External legend in Highcharts
- Highcharts : Show ticker on the start of plot
- High Charts donut chart percentages adding to 100.1%
- Highcharts Pie chart longer text
- Disabling Handlebars in HighStock charts navigator
- enable / disable CrossHaires by external button
- embedded ruby not working in highcharts
- How do I add a marker only at the end of a dynamic highchart?
- BootStrap - Model Binding and HTML5/CSS3 support?
- How do i put dynamic values inside Highchart.js data?
- Highcharts adding additional blank series from csv
- How to update new plotline values instead of removing and adding new ones in highcharts
- Highcharts SVG difference with Node JS SVG
- Highmaps isn't using a color gradient
- Angular HighCharts ParlimentChart is not working
- Query selector for the individual buttons in range selector
- Disabling a slice for a Highcharts pie chart when creating the chart
- How to make plotline appear on line chart when data is same highcharts?
- Highcharts { pie } - style for only for sliced out slice
- How do I create a graph from JSON data in Ruby on Rails?
- Highcharts: how to use setData to add series
- Highcharts and EXTJS 3: Labels in x axis overlap
- why foreach doesn't work inside my highchart and when i splet the array it works?
- Change color of series in bar chart?
- highcharts horizontal line data size
- Increase Height Of Chart On Export
- highcharts, downloadPNG remove chart data
- How to create multiple highchart and print in HTML page by using for loop?
- Action doesn't execute after ajax post
- Highcharts convert x-axis time to localtime