Commit 2c71f105 authored by Sergey Luzyanin's avatar Sergey Luzyanin

Поддержка обратного порядка категорий, показывать/скрывать горизонтальнцю ось,...

Поддержка обратного порядка категорий, показывать/скрывать горизонтальнцю ось, максимальные/минимальные заначения для ветикальной оси.
parent 846d472f
No related merge requests found
/* /*
* *
* (c) Copyright Ascensio System Limited 2010-2016 * (c) Copyright Ascensio System Limited 2010-2016
* *
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU * This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html). * General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that * In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights. * Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
* *
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR * THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html * FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
* *
* You can contact Ascensio System SIA by email at sales@onlyoffice.com * You can contact Ascensio System SIA by email at sales@onlyoffice.com
* *
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display * The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3. * Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
* *
* Pursuant to Section 7  3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains * Pursuant to Section 7  3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
* relevant author attributions when distributing the software. If the display of the logo in its graphic * relevant author attributions when distributing the software. If the display of the logo in its graphic
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE" * form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
* in every copy of the program you distribute. * in every copy of the program you distribute.
* Pursuant to Section 7  3(e) we decline to grant you any rights under trademark law for use of our trademarks. * Pursuant to Section 7  3(e) we decline to grant you any rights under trademark law for use of our trademarks.
* *
*/ */
"use strict"; "use strict";
CGroupShape.prototype.addToRecalculate = function() CGroupShape.prototype.addToRecalculate = function()
{ {
......
...@@ -425,12 +425,27 @@ CSparklineView.prototype.initFromSparkline = function(oSparkline, oSparklineGrou ...@@ -425,12 +425,27 @@ CSparklineView.prototype.initFromSparkline = function(oSparkline, oSparklineGrou
settings.putHorGridLines(c_oAscGridLinesSettings.none); settings.putHorGridLines(c_oAscGridLinesSettings.none);
settings.putVertGridLines(c_oAscGridLinesSettings.none); settings.putVertGridLines(c_oAscGridLinesSettings.none);
var val_ax_props = new asc_ValAxisSettings(); var val_ax_props = new asc_ValAxisSettings();
if(settings.type !== c_oAscChartTypeSettings.barStackedPer) if(settings.type !== c_oAscChartTypeSettings.barStackedPer)
{ {
val_ax_props.putMinValRule(c_oAscValAxisRule.auto); if(oSparklineGroup.minAxisType === Asc.SparklineAxisMinMax.Custom && oSparklineGroup.manualMin != null)
val_ax_props.putMaxValRule(c_oAscValAxisRule.auto); {
val_ax_props.putMinValRule(c_oAscValAxisRule.fixed);
val_ax_props.putMinVal(oSparklineGroup.manualMin);
}
else
{
val_ax_props.putMinValRule(c_oAscValAxisRule.auto);
}
if(oSparklineGroup.maxAxisType === Asc.SparklineAxisMinMax.Custom && oSparklineGroup.manualMax != null)
{
val_ax_props.putMinValRule(c_oAscValAxisRule.fixed);
val_ax_props.putMinVal(oSparklineGroup.manualMax);
}
else
{
val_ax_props.putMaxValRule(c_oAscValAxisRule.auto);
}
} }
else else
{ {
...@@ -444,14 +459,7 @@ CSparklineView.prototype.initFromSparkline = function(oSparkline, oSparklineGrou ...@@ -444,14 +459,7 @@ CSparklineView.prototype.initFromSparkline = function(oSparkline, oSparklineGrou
val_ax_props.putTickLabelsPos(c_oAscTickLabelsPos.TICK_LABEL_POSITION_NONE); val_ax_props.putTickLabelsPos(c_oAscTickLabelsPos.TICK_LABEL_POSITION_NONE);
if(oSparklineGroup.rightToLeft) val_ax_props.putInvertValOrder(false);
{
val_ax_props.putInvertValOrder(true);
}
else
{
val_ax_props.putInvertValOrder(false);
}
val_ax_props.putDispUnitsRule(c_oAscValAxUnits.none); val_ax_props.putDispUnitsRule(c_oAscValAxUnits.none);
val_ax_props.putMajorTickMark(c_oAscTickMark.TICK_MARK_NONE); val_ax_props.putMajorTickMark(c_oAscTickMark.TICK_MARK_NONE);
val_ax_props.putMinorTickMark(c_oAscTickMark.TICK_MARK_NONE); val_ax_props.putMinorTickMark(c_oAscTickMark.TICK_MARK_NONE);
...@@ -468,12 +476,14 @@ CSparklineView.prototype.initFromSparkline = function(oSparkline, oSparklineGrou ...@@ -468,12 +476,14 @@ CSparklineView.prototype.initFromSparkline = function(oSparkline, oSparklineGrou
cat_ax_props.putMinorTickMark(c_oAscTickMark.TICK_MARK_NONE); cat_ax_props.putMinorTickMark(c_oAscTickMark.TICK_MARK_NONE);
cat_ax_props.putIntervalBetweenTick(1); cat_ax_props.putIntervalBetweenTick(1);
cat_ax_props.putCrossesRule(c_oAscCrossesRule.auto); cat_ax_props.putCrossesRule(c_oAscCrossesRule.auto);
if(oSparklineGroup.rightToLeft)
{
cat_ax_props.putInvertCatOrder(true);
}
settings.putVertAxisProps(val_ax_props); settings.putVertAxisProps(val_ax_props);
settings.putHorAxisProps(cat_ax_props); settings.putHorAxisProps(cat_ax_props);
DrawingObjectsController.prototype.applyPropsToChartSpace(settings, chart_space); DrawingObjectsController.prototype.applyPropsToChartSpace(settings, chart_space);
var i; var i;
if(!chart_space.spPr) if(!chart_space.spPr)
chart_space.setSpPr(new CSpPr()); chart_space.setSpPr(new CSpPr());
...@@ -487,11 +497,8 @@ CSparklineView.prototype.initFromSparkline = function(oSparkline, oSparklineGrou ...@@ -487,11 +497,8 @@ CSparklineView.prototype.initFromSparkline = function(oSparkline, oSparklineGrou
chart_space.chart.plotArea.setSpPr(new CSpPr()); chart_space.chart.plotArea.setSpPr(new CSpPr());
chart_space.chart.plotArea.spPr.setFill(CreateNoFillUniFill()); chart_space.chart.plotArea.spPr.setFill(CreateNoFillUniFill());
} }
for(i = 0; i < chart_space.chart.plotArea.axId.length; ++i) var oAxis = chart_space.chart.plotArea.getAxisByTypes();
{ oAxis.valAx[0].setDelete(true);
chart_space.chart.plotArea.axId[i].setDelete(true);
}
var oSerie = chart_space.chart.plotArea.charts[0].series[0]; var oSerie = chart_space.chart.plotArea.charts[0].series[0];
if(!oSerie.spPr) if(!oSerie.spPr)
...@@ -555,6 +562,7 @@ CSparklineView.prototype.initFromSparkline = function(oSparkline, oSparklineGrou ...@@ -555,6 +562,7 @@ CSparklineView.prototype.initFromSparkline = function(oSparkline, oSparklineGrou
} }
} }
var aSeriesPoints = getPtsFromSeries(oSerie); var aSeriesPoints = getPtsFromSeries(oSerie);
var aMaxPoints = null, aMinPoints = null;
if(aSeriesPoints.length > 0) if(aSeriesPoints.length > 0)
{ {
if(fCallbackSeries) if(fCallbackSeries)
...@@ -579,7 +587,7 @@ CSparklineView.prototype.initFromSparkline = function(oSparkline, oSparklineGrou ...@@ -579,7 +587,7 @@ CSparklineView.prototype.initFromSparkline = function(oSparkline, oSparklineGrou
} }
if(oSparklineGroup.high && oSparklineGroup.colorHigh) if(oSparklineGroup.high && oSparklineGroup.colorHigh)
{ {
var aMaxPoints = [aSeriesPoints[0]]; aMaxPoints = [aSeriesPoints[0]];
for(i = 1; i < aSeriesPoints.length; ++i) for(i = 1; i < aSeriesPoints.length; ++i)
{ {
if(aSeriesPoints[i].val > aMaxPoints[0].val) if(aSeriesPoints[i].val > aMaxPoints[0].val)
...@@ -599,7 +607,7 @@ CSparklineView.prototype.initFromSparkline = function(oSparkline, oSparklineGrou ...@@ -599,7 +607,7 @@ CSparklineView.prototype.initFromSparkline = function(oSparkline, oSparklineGrou
} }
if(oSparklineGroup.low && oSparklineGroup.colorLow) if(oSparklineGroup.low && oSparklineGroup.colorLow)
{ {
var aMinPoints = [aSeriesPoints[0]]; aMinPoints = [aSeriesPoints[0]];
for(i = 1; i < aSeriesPoints.length; ++i) for(i = 1; i < aSeriesPoints.length; ++i)
{ {
if(aSeriesPoints[i].val < aMinPoints[0].val) if(aSeriesPoints[i].val < aMinPoints[0].val)
...@@ -620,6 +628,59 @@ CSparklineView.prototype.initFromSparkline = function(oSparkline, oSparklineGrou ...@@ -620,6 +628,59 @@ CSparklineView.prototype.initFromSparkline = function(oSparkline, oSparklineGrou
} }
} }
if(!oSparklineGroup.displayXAxis)
{
oAxis.catAx[0].setDelete(true);
}
else if(aSeriesPoints.length > 1)
{
aSeriesPoints = [].concat(aSeriesPoints);
var dMinVal, dMaxVal, bSorted = false;
if(val_ax_props.minVal == null)
{
if(aMinPoints)
{
dMinVal = aMinPoints[0].val;
}
else
{
aSeriesPoints.sort(function(a, b){return b.val - a.val;});
bSorted = true;
dMinVal = aSeriesPoints[0].val;
}
}
else
{
dMinVal = val_ax_props.minVal;
}
if(val_ax_props.maxVal == null)
{
if(aMaxPoints)
{
dMaxVal = aMaxPoints[0].val;
}
else
{
if(!bSorted)
{
aSeriesPoints.sort(function(a, b){return b.val - a.val;});
bSorted = true;
}
dMaxVal = aSeriesPoints[aSeriesPoints.length - 1].val;
}
}
else
{
dMaxVal = val_ax_props.maxVal;
}
if(dMaxVal < 0 || dMinVal > 0)
{
oAxis.catAx[0].setDelete(true);
}
}
if(oSparklineGroup.colorSeries) if(oSparklineGroup.colorSeries)
{ {
var oUnifill = CreateUniFillFromExcelColor(oSparklineGroup.colorSeries); var oUnifill = CreateUniFillFromExcelColor(oSparklineGroup.colorSeries);
...@@ -699,6 +760,78 @@ CSparklineView.prototype.draw = function(graphics) ...@@ -699,6 +760,78 @@ CSparklineView.prototype.draw = function(graphics)
this.chartSpace.chartObj.calcProp.trueHeight = _true_height; this.chartSpace.chartObj.calcProp.trueHeight = _true_height;
}; };
CSparklineView.prototype.setMinMaxValAx = function(minVal, maxVal, oSparklineGroup)
{
var oAxis = this.chartSpace.chart.plotArea.getAxisByTypes();
var oValAx = oAxis.valAx[0];
if(oValAx)
{
if(minVal !== null)
{
if(!oValAx.scaling)
{
oValAx.setScaling(new CScaling());
}
oValAx.scaling.setMin(minVal);
}
if(maxVal !== null)
{
if(!oValAx.scaling)
{
oValAx.setScaling(new CScaling());
}
oValAx.scaling.setMax(maxVal);
}
if(oSparklineGroup.displayXAxis)
{
var aSeriesPoints = getPtsFromSeries(this.chartSpace.chart.plotArea.charts[0].series[0]);
if(aSeriesPoints.length > 1)
{
aSeriesPoints = [].concat(aSeriesPoints);
var dMinVal, dMaxVal, bSorted = false;
if(minVal == null)
{
aSeriesPoints.sort(function(a, b){return b.val - a.val;});
bSorted = true;
dMinVal = aSeriesPoints[0].val;
}
else
{
dMinVal = minVal;
}
if(maxVal == null)
{
if(!bSorted)
{
aSeriesPoints.sort(function(a, b){return b.val - a.val;});
bSorted = true;
}
dMaxVal = aSeriesPoints[aSeriesPoints.length - 1].val;
}
else
{
dMaxVal = maxVal;
}
if(dMaxVal < 0 || dMinVal > 0)
{
oAxis.catAx[0].setDelete(true);
}
else
{
oAxis.catAx[0].setDelete(false);
}
}
}
this.chartSpace.recalcInfo.recalculateAxisVal = true;
this.chartSpace.recalculate();
}
};
//----------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------
// Manager // Manager
//----------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------
...@@ -2316,18 +2449,56 @@ function DrawingObjects() { ...@@ -2316,18 +2449,56 @@ function DrawingObjects() {
_this.checkSparklineGroupMinMaxVal = function(oSparklineGroup) _this.checkSparklineGroupMinMaxVal = function(oSparklineGroup)
{ {
var maxVal = null, minVal = null; var maxVal = null, minVal = null, i, j;
if(oSparklineGroup.type !== Asc.ESparklineType.Stacked && if(oSparklineGroup.type !== Asc.ESparklineType.Stacked &&
(Asc.SparklineAxisMinMax.Group === oSparklineGroup.minAxisType || Asc.SparklineAxisMinMax.Group === oSparklineGroup.maxAxisType)) (Asc.SparklineAxisMinMax.Group === oSparklineGroup.minAxisType || Asc.SparklineAxisMinMax.Group === oSparklineGroup.maxAxisType))
{ {
for(var i = 0; i < oSparklineGroup.arrSparklines.length; ++i) for(i = 0; i < oSparklineGroup.arrSparklines.length; ++i)
{ {
if (!oSparklineGroup.arrCachedSparklines[j]) { if (!oSparklineGroup.arrCachedSparklines[i]) {
var oSparklineView = new CSparklineView(); var oSparklineView = new CSparklineView();
oSparklineView.initFromSparkline(oSparklineGroup.arrSparklines[j], oSparklineGroup, worksheet); oSparklineView.initFromSparkline(oSparklineGroup.arrSparklines[i], oSparklineGroup, worksheet);
oSparklineGroup.addView(oSparklineView, j); oSparklineGroup.addView(oSparklineView, i);
}
var aPoints = getPtsFromSeries(oSparklineGroup.arrCachedSparklines[i].chartSpace.chart.plotArea.charts[0].series[0]);
for(j = 0; j < aPoints.length; ++j)
{
if(Asc.SparklineAxisMinMax.Group === oSparklineGroup.maxAxisType)
{
if(maxVal === null)
{
maxVal = aPoints[j].val;
}
else
{
if(maxVal < aPoints[j].val)
{
maxVal = aPoints[j].val;
}
}
}
if(Asc.SparklineAxisMinMax.Group === oSparklineGroup.minAxisType)
{
if(minVal === null)
{
minVal = aPoints[j].val;
}
else
{
if(minVal > aPoints[j].val)
{
minVal = aPoints[j].val;
}
}
}
}
}
if(maxVal !== null || minVal !== null)
{
for(i = 0; i < oSparklineGroup.arrSparklines.length; ++i)
{
oSparklineGroup.arrCachedSparklines[i].setMinMaxValAx(minVal, maxVal, oSparklineGroup);
} }
var aPoints = getPtsFromSeries(oSparklineView.chartSpace.chart.plotArea.charts[0].series[0]);
} }
} }
}; };
...@@ -2335,15 +2506,20 @@ function DrawingObjects() { ...@@ -2335,15 +2506,20 @@ function DrawingObjects() {
_this.drawSparkLineGroups = function(oDrawingContext, oSparklineGroups, range) _this.drawSparkLineGroups = function(oDrawingContext, oSparklineGroups, range)
{ {
var graphics = new CGraphics(); var graphics = new CGraphics(), i, j;
graphics.init(oDrawingContext.ctx, oDrawingContext.getWidth(0), oDrawingContext.getHeight(0), graphics.init(oDrawingContext.ctx, oDrawingContext.getWidth(0), oDrawingContext.getHeight(0),
oDrawingContext.getWidth(3)*nSparklineMultiplier, oDrawingContext.getHeight(3)*nSparklineMultiplier); oDrawingContext.getWidth(3)*nSparklineMultiplier, oDrawingContext.getHeight(3)*nSparklineMultiplier);
graphics.m_oFontManager = g_fontManager; graphics.m_oFontManager = g_fontManager;
graphics.SaveGrState(); graphics.SaveGrState();
for(var i = 0; i < oSparklineGroups.arrSparklineGroup.length; ++i) { for(i = 0; i < oSparklineGroups.arrSparklineGroup.length; ++i) {
var oSparklineGroup = oSparklineGroups.arrSparklineGroup[i]; var oSparklineGroup = oSparklineGroups.arrSparklineGroup[i];
for(var j = 0; j < oSparklineGroup.arrSparklines.length; ++j) { if(oSparklineGroup.type !== Asc.ESparklineType.Stacked &&
(Asc.SparklineAxisMinMax.Group === oSparklineGroup.minAxisType || Asc.SparklineAxisMinMax.Group === oSparklineGroup.maxAxisType))
{
_this.checkSparklineGroupMinMaxVal(oSparklineGroup);
}
for(j = 0; j < oSparklineGroup.arrSparklines.length; ++j) {
if (!oSparklineGroup.arrCachedSparklines[j]) { if (!oSparklineGroup.arrCachedSparklines[j]) {
var oSparklineView = new CSparklineView(); var oSparklineView = new CSparklineView();
oSparklineView.initFromSparkline(oSparklineGroup.arrSparklines[j], oSparklineGroup, worksheet); oSparklineView.initFromSparkline(oSparklineGroup.arrSparklines[j], oSparklineGroup, worksheet);
...@@ -2354,7 +2530,6 @@ function DrawingObjects() { ...@@ -2354,7 +2530,6 @@ function DrawingObjects() {
} }
oSparklineGroup.arrCachedSparklines[j].draw(graphics); oSparklineGroup.arrCachedSparklines[j].draw(graphics);
} }
} }
graphics.RestoreGrState(); graphics.RestoreGrState();
}; };
......
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