Created
October 5, 2018 12:55
-
-
Save kirantambe/2840eafdb3b877283e84d698a03d9f27 to your computer and use it in GitHub Desktop.
Chartist Line chart with gradient
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<svg viewbox="0 0 0 0" style="height:0; width: 0;"> | |
<defs> | |
<linearGradient id="gradient-a" x2="0%" y2="100%"> | |
<stop offset="0%" stop-color="#20F381" /> | |
<stop offset="100%" stop-color="transparent" /> | |
</linearGradient> | |
</defs> | |
</svg> | |
<div id="line-container" class='gradient-line-chart'> | |
<div id="line-chart"></div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
new Chartist.Line('#line-chart', { | |
labels: [1,2,3,4,5,6,7,8,9,10,11,12,13], | |
series: [ | |
Array.from({length: 13}, () => Math.floor(Math.random() * 13)), | |
] | |
}, { | |
fullWidth: true, | |
showArea: true, | |
low: 0, | |
showPoint: false, | |
axisX: { | |
showGrid: true | |
}, | |
axisY: { | |
showGrid: true | |
}, | |
chartPadding: { | |
right: 40 | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="//cdnjs.cloudflare.com/ajax/libs/chartist/0.9.7/chartist.min.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@import url('https://fonts.googleapis.com/css?family=Barlow'); | |
.gradient-line-chart { | |
background-color: #1B1B24; | |
font-family: Barlow; | |
} | |
#line-chart { | |
width: 100%; | |
height: 200px; | |
} | |
.gradient-line-chart .ct-series-a .ct-line{ | |
stroke: #20F381; | |
stroke-width: 2px; | |
} | |
.gradient-line-chart .ct-series-a .ct-area, .ct-series-a .ct-slice-pie { | |
fill: url(#gradient-a); | |
fill-opacity: 0.4; | |
} | |
.gradient-line-chart .ct-label{ | |
color: #FFFFFF; | |
opacity: 0.3; | |
} | |
.gradient-line-chart .ct-grids .ct-horizontal:first-child, | |
.gradient-line-chart .ct-grids .ct-horizontal + .ct-vertical{ | |
stroke: #3A3A41; | |
stroke-dasharray: 0; | |
display: block; | |
} | |
.gradient-line-chart .ct-grids .ct-horizontal, | |
.gradient-line-chart .ct-grids .ct-vertical{ | |
display: none | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link href="//cdnjs.cloudflare.com/ajax/libs/chartist/0.9.7/chartist.min.css" rel="stylesheet" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment