I need to make coloring on condition based on each brand
data = [];
data.push({
'id': "Apple",
'value': 12,
'condition': 'CM'
});
data.push({
'id': "Apple",
'value': 4,
'condition': 'ECM'
});
data.push({
'id': "Apple",
'value': -23,
'condition': 'SAX'
});
data.push({
'id': "Microsoft",
'value': 4,
'condition': 'SAX'
});
data.push({
'id': "Microsoft",
'value': 78,
'condition': 'ECM'
});
data.push({
'id': "Microsoft",
'value': 78,
'condition': 'CM'
});
data.push({
'id': "ABC",
'condition': 'CM'
});
data.push({
'id': "DEF",
'condition': 'CM'
});
data.push({
'id': "XYZ",
'condition': 'CM'
});
var conditions = new Set(data.map(a => a.condition));
traces = [];
conditions.forEach(function(condition) {
var newArray = data.filter(function(el) {
return el.condition == condition;
});
traces.push({
x: newArray.map(a => a.id),
y: newArray.map(a => a.value),
name: condition,
mode: 'markers',
type: 'scatter',
marker: {
color: 'rgb(17, 157, 255)',
size: 10,
line: {
color: 'rgb(231, 99, 250)',
width: 6
}
}
})
})
Plotly.plot('myPlot', traces);
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
<div id="myPlot"></div>
I want
1.if apple and if value in between -10 to +30 then yellow plot, if value more that 30 then green and if lessthan -10 then red 2. if Microsoft if value in between -20 to +10 then yellow plot, if value more that 20 then green and if lessthan -20 then red