chartist 1.2.1 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/_settings.scss +1 -1
- package/dist/charts/BarChart/BarChart.d.ts.map +1 -1
- package/dist/charts/BarChart/BarChart.types.d.ts +3 -2
- package/dist/charts/BarChart/BarChart.types.d.ts.map +1 -1
- package/dist/index.cjs +20 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +20 -9
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +6 -3
package/dist/index.js
CHANGED
|
@@ -2915,8 +2915,9 @@ function getSerialSums(series) {
|
|
|
2915
2915
|
seriesBarDistance: 15,
|
|
2916
2916
|
// If set to true this property will cause the series bars to be stacked. Check the `stackMode` option for further stacking options.
|
|
2917
2917
|
stackBars: false,
|
|
2918
|
-
// If set to
|
|
2918
|
+
// If set to true this property will force the stacked bars to draw from the zero line.
|
|
2919
2919
|
// If set to 'accumulate' this property will form a total for each series point. This will also influence the y-axis and the overall bounds of the chart. In stacked mode the seriesBarDistance property will have no effect.
|
|
2920
|
+
// If set to 'accumulate-relative' positive and negative values will be handled separately.
|
|
2920
2921
|
stackMode: "accumulate",
|
|
2921
2922
|
// Inverts the axes of the bar chart in order to draw a horizontal bar chart. Be aware that you also need to invert your axis settings as the Y Axis will now display the labels and the X Axis the values.
|
|
2922
2923
|
horizontalBars: false,
|
|
@@ -3025,8 +3026,12 @@ class BarChart extends BaseChart {
|
|
|
3025
3026
|
}
|
|
3026
3027
|
// Projected 0 point
|
|
3027
3028
|
const zeroPoint = options.horizontalBars ? chartRect.x1 + valueAxis.projectValue(0) : chartRect.y1 - valueAxis.projectValue(0);
|
|
3029
|
+
const isAccumulateStackMode = options.stackMode === "accumulate";
|
|
3030
|
+
const isAccumulateRelativeStackMode = options.stackMode === "accumulate-relative";
|
|
3028
3031
|
// Used to track the screen coordinates of stacked bars
|
|
3029
|
-
const
|
|
3032
|
+
const posStackedBarValues = [];
|
|
3033
|
+
const negStackedBarValues = [];
|
|
3034
|
+
let stackedBarValues = posStackedBarValues;
|
|
3030
3035
|
labelAxis.createGridAndLabels(gridGroup, labelGroup, options, this.eventEmitter);
|
|
3031
3036
|
valueAxis.createGridAndLabels(gridGroup, labelGroup, options, this.eventEmitter);
|
|
3032
3037
|
if (options.showGridBackground) {
|
|
@@ -3073,6 +3078,8 @@ class BarChart extends BaseChart {
|
|
|
3073
3078
|
seriesClassName || "".concat(options.classNames.series, "-").concat(alphaNumerate(seriesIndex))
|
|
3074
3079
|
].join(" "));
|
|
3075
3080
|
normalizedData.series[seriesIndex].forEach((value, valueIndex)=>{
|
|
3081
|
+
const valueX = safeHasProperty(value, "x") && value.x;
|
|
3082
|
+
const valueY = safeHasProperty(value, "y") && value.y;
|
|
3076
3083
|
let labelAxisValueIndex;
|
|
3077
3084
|
// We need to set labelAxisValueIndex based on some options combinations
|
|
3078
3085
|
if (options.distributeSeries && !options.stackBars) {
|
|
@@ -3091,13 +3098,13 @@ class BarChart extends BaseChart {
|
|
|
3091
3098
|
// We need to transform coordinates differently based on the chart layout
|
|
3092
3099
|
if (options.horizontalBars) {
|
|
3093
3100
|
projected = {
|
|
3094
|
-
x: chartRect.x1 + valueAxis.projectValue(
|
|
3095
|
-
y: chartRect.y1 - labelAxis.projectValue(
|
|
3101
|
+
x: chartRect.x1 + valueAxis.projectValue(valueX || 0, valueIndex, normalizedData.series[seriesIndex]),
|
|
3102
|
+
y: chartRect.y1 - labelAxis.projectValue(valueY || 0, labelAxisValueIndex, normalizedData.series[seriesIndex])
|
|
3096
3103
|
};
|
|
3097
3104
|
} else {
|
|
3098
3105
|
projected = {
|
|
3099
|
-
x: chartRect.x1 + labelAxis.projectValue(
|
|
3100
|
-
y: chartRect.y1 - valueAxis.projectValue(
|
|
3106
|
+
x: chartRect.x1 + labelAxis.projectValue(valueX || 0, labelAxisValueIndex, normalizedData.series[seriesIndex]),
|
|
3107
|
+
y: chartRect.y1 - valueAxis.projectValue(valueY || 0, valueIndex, normalizedData.series[seriesIndex])
|
|
3101
3108
|
};
|
|
3102
3109
|
}
|
|
3103
3110
|
// If the label axis is a step based axis we will offset the bar into the middle of between two steps using
|
|
@@ -3112,6 +3119,10 @@ class BarChart extends BaseChart {
|
|
|
3112
3119
|
// Using bi-polar offset for multiple series if no stacked bars or series distribution is used
|
|
3113
3120
|
projected[labelAxis.units.pos] += options.stackBars || options.distributeSeries ? 0 : biPol * options.seriesBarDistance * (options.horizontalBars ? -1 : 1);
|
|
3114
3121
|
}
|
|
3122
|
+
// distinguish between positive and negative values in relative stack mode
|
|
3123
|
+
if (isAccumulateRelativeStackMode) {
|
|
3124
|
+
stackedBarValues = valueY >= 0 || valueX >= 0 ? posStackedBarValues : negStackedBarValues;
|
|
3125
|
+
}
|
|
3115
3126
|
// Enter value in stacked bar values used to remember previous screen value for stacking up bars
|
|
3116
3127
|
const previousStack = stackedBarValues[valueIndex] || zeroPoint;
|
|
3117
3128
|
stackedBarValues[valueIndex] = previousStack - (zeroPoint - projected[labelAxis.counterUnits.pos]);
|
|
@@ -3123,7 +3134,7 @@ class BarChart extends BaseChart {
|
|
|
3123
3134
|
["".concat(labelAxis.units.pos, "1")]: projected[labelAxis.units.pos],
|
|
3124
3135
|
["".concat(labelAxis.units.pos, "2")]: projected[labelAxis.units.pos]
|
|
3125
3136
|
};
|
|
3126
|
-
if (options.stackBars && (
|
|
3137
|
+
if (options.stackBars && (isAccumulateStackMode || isAccumulateRelativeStackMode || !options.stackMode)) {
|
|
3127
3138
|
// Stack mode: accumulate (default)
|
|
3128
3139
|
// If bars are stacked we use the stackedBarValues reference and otherwise base all bars off the zero line
|
|
3129
3140
|
// We want backwards compatibility, so the expected fallback without the 'stackMode' option
|
|
@@ -3145,8 +3156,8 @@ class BarChart extends BaseChart {
|
|
|
3145
3156
|
// Create bar element
|
|
3146
3157
|
const bar = seriesElement.elem("line", positions, options.classNames.bar).attr({
|
|
3147
3158
|
"ct:value": [
|
|
3148
|
-
|
|
3149
|
-
|
|
3159
|
+
valueX,
|
|
3160
|
+
valueY
|
|
3150
3161
|
].filter(isNumeric).join(","),
|
|
3151
3162
|
"ct:meta": serialize(metaData)
|
|
3152
3163
|
});
|