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

95
Views
Adding different point style to each column from parsed csv in chart.js

I'm trying to use the parsed csv to specify a pointStyle color for each column dataset. Right now this will cause alternating colors of points on the line chart. Would splitting out the 'borderColor:' into three if statements of "i equal to the column number" work? Not sure how this would be written.

var data = Papa.parse(csvString).data;
    var timeLabels = data.slice(1).map(function(row) { return row[0]; }); // data in that column

    var datasets = [];
    for (var i = 1; i < data[0].length; i++) {
      datasets.push(
        {
          label: data[0][i], // column name
          data: data.slice(1).map(function(row) {return row[i]}), // data in that column
          fill: false, // `true` for area charts, `false` for regular line charts
          borderColor: ["#3e95cd","#8e5ea2","#c45850"],
          borderWidth: "2",
          pointRadius: '0',
          pointStyle: "rectRot"
        }
      )
    }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You are now telling each dataset that the colors it has to use is an array of 3 collors so it will do so, like you said if you only want one color you just need to pass that one collor like so:

var datasets = [];
const colors = ["#3e95cd", "#8e5ea2", "#c45850"];

for (var i = 1; i < data[0].length; i++) {
  datasets.push({
    label: data[0][i], // column name
    data: data.slice(1).map(function(row) {
      return row[i]
    }), // data in that column
    fill: false, // `true` for area charts, `false` for regular line charts
    borderColor: colors[i],
    borderWidth: "2",
    pointRadius: '0',
    pointStyle: "rectRot"
  })
}
about 4 years ago · Juan Pablo Isaza Report
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!