Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: chartist-js/chartist
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: main
Choose a base ref
...
head repository: mempool/chartist-js
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: develop
Choose a head ref
Can’t automatically merge. Don’t worry, you can still create the pull request.
  • 3 commits
  • 7 files changed
  • 3 contributors

Commits on Nov 10, 2020

  1. Copy the full SHA
    0089b61 View commit details
  2. Merge pull request #1 from TechMiX/lineStackMode

    add stackedLine option to line chart
    softsimon authored Nov 10, 2020
    Copy the full SHA
    fc52299 View commit details
  3. Update package.json

    softsimon committed Nov 10, 2020
    Copy the full SHA
    12dbdf3 View commit details
Showing with 51 additions and 13 deletions.
  1. +23 −4 dist/chartist.js
  2. +1 −1 dist/chartist.min.css
  3. +3 −3 dist/chartist.min.js
  4. +1 −1 dist/chartist.min.js.map
  5. +1 −1 package-lock.json
  6. +1 −1 package.json
  7. +21 −2 src/scripts/charts/line.js
27 changes: 23 additions & 4 deletions dist/chartist.js
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@
}(this, function () {

/* Chartist.js 0.11.4
* Copyright © 2019 Gion Kunz
* Copyright © 2020 Gion Kunz
* Free to use under either the WTFPL license or the MIT license.
* https://raw.githubusercontent.com/gionkunz/chartist-js/master/LICENSE-WTFPL
* https://raw.githubusercontent.com/gionkunz/chartist-js/master/LICENSE-MIT
@@ -3326,6 +3326,8 @@ var Chartist = {
showPoint: true,
// If the line chart should draw an area
showArea: false,
// If the line chart series should be stacked
stackedLine: false,
// The base for the area chart that will be used to close the area shape (is normally 0)
areaBase: 0,
// Specify if the lines should be smoothed. This value can be true or false where true will result in smoothing using the default smoothing interpolation function Chartist.Interpolation.cardinal and false results in Chartist.Interpolation.none. You can also choose other smoothing / interpolation functions available in the Chartist.Interpolation module, or write your own interpolation function. Check the examples for a brief description.
@@ -3371,7 +3373,23 @@ var Chartist = {
*
*/
function createChart(options) {
var data = Chartist.normalizeData(this.data, options.reverseData, true);

var dataToNormalize = this.data;
if (options.stackedLine) {
var dataCopy = JSON.parse(JSON.stringify(this.data));
for (var i=0; i<this.data.series.length; i++) {
dataCopy.series[i].className = this.data.series[i].className;
}
for (var i=1; i<dataCopy.series.length; i++) {
for (var j=0; j<dataCopy.series[i].length; j++) {
dataCopy.series[i][j] += dataCopy.series[i-1][j];
}
}
dataCopy.series.reverse();
dataToNormalize = dataCopy;
}

var data = Chartist.normalizeData(dataToNormalize, options.reverseData, true);

// Create new svg object
this.svg = Chartist.createSvg(this.container, options.width, options.height, options.classNames.chart);
@@ -3419,9 +3437,10 @@ var Chartist = {
});

// Use series class from series data or if not set generate one
var relativeSeriesIndex = options.stackedLine? data.raw.series.length - 1 - seriesIndex : seriesIndex;
seriesElement.addClass([
options.classNames.series,
(series.className || options.classNames.series + '-' + Chartist.alphaNumerate(seriesIndex))
(series.className || options.classNames.series + '-' + Chartist.alphaNumerate(relativeSeriesIndex))
].join(' '));

var pathCoordinates = [],
@@ -3812,7 +3831,7 @@ var Chartist = {
var seriesGroup = this.svg.elem('g');
var labelGroup = this.svg.elem('g').addClass(options.classNames.labelGroup);

if(options.stackBars && data.normalized.series.length !== 0) {
if(options.stackBars && (options.stackMode === 'accumulate' || !options.stackMode) && data.normalized.series.length !== 0) {

// If stacked bars we need to calculate the high low from stacked values from each series
var serialSums = Chartist.serialMap(data.normalized.series, function serialSums() {
Loading