How to make two lines thicker in Chart JS


Stijn Westerhof

As you can see in my fiddle , I have made the chart using Chart JS . There are three lines in this chart. I'm going to make the orange and yellow lines thicker than they are. The green dotted line means it is correct.

I searched everywhere and tried a few things. But I haven't found the correct solution yet. I hope my question is clear and hope someone can help me.

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.1.6/Chart.min.js" charset="utf-8"></script>
<canvas id="canvas2"></canvas>

javascript

Chart.defaults.global.legend.display = false;
var lineChartData = {
labels: ['20°', '30°', '40°', '50°', '60°', '70°', '80°'],
datasets: [{
  data: [null, null, null, 400, 320, 220, 90],
  pointBorderColor: "rgba(75,192,192,1)",
  pointBackgroundColor: "#fff",
  borderColor: '#FFEC8B',
  pointBorderWidth: 0,
  pointHoverRadius: 0,
  pointHoverBackgroundColor: "rgba(75,192,192,1)",
  pointHoverBorderColor: "rgba(220,220,220,1)",
  pointHoverBorderWidth: 0,
  lineWidth: 100,
  pointRadius: 0,
  pointHitRadius: 0,
},{
  data: [550, 520, 470, 400, null, null, null],
  borderColor: '#ff8800',
  pointBorderWidth: 0,
  pointHoverRadius: 0,
  pointHoverBackgroundColor: "rgba(75,192,192,1)",
  pointHoverBorderColor: "rgba(220,220,220,1)",
  pointHoverBorderWidth: 0,
  pointRadius: 0,
  pointHitRadius: 0,
},
{
    data: [220, 220, 220, 220, 220, 220, 220],
    borderColor: '#008080',
    borderDash: [10, 10],
    pointBorderWidth: 0,
    pointHoverRadius: 0,
    pointHoverBackgroundColor: "rgba(75,192,192,1)",
    pointHoverBorderColor: "rgba(220,220,220,1)",
    pointHoverBorderWidth: 0,
    pointRadius: 0,
    pointHitRadius: 0,
  }
]
};

var ctx = document.getElementById("canvas2").getContext("2d");
var myChart = new Chart(ctx, {
 type: "line",
 beginAtZero: true,
 scaleOverride:true,
 scaleSteps:9,
 scaleStartValue:0,
 lineWidth: 100,
 scaleStepWidth:100,
 data: lineChartData,
 options: {
    elements: {
        line: {
            fill: false
        }
    },
    style: {
      strokewidth: 10
    },
    scales: {
      xAxes: [{
        display: true,
        scaleLabel: {
          display: true,
          labelString: 'Temperatuur - Celcius'
        }
      }],
      yAxes: [{
        display: true,
        ticks: {
            max: 600,
            min: 0,
            stepSize: 200,
            userCallback: function(value, index, values) {
                value = value.toString();
                value = value.split(/(?=(?:...)*$)/);
                value = value.join('.');
                return value + '%';
              }
        },
        scaleLabel: {
          display: true,
          labelString: 'Rendement'
        }
      }]
    }
  }
})

Teddy

You are close!
Actually, the property you have to edit is not, lineWidthbut borderWidth( you can see that in the first example in the Chart.js documentation ).


As stated in the MDN documentation example : lineTo

Use beginPath() to start drawing the path of the line, moveTo() to move the pen, and the stroke() method to actually draw the line.

The line is basically a rectangle with a width of 0. Then, use the rectangle border width to calculate the width of the line.


So you just need to edit the dataset this way:

datasets: [{
    // ...
    borderWidth: 1 // and not lineWidth
    // ...
}]

I also updated your fiddle with the edit , you can see it's working now.

Related


How to make two lines thicker in Chart JS

Stijn Westerhof: As you can see in the fiddle , I have used Chart JS to make the chart . There are three lines in this chart. I'm going to make the orange and yellow lines thicker than they are. The green dotted line is good. I searched everywhere and tried a

How to make two lines thicker in Chart JS

Stijn Westerhof: As you can see in the fiddle , I have used Chart JS to make the chart . There are three lines in this chart. I'm going to make the orange and yellow lines thicker than they are. The green dotted line is good. I searched everywhere and tried a

How to make two lines thicker in Chart JS

Stijn Westerhof: As you can see in the fiddle , I have used Chart JS to make the chart . There are three lines in this chart. I'm going to make the orange and yellow lines thicker than they are. The green dotted line is good. I searched everywhere and tried a

How to make thicker stem lines in Matplolib

Yanping Island Crab I want to make thicker stemming in python when using plt.stem. this is my code import matplotlib.pyplot as plt import numpy as np N = 20 n = np.arange(0, 2*N, 1) x = np.exp(-n/N)*np.exp(1j * 2*np.pi/N*n) plt.stem(n,x.real) plt.show()

How to make thicker stem lines in Matplolib

Yanping Island Crab I want to make thicker stemming in python when using plt.stem. this is my code import matplotlib.pyplot as plt import numpy as np N = 20 n = np.arange(0, 2*N, 1) x = np.exp(-n/N)*np.exp(1j * 2*np.pi/N*n) plt.stem(n,x.real) plt.show()

Sublime Text: How To Make Vertical Leader Lines Thicker

Santosh Yedidi I am using sublime text. I use the following in my settings to show indented lines: "indent_guide_options": [ "draw_normal", "draw_active" ], and changed the colors with the following in the color theme file: <key>guide<

Sublime Text: How To Make Vertical Leader Lines Thicker

