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 Articles
- 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
- 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
- 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
- Highcharts - Stacked Bar Column - Total Value of Stacked Bar not Correct with Negative and Positive Values
- 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
- Highcharts: having trouble recreating stacked area chart from Excel with positive and negative values
- Highcharts navigator error: Invalid negative value for <rect> attribute width
- 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
- How do I prevent Highstock right range handle keep slipping off the max value when adding data
- highcharts - error when updating a series to have less categories than previously
- Heat Map With Red Color Range For Negative Values And Green Color Range For Positive Values
- Negative value for categories axis in highcharts
- How center the value 0[threshold], the line which separates positive and negative value?
- Change color code on colum, depending on data value (highchartJS)
- passing json values to highcharts from .net code behind
- Negative values in the data not showing in highcharts linechart
- Highcharts - Cannot set x-axes categories in column charts with negative values
- Negative values causes wrong y-axis highcharts
- Highcharts Point Value Disappearing
- Highcharts Multiple Series Dynamic Column Chart Update
- How can I show a highstock graph with a linear timeline
- Highcharts area graph animation on setData
- Make events run multiple times, Highcharts
- Highcharts - legend titles rotation is not working fine in IE10
- High Chart Data label Formatter not working properly
- Android Highchart bar chart add a text below a bar
- 'ManyToOneRel' object has no attribute 'parent_model' error with django chartit
- primefaces chart x axis
- dotnet highchar data points are not coming with every record
- Highcharts: structure legend by subtitles
- Synchronize multiple chart's x-axis
- Highcharts - Is it possible to shrink image line?
- installing a highcharts server with CentOS 6
- Scraping data from high charts
- Is it possible to change the name of "x" for x data?
- How to include highcharts exporting module when using webpack?
- How to add markers to a grouped bar plot in Highcharts?
- How to make the colors on the heatmap chart to make it appear with scale values?