Necesito hacer colorantes en condiciones en base a cada marca
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>Quiero
1.si Apple y si el valor está entre -10 y +30, entonces gráfico amarillo, si el valor es superior a 30, entonces verde y si es inferior a -10, entonces rojo 2. Si Microsoft si el valor está entre -20 y +10, entonces gráfico amarillo, si valor más de 20 entonces verde y si menos de -20 entonces rojo