Commit d3687dc0 authored by Evgeny's avatar Evgeny

Fix problem with update stacked-100 charts

parent bee04927
...@@ -1177,6 +1177,34 @@ ...@@ -1177,6 +1177,34 @@
return parsedDate; return parsedDate;
}; };
c3_chart_internal_fn.updateValues = function(d){
var $$ = this;
var values;
$$.data.targets.forEach(function(t){
if(t.id === d.id){
values = t.values;
}
});
return values;
};
c3_chart_internal_fn.updateValue = function(d){
var $$ = this;
var values;
$$.data.targets.forEach(function(t){
if(t.id === d.id){
values = t.values;
}
});
if(values && values[d.x]){
return values[d.x].value
}
return undefined;
};
c3_chart_internal_fn.getDefaultConfig = function () { c3_chart_internal_fn.getDefaultConfig = function () {
var config = { var config = {
bindto: '#chart', bindto: '#chart',
...@@ -3009,6 +3037,9 @@ ...@@ -3009,6 +3037,9 @@
return function (d) { return function (d) {
var values = config.line_connectNull ? $$.filterRemoveNull(d.values) : d.values, var values = config.line_connectNull ? $$.filterRemoveNull(d.values) : d.values,
x = isSub ? $$.x : $$.subX, y = yScaleGetter.call($$, d.id), x0 = 0, y0 = 0, path; x = isSub ? $$.x : $$.subX, y = yScaleGetter.call($$, d.id), x0 = 0, y0 = 0, path;
values = $$.updateValues(d) || values;
if ($$.isLineType(d)) { if ($$.isLineType(d)) {
if (config.data_regions[d.id]) { if (config.data_regions[d.id]) {
path = $$.lineWithRegions(values, x, y, config.data_regions[d.id]); path = $$.lineWithRegions(values, x, y, config.data_regions[d.id]);
...@@ -3174,6 +3205,9 @@ ...@@ -3174,6 +3205,9 @@
return function (d) { return function (d) {
var values = config.line_connectNull ? $$.filterRemoveNull(d.values) : d.values, var values = config.line_connectNull ? $$.filterRemoveNull(d.values) : d.values,
x0 = 0, y0 = 0, path; x0 = 0, y0 = 0, path;
values = $$.updateValues(d) || values;
if ($$.isAreaType(d)) { if ($$.isAreaType(d)) {
if ($$.isStepType(d)) { values = $$.convertValuesToStep(values); } if ($$.isStepType(d)) { values = $$.convertValuesToStep(values); }
path = area.interpolate($$.getInterpolate(d))(values); path = area.interpolate($$.getInterpolate(d))(values);
...@@ -3398,6 +3432,7 @@ ...@@ -3398,6 +3432,7 @@
barOffset = $$.getShapeOffset($$.isBarType, barIndices, !!isSub), barOffset = $$.getShapeOffset($$.isBarType, barIndices, !!isSub),
yScale = isSub ? $$.getSubYScale : $$.getYScale; yScale = isSub ? $$.getSubYScale : $$.getYScale;
return function (d, i) { return function (d, i) {
d.value = $$.updateValue(d) || d.value;
var y0 = yScale.call($$, d.id)(0), var y0 = yScale.call($$, d.id)(0),
offset = barOffset(d, i) || y0, // offset is for stacked bar chart offset = barOffset(d, i) || y0, // offset is for stacked bar chart
posX = barX(d), posY = barY(d); posX = barX(d), posY = barY(d);
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -955,3 +955,31 @@ c3_chart_internal_fn.parseDate = function (date) { ...@@ -955,3 +955,31 @@ c3_chart_internal_fn.parseDate = function (date) {
} }
return parsedDate; return parsedDate;
}; };
c3_chart_internal_fn.updateValues = function(d){
var $$ = this;
var values;
$$.data.targets.forEach(function(t){
if(t.id === d.id){
values = t.values;
}
});
return values;
};
c3_chart_internal_fn.updateValue = function(d){
var $$ = this;
var values;
$$.data.targets.forEach(function(t){
if(t.id === d.id){
values = t.values;
}
});
if(values && values[d.x]){
return values[d.x].value
}
return undefined;
};
...@@ -96,6 +96,7 @@ c3_chart_internal_fn.generateGetBarPoints = function (barIndices, isSub) { ...@@ -96,6 +96,7 @@ c3_chart_internal_fn.generateGetBarPoints = function (barIndices, isSub) {
barOffset = $$.getShapeOffset($$.isBarType, barIndices, !!isSub), barOffset = $$.getShapeOffset($$.isBarType, barIndices, !!isSub),
yScale = isSub ? $$.getSubYScale : $$.getYScale; yScale = isSub ? $$.getSubYScale : $$.getYScale;
return function (d, i) { return function (d, i) {
d.value = $$.updateValue(d) || d.value;
var y0 = yScale.call($$, d.id)(0), var y0 = yScale.call($$, d.id)(0),
offset = barOffset(d, i) || y0, // offset is for stacked bar chart offset = barOffset(d, i) || y0, // offset is for stacked bar chart
posX = barX(d), posY = barY(d); posX = barX(d), posY = barY(d);
......
...@@ -77,6 +77,9 @@ c3_chart_internal_fn.generateDrawLine = function (lineIndices, isSub) { ...@@ -77,6 +77,9 @@ c3_chart_internal_fn.generateDrawLine = function (lineIndices, isSub) {
return function (d) { return function (d) {
var values = config.line_connectNull ? $$.filterRemoveNull(d.values) : d.values, var values = config.line_connectNull ? $$.filterRemoveNull(d.values) : d.values,
x = isSub ? $$.x : $$.subX, y = yScaleGetter.call($$, d.id), x0 = 0, y0 = 0, path; x = isSub ? $$.x : $$.subX, y = yScaleGetter.call($$, d.id), x0 = 0, y0 = 0, path;
values = $$.updateValues(d) || values;
if ($$.isLineType(d)) { if ($$.isLineType(d)) {
if (config.data_regions[d.id]) { if (config.data_regions[d.id]) {
path = $$.lineWithRegions(values, x, y, config.data_regions[d.id]); path = $$.lineWithRegions(values, x, y, config.data_regions[d.id]);
...@@ -242,6 +245,9 @@ c3_chart_internal_fn.generateDrawArea = function (areaIndices, isSub) { ...@@ -242,6 +245,9 @@ c3_chart_internal_fn.generateDrawArea = function (areaIndices, isSub) {
return function (d) { return function (d) {
var values = config.line_connectNull ? $$.filterRemoveNull(d.values) : d.values, var values = config.line_connectNull ? $$.filterRemoveNull(d.values) : d.values,
x0 = 0, y0 = 0, path; x0 = 0, y0 = 0, path;
values = $$.updateValues(d) || values;
if ($$.isAreaType(d)) { if ($$.isAreaType(d)) {
if ($$.isStepType(d)) { values = $$.convertValuesToStep(values); } if ($$.isStepType(d)) { values = $$.convertValuesToStep(values); }
path = area.interpolate($$.getInterpolate(d))(values); path = area.interpolate($$.getInterpolate(d))(values);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment