Commit fe5617ad authored by Sergey Luzyanin's avatar Sergey Luzyanin Committed by Alexander.Trofimov

Отрисовка спаклайнов

parent 7e9472db
...@@ -4439,9 +4439,34 @@ function sparklineGroup() { ...@@ -4439,9 +4439,34 @@ function sparklineGroup() {
this.colorHigh = null; this.colorHigh = null;
this.colorLow = null; this.colorLow = null;
this.f = '??'; this.f = '??';
this.arrSparklines = []; this.arrSparklines = [];
this.arrCachedSparklines = [];
} }
sparklineGroup.prototype.clearCached = function()
{
this.arrCachedSparklines.length = 0;
};
sparklineGroup.prototype.addView = function(oSparklineView)
{
this.arrCachedSparklines.push(oSparklineView);
};
sparklineGroup.prototype.draw = function(oDrawingContext)
{
var graphics = new CGraphics();
graphics.init(oDrawingContext.ctx, oDrawingContext.getWidth(0), oDrawingContext.getHeight(0), oDrawingContext.getWidth(3), oDrawingContext.getHeight(3));
graphics.m_oFontManager = g_fontManager;
for(var i = 0; i < this.arrCachedSparklines.length; ++i)
{
this.arrCachedSparklines[i].draw(graphics);
}
};
sparklineGroup.prototype.updateCache = function(wsView)
{
wsView.objectRender.createSparklineViews(this);
};
function sparkline() { function sparkline() {
this.sqref = '??'; // ToDo добавить значение по умолчанию this.sqref = '??'; // ToDo добавить значение по умолчанию
this.f = '??'; this.f = '??';
......
"use strict"; "use strict";
/* DrawingObjects.js /* DrawingObjects.js
* *
...@@ -305,6 +305,77 @@ prot["asc_setFormatCode"] = prot.asc_setFormatCode; ...@@ -305,6 +305,77 @@ prot["asc_setFormatCode"] = prot.asc_setFormatCode;
function CSparklineView()
{
this.col = null;
this.row = null;
this.ws = null;
this.extX = null;
this.extY = null;
this.chartSpace = null;
}
CSparklineView.prototype.initFromSparkline = function(oSparkline, oSparklineGroup, worksheetView)
{
this.ws = worksheetView;
var settings = new asc_ChartSettings();
switch(oSparklineGroup.type)
{
case Asc.ESparklineType.Column:
{
settings.type = c_oAscChartTypeSettings.barNormal;
break;
}
case Asc.ESparklineType.Stacked:
{
settings.type = c_oAscChartTypeSettings.barStacked;
break;
}
default:
{
settings.type = c_oAscChartTypeSettings.lineNormal;
break;
}
}
var ser = new asc_CChartSeria();
ser.Val.Formula = oSparkline.f;
var chartSeries = {series: [ser], parsedHeaders: {bLeft: false, bTop: false}};
var chart_space = DrawingObjectsController.prototype._getChartSpace(chartSeries, settings, true);
chart_space.setWorksheet(worksheetView.model);
this.chartSpace = chart_space;
var oBBox = worksheetView.model.getCell(oSparkline.sqref);
this.col = oBBox.c1;
this.row = oBBox.r1;
this.extX = worksheetView.getColumnWidth(oBBox.c1, 3);
this.extY = worksheetView.getRowHeight(oBBox.r1, 3);
CheckSpPrXfrm(this.chartSpace);
this.chartSpace.spPr.xfrm.setOffX(0);
this.chartSpace.spPr.xfrm.setOffY(0);
this.chartSpace.spPr.xfrm.setExtX(this.extX);
this.chartSpace.spPr.xfrm.setExtY(this.extY);
this.chartSpace.recalculate();
};
CSparklineView.prototype.draw = function(graphics)
{
var x = this.ws.getCellLeft(this.col, 3);
var y = this.ws.getCellTop(this.row, 3);
var extX = this.ws.getColumnWidth(this.col, 3);
var extY = this.ws.getRowHeight(this.row, 3);
if(Math.abs(this.extX - extX) > 0.01 || Math.abs(this.extY - extY) > 0.01)
{
this.chartSpace.spPr.xfrm.setExtX(extX);
this.chartSpace.spPr.xfrm.setExtY(extY);
this.extX = extX;
this.extY = extY;
this.chartSpace.recalculate();
}
graphics.m_oCoordTransform.tx = x;
graphics.m_oCoordTransform.ty = y;
};
//----------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------
// Manager // Manager
//----------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------
...@@ -1913,6 +1984,23 @@ function DrawingObjects() { ...@@ -1913,6 +1984,23 @@ function DrawingObjects() {
} }
}; };
_this.createSparklineViews = function(oSparkLineGroup)
{
oSparkLineGroup.clearCached();
for(var i = 0; i < oSparkLineGroup.arrSparklines.length; ++i)
{
var oSparklineView = new CSparklineView();
oSparklineView.initFromSparkline(oSparkLineGroup.arrSparklines[i], oSparkLineGroup, worksheet);
oSparkLineGroup.addView(oSparklineView);
}
};
_this.drawSparkLineGroup = function(oSparkLineGroup, oDrawingContext)
{
},
_this.rebuildChartGraphicObjects = function(data) _this.rebuildChartGraphicObjects = function(data)
{ {
if(!worksheet) if(!worksheet)
......
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