Commit d1cf17e4 authored by Dmitry.Vikulov's avatar Dmitry.Vikulov Committed by Alexander.Trofimov

Сделана поддержка шрифтов для диаграмм.

***Необходимы доработки в релизном меню:
- Добавлен класс asc_CChartHeader(вместо chart.title и т.д)
- Проверка валидности диапазона диаграммы теперь через api.asc_checkChartInterval

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@47246 954022d7-b5bf-4e40-9824-e11837661b57
parent 7d4eb966
This diff is collapsed.
......@@ -26,7 +26,6 @@ function ChartRender() {
}
}
//var arrBaseColors = ["#4572A7", "#AA4643", "#89A54E", "#71588F", "#4198AF", "#DB843D"];
var arrBaseColors = [];
function ChartStyleManager() {
......@@ -287,9 +286,9 @@ function ChartPreviewManager() {
// Create and minimize properties
var chart = new CChartData(false);
chart.xAxis.show = chart.xAxis.grid = false;
chart.yAxis.show = chart.yAxis.grid = false;
chart.legend.show = false;
chart.xAxis.bShow = chart.xAxis.bGrid = false;
chart.yAxis.bShow = chart.yAxis.bGrid = false;
chart.legend.bShow = false;
chart.type = chartType;
chart.styleId = parseInt(style);
......@@ -635,6 +634,7 @@ function calcAllMargin(isFormatCell,isformatCellScOy,minX,maxX,minY,maxY) {
//-----------------------------------------------------------------------------------
// Draw
//-----------------------------------------------------------------------------------
function checkDataRange(type,subType,dataRange,isRows,worksheet) {
var columns = false;
var rows = false;
......@@ -1387,12 +1387,12 @@ function drawChart(chart, arrValues, width, height) {
break;
}
if(!chart.yAxis.show)
if(!chart.yAxis.bShow)
{
bar._otherProps._ylabels = false;
bar._otherProps._noyaxis = true;
}
if(!chart.xAxis.show)
if(!chart.xAxis.bShow)
{
bar._otherProps._xlabels = false;
bar._otherProps._noxaxis = true;
......@@ -1416,8 +1416,8 @@ function drawChart(chart, arrValues, width, height) {
chart.yAxis.title = defaultYTitle;
if((!chart.xAxis.title || chart.xAxis.title == null || chart.xAxis.title == undefined || chart.xAxis.title == '') && chart.xAxis.bDefaultTitle)
chart.xAxis.title = defaultXTitle;
if((!chart.title || chart.title == null || chart.title == undefined || chart.title == '') && chart.bDefaultTitle)
chart.title = defaultTitle;
if((!chart.header.title || chart.header.title == null || chart.header.title == undefined || chart.header.title == '') && chart.header.bDefaultTitle)
chart.header.title = defaultTitle;
if (chart.yAxis.title)
bar._chartGutter._left = 35 + 29;
......@@ -1433,7 +1433,7 @@ function drawChart(chart, arrValues, width, height) {
//bar.Draw();
// Легенда
if (chart.legend.show && chart.legend.position != '') {
if (chart.legend.bShow && chart.legend.position != '') {
bar._otherProps._key_position = 'graph';
bar._otherProps._key = [];
bar._otherProps._key_halign = chart.legend.position;
......@@ -1494,9 +1494,9 @@ function drawChart(chart, arrValues, width, height) {
// Подписи данных
if(chart.type != 'Stock')
{
if (chart.showValue && bar.type == 'pie')
if (chart.bShowValue && bar.type == 'pie')
bar._otherProps._labels = data[0];
else if (chart.showValue)
else if (chart.bShowValue)
bar._otherProps._labels_above = true;
else
bar._otherProps._labels_above = false;
......@@ -1504,8 +1504,8 @@ function drawChart(chart, arrValues, width, height) {
}
// Название
if (chart.title) {
bar._chartTitle._text = chart.title;
if (chart.header.title) {
bar._chartTitle._text = chart.header.title;
bar._chartTitle._vpos = 32;
bar._chartTitle._hpos = 0.5;
bar._chartTitle._size = 18;
......@@ -1513,7 +1513,7 @@ function drawChart(chart, arrValues, width, height) {
if (chart.xAxis.title) {
var legendTop = 0;
var widthXtitle = bar.context.measureText(chart.xAxis.title).width
var widthXtitle = bar.context.measureText(chart.xAxis.title).width;
if(chart.legend.position == 'bottom')
legendTop = 30;
bar._xAxisTitle._text = chart.xAxis.title;
......@@ -1521,7 +1521,7 @@ function drawChart(chart, arrValues, width, height) {
}
if (chart.yAxis.title) {
var widthYtitle = bar.context.measureText(chart.yAxis.title).width
var widthYtitle = bar.context.measureText(chart.yAxis.title).width;
bar._yAxisTitle._text = chart.yAxis.title;
bar._yAxisTitle._align = 'rev';
var keyLeft = 0;
......@@ -1532,8 +1532,8 @@ function drawChart(chart, arrValues, width, height) {
}
// Основная сетка
bar._otherProps._background_grid_hlines = chart.xAxis.grid;
bar._otherProps._background_grid_vlines = chart.yAxis.grid;
bar._otherProps._background_grid_hlines = chart.xAxis.bGrid;
bar._otherProps._background_grid_vlines = chart.yAxis.bGrid;
var axis;
calcGutter(axis,chart.min,chart.max,chart.ymin,chart.ymax,chart.isSkip,chart.isFormatCell);
......@@ -1555,7 +1555,10 @@ function drawChart(chart, arrValues, width, height) {
bar.Draw(chart.min,chart.max,chart.ymin,chart.ymax,chart.isSkip,chart.isFormatCell,chart.isformatCellScOy);
}
//
//-----------------------------------------------------------------------------------
// Chart types
//-----------------------------------------------------------------------------------
function DrawScatterChart(chartCanvas, chartSubType, data, chart) {
var colors = generateColors(data.length * data[0].length, arrBaseColors);
......@@ -1646,6 +1649,7 @@ function DrawScatterChart(chartCanvas, chartSubType, data, chart) {
//addOptions('chart.gutter.bottom',50);
bar._chartGutter._bottom = 30;
//для соединения линий
bar._otherProps._area_border = chart.bShowBorder;
bar._otherProps._line = true;
bar._otherProps._linewidth = 2;
bar._otherProps._background_grid_color = 'graytext';
......@@ -1703,6 +1707,7 @@ function DrawPieChart(chartCanvas, chartSubType, data, chart) {
//для разрезанной кольцевой или разрезанной круговой
//bar._otherProps._exploded = 15;
bar._otherProps._area_border = chart.bShowBorder;
bar._otherProps._ylabels_count = 'auto';
bar._otherProps._colors = ['steelblue', 'IndianRed', 'Silver'];
bar._chartGutter._left = 45;
......@@ -1778,6 +1783,7 @@ function DrawLineChart(chartCanvas, chartType, chartSubType, data, chart) {
bar._chartGutter._bottom = 35;
}
bar._otherProps._area_border = chart.bShowBorder;
bar._otherProps._background_grid_autofit_numvlines = data.length;
bar._otherProps._background_grid_color = 'graytext';
bar._otherProps._background_barcolor1 = 'white';
......@@ -1862,6 +1868,7 @@ function DrawBarChart(chartCanvas, chartSubType, data, chart) {
}
}
bar._otherProps._area_border = chart.bShowBorder;
bar._otherProps._ylabels_count = 'auto';
bar._otherProps._variant = 'bar';
bar._chartGutter._left = 35;
......@@ -1949,6 +1956,7 @@ function DrawHBarChart(chartCanvas, chartSubType, data, chart) {
}
//bar._otherProps._labels = ['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'];
bar._otherProps._area_border = chart.bShowBorder;
bar._otherProps._ylabels_count = 'auto';
bar._chartGutter._left = 35;
bar._chartGutter._bottom = 35;
......
......@@ -282,7 +282,7 @@
this.context.fillRect(0,0,this.canvas.width,this.canvas.height);
// border
if ( !g_bChartPreview ) {
if ( !g_bChartPreview && this._otherProps._area_border ) {
this.context.beginPath();
this.context.rect(0, 0, this.canvas.width,this.canvas.height);
this.context.strokeStyle = "black";
......
......@@ -178,6 +178,7 @@ OfficeExcel.OtherProps = function()
this._borders = true;
this._border = false;
this._area_border = true; // ãðàíèöà äëÿ âñåé îáëàñòè äèàãðàììû
this._border_color = 'rgba(255,255,255,0.5)';
this._align = 'center';
......
......@@ -416,7 +416,7 @@
//this.context.strokeRect(10,10,this.canvas.width-150,this.canvas.height-150)
// border
if ( !g_bChartPreview ) {
if ( !g_bChartPreview && this._otherProps._area_border ) {
this.context.beginPath();
this.context.rect(0, 0, this.canvas.width,this.canvas.height);
this.context.strokeStyle = "black";
......
......@@ -499,7 +499,7 @@
//this.context.strokeRect(10,10,this.canvas.width-150,this.canvas.height-150)
// border
if ( !g_bChartPreview ) {
if ( !g_bChartPreview && this._otherProps._area_border ) {
this.context.beginPath();
this.context.rect(0, 0, this.canvas.width,this.canvas.height);
this.context.strokeStyle = "black";
......
......@@ -540,7 +540,7 @@
//this.context.strokeRect(10,10,this.canvas.width-150,this.canvas.height-150)
// border
if ( !g_bChartPreview ) {
if ( !g_bChartPreview && this._otherProps._area_border ) {
this.context.beginPath();
this.context.rect(0, 0, this.canvas.width,this.canvas.height);
this.context.strokeStyle = "black";
......
......@@ -480,7 +480,7 @@
//this.context.strokeRect(10,10,this.canvas.width-150,this.canvas.height-150)
// border
if ( !g_bChartPreview ) {
if ( !g_bChartPreview && this._otherProps._area_border ) {
this.context.beginPath();
this.context.rect(0, 0, this.canvas.width,this.canvas.height);
this.context.strokeStyle = "black";
......
......@@ -886,7 +886,7 @@ function BinaryChartWriter(memory)
this.WriteChartContent = function(chart)
{
var oThis = this;
if(null != chart.legend && true == chart.legend.show)
if(null != chart.legend && true == chart.legend.bShow)
this.bs.WriteItem(c_oSer_ChartType.Legend, function(){oThis.WriteLegend(chart.legend);});
if(null != chart.title && ("" != chart.title || true == chart.bDefaultTitle))
{
......@@ -913,8 +913,8 @@ function BinaryChartWriter(memory)
if(null != byteLegendPos)
this.bs.WriteItem(c_oSer_ChartLegendType.LegendPos, function(){oThis.memory.WriteByte(byteLegendPos);});
}
if(null != legend.overlay)
this.bs.WriteItem(c_oSer_ChartLegendType.Overlay, function(){oThis.memory.WriteBool(legend.overlay);});
if(null != legend.bOverlay)
this.bs.WriteItem(c_oSer_ChartLegendType.Overlay, function(){oThis.memory.WriteBool(legend.bOverlay);});
};
this.WritePlotArea = function(chart)
{
......@@ -946,10 +946,10 @@ function BinaryChartWriter(memory)
this.memory.WriteByte(c_oSer_ChartCatAxType.Title);
this.memory.WriteString2(axis.title);
}
if(null != axis.grid)
this.bs.WriteItem(c_oSer_ChartCatAxType.MajorGridlines, function(){oThis.memory.WriteBool(axis2.grid);});
if(null != axis.show)
this.bs.WriteItem(c_oSer_ChartCatAxType.Delete, function(){oThis.memory.WriteBool(!axis.show);});
if(null != axis.bGrid)
this.bs.WriteItem(c_oSer_ChartCatAxType.MajorGridlines, function(){oThis.memory.WriteBool(axis2.bGrid);});
if(null != axis.bShow)
this.bs.WriteItem(c_oSer_ChartCatAxType.Delete, function(){oThis.memory.WriteBool(!axis.bShow);});
if(bBottom)
this.bs.WriteItem(c_oSer_ChartCatAxType.AxPos, function(){oThis.memory.WriteByte(EChartAxPos.chartaxposBottom);});
else
......@@ -1025,7 +1025,7 @@ function BinaryChartWriter(memory)
this.bs.WriteItemWithLength(function(){oThis.WriteSeries(chartRange, chart.data, chart.type);});
}
}
if(null != chart.showValue)
if(null != chart.bShowValue)
{
this.memory.WriteByte(c_oSer_BasicChartType.DataLabels);
this.memory.WriteByte(c_oSerPropLenType.Variable);
......@@ -1212,17 +1212,17 @@ function BinaryChartWriter(memory)
{
this.memory.WriteByte(c_oSer_ChartSeriesMarkerType.Symbol);
this.memory.WriteByte(c_oSerPropLenType.Byte);
this.memory.WriteByte(marker.showValue);
this.memory.WriteByte(marker.bShowValue);
}
};
this.WriteDataLabels = function(chart)
{
var oThis = this;
if(null != chart.showValue)
if(null != chart.bShowValue)
{
this.memory.WriteByte(c_oSer_ChartSeriesDataLabelsType.ShowVal);
this.memory.WriteByte(c_oSerPropLenType.Byte);
this.memory.WriteBool(chart.showValue);
this.memory.WriteBool(chart.bShowValue);
}
};
}
......@@ -1235,7 +1235,7 @@ function Binary_ChartReader(stream, chart)
this.chartType = null;
this.PreRead = function()
{
this.chart.legend.show = false;
this.chart.legend.bShow = false;
}
this.Read = function(length)
{
......@@ -1277,16 +1277,16 @@ function Binary_ChartReader(stream, chart)
var oThis = this;
if ( c_oSer_ChartType.Legend === type )
{
this.chart.legend.show = true;
this.chart.legend.bShow = true;
res = this.bcr.Read1(length, function(t,l){
return oThis.ReadLegend(t,l);
});
}
else if ( c_oSer_ChartType.Title === type )
{
this.chart.title = this.stream.GetString2LE(length);
if("" == this.chart.title)
this.chart.bDefaultTitle = true;
this.chart.header.title = this.stream.GetString2LE(length);
if("" == this.chart.header.title)
this.chart.header.bDefaultTitle = true;
}
else if ( c_oSer_ChartType.PlotArea === type )
{
......@@ -1318,8 +1318,8 @@ function Binary_ChartReader(stream, chart)
}
}
}
this.chart.xAxis.show = this.chart.yAxis.show = false;
this.chart.xAxis.grid = this.chart.yAxis.grid = false;
this.chart.xAxis.bShow = this.chart.yAxis.bShow = false;
this.chart.xAxis.bGrid = this.chart.yAxis.bGrid = false;
var fExecAxis = function(oFrom, oTo)
{
for(var i in oFrom)
......@@ -1330,9 +1330,9 @@ function Binary_ChartReader(stream, chart)
if(null != yAxis)
fExecAxis(yAxis, this.chart.yAxis);
//
var bTemp = this.chart.xAxis.grid;
this.chart.xAxis.grid = this.chart.yAxis.grid;
this.chart.yAxis.grid = bTemp;
var bTemp = this.chart.xAxis.bGrid;
this.chart.xAxis.bGrid = this.chart.yAxis.bGrid;
this.chart.yAxis.bGrid = bTemp;
if(c_oAscChartType.hbar == this.chartType)
{
var oTemp = this.chart.xAxis;
......@@ -1372,7 +1372,7 @@ function Binary_ChartReader(stream, chart)
}
}
else if ( c_oSer_ChartLegendType.Overlay === type )
this.chart.legend.overlay = this.stream.GetBool();
this.chart.legend.bOverlay = this.stream.GetBool();
else
res = c_oSerConstants.ReadUnknown;
return res;
......@@ -1452,9 +1452,9 @@ function Binary_ChartReader(stream, chart)
oAx.bDefaultTitle = true;
}
else if ( c_oSer_ChartCatAxType.MajorGridlines === type )
oAx.grid = this.stream.GetBool();
oAx.bGrid = this.stream.GetBool();
else if ( c_oSer_ChartCatAxType.Delete === type )
oAx.show = !this.stream.GetBool();
oAx.bShow = !this.stream.GetBool();
else if ( c_oSer_ChartCatAxType.AxPos === type )
oAx.axPos = this.stream.GetUChar();
else
......@@ -1624,7 +1624,7 @@ function Binary_ChartReader(stream, chart)
var res = c_oSerConstants.ReadOk;
var oThis = this;
if ( c_oSer_ChartSeriesDataLabelsType.ShowVal === type )
this.chart.showValue = this.stream.GetBool();
this.chart.bShowValue = this.stream.GetBool();
else
res = c_oSerConstants.ReadUnknown;
return res;
......
......@@ -56,3 +56,20 @@ var c_oAscChartType = {
Accent5: 7,
Accent6: 8
};
var c_oAscTransactionState = {
No: -1,
Start: 0,
Stop: 1
};
var c_oAscCellAnchorType = {
cellanchorAbsolute: 0,
cellanchorOneCell: 1,
cellanchorTwoCell: 2
};
var c_oAscChartDefines = {
defaultChartWidth: 478,
defaultChartHeight: 286
};
\ No newline at end of file
......@@ -2089,7 +2089,8 @@
<input type='text' style='margin-left: 10px;' id='xAxisTitle' value='X axis'><br>
<span style='margin-left: 10px;'>Y axis title</span>
<input type='text' style='margin-left: 10px;' id='yAxisTitle' value='Y axis'><br>
<input type='checkbox' id='valueShow' style='margin-left: 10px;'>Show values<br>
<input type='checkbox' id='valueShow' style='margin-left: 10px;'>Show values
<input type='checkbox' id='borderShow' style='margin-left: 10px;'>Show border<br>
</fieldset>
<fieldset id="legendField">
<legend>Legend</legend>
......
......@@ -1965,6 +1965,11 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
}
},
asc_checkChartInterval: function(type, subtype, interval, isRows) {
var ws = this.wb.getWorksheet();
return ws.objectRender.checkChartInterval(type, subtype, interval, isRows);
},
// Для вставки диаграмм в Word
asc_getBinaryFileWriter: function() {
this.wb._initCommentsToSave();
......@@ -2762,6 +2767,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
prot["asc_deleteSelectedDrawingObject"] = prot.asc_deleteSelectedDrawingObject;
prot["asc_setSelectedDrawingObjectLayer"] = prot.asc_setSelectedDrawingObjectLayer;
prot["asc_getChartPreviews"] = prot.asc_getChartPreviews;
prot["asc_checkChartInterval"] = prot.asc_checkChartInterval;
prot["asc_getBinaryFileWriter"] = prot.asc_getBinaryFileWriter;
prot["asc_getWordChartObject"] = prot.asc_getWordChartObject;
prot["asc_cleanWorksheet"] = prot.asc_cleanWorksheet;
......
......@@ -2081,7 +2081,7 @@
chartForm.find("#chartRange").val(interval);
chartForm.find("#chartRange").bind("keyup", function() {
var result = range.asc_checkInterval(chartForm.find("#chartType").val(),chartForm.find("#chartSubType").val(),chartForm.find("#chartRange").val(),chartForm.find("#dataRows").is(":checked"));
var result = api.asc_checkChartInterval(chartForm.find("#chartType").val(), chartForm.find("#chartSubType").val(), chartForm.find("#chartRange").val(), chartForm.find("#dataRows").is(":checked"));
if (result)
chartForm.find("#chartRange").css("color", "black");
else
......@@ -2096,15 +2096,16 @@
else
chartForm.find("#dataColumns").attr("checked", range.asc_getColumnsFlag());
chartForm.find("#chartTitle").val(chart.asc_getTitle());
chartForm.find("#chartTitle").val(chart.asc_getHeader().asc_getTitle());
chartForm.find("#valueShow").attr("checked", chart.asc_getShowValueFlag());
chartForm.find("#borderShow").attr("checked", chart.asc_getShowBorderFlag());
var xAxis = chart.asc_getXAxis();
chartForm.find("#xAxisShow").attr("checked", xAxis.asc_getShowFlag());
chartForm.find("#xGridShow").attr("checked", xAxis.asc_getGridFlag());
chartForm.find("#xAxisTitle").val(xAxis.asc_getTitle() ? xAxis.asc_getTitle() : "");
var yAxis = chart.asc_getXAxis();
var yAxis = chart.asc_getYAxis();
chartForm.find("#yAxisShow").attr("checked", yAxis.asc_getShowFlag());
chartForm.find("#yGridShow").attr("checked", yAxis.asc_getGridFlag());
chartForm.find("#yAxisTitle").val(yAxis.asc_getTitle() ? yAxis.asc_getTitle() : "");
......@@ -2123,8 +2124,10 @@
var isSelected = (chart.type != null) && (chart.type != "");
var range = chart.asc_getRange();
if (!range.asc_checkInterval(chartForm.find("#chartType").val(),chartForm.find("#chartSubType").val(),chartForm.find("#chartRange").val(),chartForm.find("#dataRows").is(":checked")))
if ( !api.asc_checkChartInterval(chartForm.find("#chartType").val(),chartForm.find("#chartSubType").val(),chartForm.find("#chartRange").val(),chartForm.find("#dataRows").is(":checked")) )
return;
range.asc_setRowsFlag(chartForm.find("#dataRows").is(":checked"));
range.asc_setColumnsFlag(chartForm.find("#dataColumns").is(":checked"));
range.asc_setInterval(chartForm.find("#chartRange").val());
......@@ -2132,8 +2135,9 @@
chart.asc_setType(chartForm.find("#chartType").find("option:selected").val());
chart.asc_setSubType(chartForm.find("#chartSubType").find("option:selected").val());
chart.asc_setTitle(chartForm.find("#chartTitle").val());
chart.asc_getHeader().asc_setTitle(chartForm.find("#chartTitle").val());
chart.asc_setShowValueFlag(chartForm.find("#valueShow").is(":checked"));
chart.asc_setShowBorderFlag(chartForm.find("#borderShow").is(":checked"));
if(chart.type != null && chart.type == 'Stock' && !isSelected)
{
......@@ -2160,7 +2164,6 @@
var legend = chart.asc_getLegend();
legend.asc_setShowFlag(chartForm.find("#legendShow").is(":checked"));
//legend.asc_setShowFlag(true);
legend.asc_setPosition("");
if (chartForm.find("#legendLeft").is(":checked"))
......
......@@ -324,6 +324,14 @@ var UndoRedoDataTypes = new function() {
this.SingleProperty = 33;
this.RgbColor = 34;
this.ThemeColor = 35;
this.ChartData = 36;
this.ChartRange = 37;
this.ChartHeader = 38;
this.ChartAxisX = 39;
this.ChartAxisY = 40;
this.ChartLegend = 41;
this.ChartFont = 42;
this.Create = function(nType)
{
switch(nType)
......@@ -364,6 +372,13 @@ var UndoRedoDataTypes = new function() {
case this.SingleProperty: return new UndoRedoData_SingleProperty(); break;
case this.RgbColor: return new RgbColor(); break;
case this.ThemeColor: return new ThemeColor(); break;
case this.ChartData: return new asc_CChart(); break;
case this.ChartRange: return new asc_CChartRange(); break;
case this.ChartHeader: return new asc_CChartHeader(); break;
case this.ChartAxisX: return new asc_CChartAxisX(); break;
case this.ChartAxisY: return new asc_CChartAxisY(); break;
case this.ChartLegend: return new asc_CChartLegend(); break;
case this.ChartFont: return new asc_CChartFont(); break;
}
return null;
};
......@@ -2021,12 +2036,12 @@ UndoRedoDrawingObject.prototype = {
if ( !api.wb )
return;
var ws = api.wb.getWorksheetById(nSheetId);
var objectRender = ws.objectRender;
Data.worksheet = ws;
if ( Data.isChart() )
Data.chart.range.intervalToIntervalObject();
objectRender.intervalToIntervalObject(Data.chart);
var objectRender = ws.objectRender;
if ( bUndo == true )
objectRender.Undo(Type, Data);
else
......
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