Santosh Yedidi I am using sublime text. I use the following in my settings to show indented lines: "indent_guide_options": [ "draw_normal", "draw_active" ], and changed the colors with the following in the color theme file: <key>guide<

How to draw thicker lines in mschart

little thunder I have a line connecting different points. I have dynamically generated the row. I want to be a line thinker. My code is as follows: //now lets plot lines between tow points. Series newLineSeries = new Series("LineSeries" + index); //--If t

How to draw thicker lines in mschart

little thunder I have a line connecting different points. I have dynamically generated the row. I want to be a line thinker. My code is as follows: //now lets plot lines between tow points. Series newLineSeries = new Series("LineSeries" + index); //--If t

How to place static pointDots and make vertical lines in Chart.js

Worstein Azatian js community, I'm trying to make some customizations to Chart.js, but I'm running into some basic issues... In this photo you can see what I have achieved My question is how to set fixed points in the chart? Is there any way to do what I'm try

How to place static pointDots and make vertical lines in Chart.js

Worstein Azatian js community, I'm trying to make some customizations to Chart.js, but I'm running into some basic issues... In this photo you can see what I have achieved My question is how to set fixed points in the chart? Is there any way to do what I'm try

How to place static pointDots and make vertical lines in Chart.js

Worstein Azatian js community, I'm trying to make some customizations to Chart.js, but I'm running into some basic issues... In this photo you can see what I have achieved My question is how to set fixed points in the chart? Is there any way to do what I'm try

How to make a plane thicker in RGL?

what for I'll try to make some nice visual illustrations for the binary classification example using the 3D printed data. Here is my 3D plot: require(rgl) #Get example data from mtcars and normalize to range 0:1 fun_norm <- function(k){(k-min(k))/(max(k)-min(k

How to make the midline thicker in bwplot?

username The following code is a minimal example for latticegenerating a boxplot (representing some values of mini ..) . But the median lines on these boxplots are a) colored and b) very thin. How to make them black and tick? a71<-structure(list(n = structure(

How to make a plane thicker in RGL?

what for I'll try to make some nice visual illustrations for the binary classification example using the 3D printed data. Here is my 3D plot: require(rgl) #Get example data from mtcars and normalize to range 0:1 fun_norm <- function(k){(k-min(k))/(max(k)-min(k

surfc: how to make contours thicker?

wet lab student I've been reading the documentation and surfcI can't find an option to make the contour thicker, as the contour is shown below the surface. Is there anyway to do this? and Can't really find any documentation on this, but playing around I found

How to make the midline thicker in bwplot?

username The following code is a minimal example for latticegenerating a boxplot (representing some values of mini ..) . But the median lines on these boxplots are a) colored and b) very thin. How to make them black and tick? a71<-structure(list(n = structure(

How to make the midline thicker in bwplot?

username The following code is a minimal example for latticegenerating a boxplot (representing some values of mini ..) . But the median lines on these boxplots are a) colored and b) very thin. How to make them black and tick? a71<-structure(list(n = structure(

How to make a plane thicker in RGL?

what for I'll try to make some nice visual illustrations for the binary classification example using the 3D printed data. Here is my 3D plot: require(rgl) #Get example data from mtcars and normalize to range 0:1 fun_norm <- function(k){(k-min(k))/(max(k)-min(k

surfc: how to make contours thicker?

wet lab student I've been reading the documentation and surfcI can't find an option to make the contour thicker, as the contour is shown below the surface. Is there anyway to do this? and Can't really find any documentation on this, but playing around I found

How to make map border thicker in Google Geomap?

Nicholas R. I am using a dhtml map to deploy to google appengine . Now, I want to make the border darker and thicker. How to do it? I have deployed this map My model is as follows Can we try to make my map look more like a mockup? My code so far is this. <!DOC

How to make map border thicker in Google Geomap?

Nicholas R. I am using a dhtml map to deploy to google appengine . Now, I want to make the border darker and thicker. How to do it? I have deployed this map My model is as follows Can we try to make my map look more like a mockup? My code so far is like this.

How to make the outline of a radio button thicker

Sanjo I'm trying to add something like https://design-system.service.gov.uk/components/radios/ for radio buttons . The problem is that, on the radio button's focus, mine looks like this: enter image description here It should look like this: enter image descri

How to make underline text thicker in Flutter

Shulsh Shukla After reading the Flutter documentation, I got information on how to underline text. But my problem is, I need a simple text style with bold underline. Vinos Vino Try adding a property called decorationThicknessin TextStyle . Text( 'Flutter Dev

How to make map border thicker in Google Geomap?

Nicholas R. I am using a dhtml map to deploy to google appengine . Now, I want to make the border darker and thicker. How to do it? I have deployed this map My model is as follows Can we try to make my map look more like a mockup? My code so far is this. <!DOC

How to make the outline of a radio button thicker

Sanjo I'm trying to add something like https://design-system.service.gov.uk/components/radios/ for radio buttons . The problem is that, on the radio button's focus, mine looks like this: enter image description here It should look like this: enter image descri

How to make underline text thicker in Flutter

Shulsh Shukla After reading the Flutter documentation, I got information on how to underline text. But my problem is, I need a simple text style with bold underline. Vinos Vino Try adding a property called decorationThicknessin TextStyle . Text( 'Flutter Dev

How to use css to make font thicker then 900

Gianluca I want to make the font extra bold due to the background color of my friend's image in the website header. I found it online, but unfortunately it doesn't work. Is there any other way? h1{ text-shadow: 1px 0 #888888; letter-spacing:1px; font-wei