Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

64
Views
plotlyjs condition based coloring

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

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!