From 318d4ba97ea3b05b6beb3edd27e43461d544fbe1 Mon Sep 17 00:00:00 2001 From: csh Date: Fri, 23 Dec 2022 10:47:34 +0800 Subject: [PATCH] =?UTF-8?q?release=201.01=20=E4=BF=AE=E5=A4=8Dchart?= =?UTF-8?q?=E5=9B=BE=E7=9A=84=E4=B8=80=E4=BA=9Bbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Demo/wordHelp.tsl | 126 ++++++++++---------- funcext/TSOffice/TOfficeObj.tsf | 65 ++++++---- funcext/TSOffice/TSUtils/ErrorMessage.tsf | 4 +- funcext/TSOffice/TSUtils/TSChart.tsf | 1 + funcext/TSOffice/worksheet/xlsxRichText.tsf | 18 --- 5 files changed, 106 insertions(+), 108 deletions(-) delete mode 100644 funcext/TSOffice/worksheet/xlsxRichText.tsf diff --git a/Demo/wordHelp.tsl b/Demo/wordHelp.tsl index 0affe97..ecd1153 100644 --- a/Demo/wordHelp.tsl +++ b/Demo/wordHelp.tsl @@ -1,6 +1,7 @@ ///Create by Tinysoft. ///自动生成 TSDocxFile 帮助文件 -mtic;SetProfiler(7); +mtic; +//SetProfiler(7); docx := new TSDocxFile(); [err, errmsg] := docx.NewFile(); if err then @@ -63,11 +64,11 @@ _Faq(docx); ///目录 docx.AddTableContent(paragraphTitle, 1, 3); -v := docx.SaveAs('', 'D:/temp/help.docx'); -println('Test Over!\n Save {}: {},time={}', file, v, mtoc); +v := docx.SaveAs('', 'TSDocFile-Help.docx'); +println('Test Over!\n Save {}: {},time={}秒', file, v, mtoc); -info := GetProfilerInfo(true); -exportfile(ftstream(),'','f:\\temp\\ProfilerInfo.stm',info); +//info := GetProfilerInfo(true); +//exportfile(ftstream(),'','f:\\temp\\ProfilerInfo.stm',info); /////////////////////////////////////////////////////////////////////////////////////////////// ///子函数 @@ -695,6 +696,7 @@ Begin docx.AddChart(chart, -1); _AddTitle(docx, '案例二:广东省2019——2021年GDP(折线图)', 2); + chart.Name := 'GD-GDP-2'; chart.Type := 'line'; chart.ShowBubbleSize := false; chart.ShowPercent := false; @@ -707,6 +709,7 @@ Begin docx.AddChart(chart, -1); _AddTitle(docx, '案例三:广东省2021年GDP(饼状图)', 2); + chart.Name := 'GD-GDP-3'; chart.Title := '广东省2021年GDP(单位:亿元)'; chart.Type := 'pie'; chart.ShowCatName := true; @@ -714,67 +717,66 @@ Begin chart.AddSeries('广东省', names, (tmpData[2])[1:]); docx.AddChart(chart, -1); - charts := array(("Type":"area","图表类型":"面积图"), - ("Type":"areastacked","图表类型":""), - ("Type":"areapercentstacked","图表类型":""), - ("Type":"area3d","图表类型":""), - ("Type":"area3dstacked","图表类型":""), - ("Type":"area3dpercentstacked","图表类型":""), - ("Type":"bar","图表类型":""), - ("Type":"barstacked","图表类型":""), - ("Type":"barpercentstacked","图表类型":""), - ("Type":"bar3dclustered","图表类型":""), - ("Type":"bar3dstacked","图表类型":""), - ("Type":"bar3dpercentstacked","图表类型":""), - ("Type":"bar3dconeclustered","图表类型":""), - ("Type":"bar3dconestacked","图表类型":""), - ("Type":"bar3dconepercentstacked","图表类型":""), - ("Type":"bar3dpyramidclustered","图表类型":""), - ("Type":"bar3dpyramidstacked","图表类型":""), - ("Type":"bar3dpyramidpercentstacked","图表类型":""), - ("Type":"bar3dcylinderclustered","图表类型":""), - ("Type":"bar3dcylinderstacked","图表类型":""), - ("Type":"bar3dcylinderpercentstacked","图表类型":""), - ("Type":"col","图表类型":""), - ("Type":"colstacked","图表类型":""), - ("Type":"colpercentstacked","图表类型":""), - ("Type":"col3d","图表类型":""), - ("Type":"col3dclustered","图表类型":""), - ("Type":"col3dstacked","图表类型":""), - ("Type":"col3dpercentstacked","图表类型":""), - ("Type":"col3dcone","图表类型":""), - ("Type":"col3dconeclustered","图表类型":""), - ("Type":"col3dconestacked","图表类型":""), - ("Type":"col3dconepercentstacked","图表类型":""), - ("Type":"col3dpyramid","图表类型":""), - ("Type":"col3dpyramidclustered","图表类型":""), - ("Type":"col3dpyramidstacked","图表类型":""), - ("Type":"col3dpyramidpercentstacked","图表类型":""), - ("Type":"col3dcylinder","图表类型":""), - ("Type":"col3dcylinderclustered","图表类型":""), - ("Type":"col3dcylinderstacked","图表类型":""), - ("Type":"col3dcylinderpercentstacked","图表类型":""), - ("Type":"bubble","图表类型":""), - ("Type":"bubble3d","图表类型":""), - ("Type":"doughnut","图表类型":""), - ("Type":"line","图表类型":""), - ("Type":"pie3d","图表类型":""), - ("Type":"pie","图表类型":""), - ("Type":"pieofpiechart","图表类型":""), - ("Type":"barofpiechart","图表类型":""), - ("Type":"radar","图表类型":""), - ("Type":"scatter","图表类型":""), - ("Type":"surface3d","图表类型":""), - ("Type":"wireframesurface3d","图表类型":""), - ("Type":"contour","图表类型":""), - ("Type":"wireframecontour","图表类型":"")); + charts := array(("Type":"area","图表类型":"标准二维面积图"), + ("Type":"areastacked","图表类型":"二维堆积面积图"), + ("Type":"areapercentstacked","图表类型":"二维百分比堆积面积图"), + ("Type":"area3d","图表类型":"标准三维面积图"), + ("Type":"area3dstacked","图表类型":"三维堆积面积图"), + ("Type":"area3dpercentstacked","图表类型":"三维百分比堆积面积图"), + ("Type":"bar","图表类型":"二维簇状条形图"), + ("Type":"barstacked","图表类型":"二维堆积条形图"), + ("Type":"barpercentstacked","图表类型":"二维百分比堆积条形图"), + ("Type":"bar3dclustered","图表类型":"三维簇状条形图"), + ("Type":"bar3dstacked","图表类型":"三维堆积条形图"), + ("Type":"bar3dpercentstacked","图表类型":"三维百分比堆积条形图"), + ("Type":"bar3dconeclustered","图表类型":"三维簇状水平圆锥图"), + ("Type":"bar3dconestacked","图表类型":"三维堆积水平圆锥图"), + ("Type":"bar3dconepercentstacked","图表类型":"三维堆积百分比水平圆锥图"), + ("Type":"bar3dpyramidclustered","图表类型":"三维簇状水平棱锥图"), + ("Type":"bar3dpyramidstacked","图表类型":"三维堆积水平棱锥图"), + ("Type":"bar3dpyramidpercentstacked","图表类型":"三维堆积百分比水平棱锥图"), + ("Type":"bar3dcylinderclustered","图表类型":"三维簇状水平圆柱图"), + ("Type":"bar3dcylinderstacked","图表类型":"三维堆积水平圆柱图"), + ("Type":"bar3dcylinderpercentstacked","图表类型":"三维堆积百分比水平圆柱图"), + ("Type":"col","图表类型":"二维簇状柱形图"), + ("Type":"colstacked","图表类型":"二维堆积柱形图"), + ("Type":"colpercentstacked","图表类型":"二维百分比堆积柱形图"), + ("Type":"col3d","图表类型":"三维簇状柱形图"), + ("Type":"col3dclustered","图表类型":"三维柱形图"), + ("Type":"col3dstacked","图表类型":"三维堆积柱形图"), + ("Type":"col3dpercentstacked","图表类型":"三维百分比堆积柱形图"), + ("Type":"col3dcone","图表类型":"三维圆锥图"), + ("Type":"col3dconeclustered","图表类型":"三维簇状圆锥图"), + ("Type":"col3dconestacked","图表类型":"三维堆积圆锥图"), + ("Type":"col3dconepercentstacked","图表类型":"三维百分比堆积圆锥图"), + ("Type":"col3dpyramid","图表类型":"三维棱锥图"), + ("Type":"col3dpyramidclustered","图表类型":"三维簇状棱锥图"), + ("Type":"col3dpyramidstacked","图表类型":"三维堆积棱锥图"), + ("Type":"col3dpyramidpercentstacked","图表类型":"三维百分比堆积棱锥图"), + ("Type":"col3dcylinder","图表类型":"三维圆柱图"), + ("Type":"col3dcylinderclustered","图表类型":"三维簇状圆柱图"), + ("Type":"col3dcylinderstacked","图表类型":"三维堆积圆柱图"), + ("Type":"col3dcylinderpercentstacked","图表类型":"三维百分比堆积圆柱图"), + ("Type":"bubble","图表类型":"气泡图"), + ("Type":"bubble3d","图表类型":"3D气泡图"), + ("Type":"doughnut","图表类型":"圆环图"), + ("Type":"line","图表类型":"折线图"), + ("Type":"pie3d","图表类型":"三维饼图"), + ("Type":"pie","图表类型":"饼图"), + ("Type":"radar","图表类型":"雷达图"), + ("Type":"scatter","图表类型":"散点图"), + ("Type":"surface3d","图表类型":"三维曲面图"), + ("Type":"wireframesurface3d","图表类型":"三维曲面图(框架图)"), + ("Type":"contour","图表类型":"曲面图"), + ("Type":"wireframecontour","图表类型":"曲面图(俯视框架图)")); _AddTitle(docx, '系统支持的图表类型', 2); - tbl := docx.CreateTable(charts); + tbl := docx.CreateTable(charts, true, true); tbl.Format.Indent := 500; tbl.format.IndentType := 'dxa'; //设置列宽 tbl.ColumnWidth(1, 2000); - tbl.ColumnWidth(2, 12000); + tbl.ColumnWidth(2, 6000); + tbl.ColumnWidth(3, 8000); tbl := docx.InsertTable(tbl, -1); println(' >>OK\n'); @@ -973,12 +975,12 @@ Begin if istable(sysparams[f]) then Begin return sysParams[f, className]; End; - sysparams[f] := array(); [err,fh] := io_open(f); if err then return array(); [err, data] := io_read(fh); io_close(fh); if err then return array(); + sysparams[f] := array(); comment := ''; cName := ''; diff --git a/funcext/TSOffice/TOfficeObj.tsf b/funcext/TSOffice/TOfficeObj.tsf index 552596d..32ed4fe 100644 --- a/funcext/TSOffice/TOfficeObj.tsf +++ b/funcext/TSOffice/TOfficeObj.tsf @@ -1095,6 +1095,7 @@ type TChartImpl=class(NodeInfo) ,("field":"Legend","name":Legend.NodeName,"obj":Legend,"attrEx":"","nodeType":"","attrName":"", "desc":"disable", "class":"TLegend") ,("field":"Plotarea","name":Plotarea.NodeName,"obj":Plotarea,"attrEx":"","nodeType":"","attrName":"", "desc":"disable", "class":"TplotArea") ,("field":"ShowBlanksAs","name":"ShowBlanksAs","obj":ShowBlanksAs,"attrEx":"","nodeType":"","attrName":"", "desc":"此元素指定如何在图表上绘制空白单元格。", "class":"") + ,("field":"plotVisOnly","name":"plotVisOnly","obj":plotVisOnly,"attrEx":"","nodeType":"","attrName":"", "desc":"此元素指定如何在图表上绘制空白单元格。", "class":"") ,("field":"ChartNode","name":"ChartNode","obj":ChartNode,"attrEx":"","nodeType":"","attrName":"", "desc":"disable", "class":"") ,("field":"C","name":"C","obj":C,"attrEx":"","nodeType":"","attrName":"", "desc":"disable", "class":"") ,("field":"xmlObj","name":"xmlObj","obj":xmlObj,"attrEx":"","nodeType":"","attrName":"", "desc":"disable", "class":"") @@ -1130,6 +1131,7 @@ type TChartImpl=class(NodeInfo) Legend; Plotarea; ShowBlanksAs; + plotVisOnly; ChartNode; C; xmlObj; @@ -3005,8 +3007,8 @@ type TView3D=class(NodeInfo) Function GetChildren(); override; Begin HandleChildren(); - return array(("field":"RotX","name":"c:rotX","obj":RotX,"attrEx":"rgb","nodeType":"","attrName":"", "desc":"", "class":"") - ,("field":"RotY","name":"c:rotY","obj":RotY,"attrEx":"index","nodeType":"","attrName":"", "desc":"", "class":"") + return array(("field":"RotX","name":"c:rotX","obj":RotX,"attrEx":"","nodeType":"","attrName":"", "desc":"", "class":"") + ,("field":"RotY","name":"c:rotY","obj":RotY,"attrEx":"","nodeType":"","attrName":"", "desc":"", "class":"") ,("field":"RAngAx","name":"c:rAngAx","obj":RAngAx,"attrEx":"","nodeType":"","attrName":"", "desc":"", "class":"") ,("field":"DepthPercent","name":"c:depthPercent","obj":DepthPercent,"attrEx":"","nodeType":"","attrName":"", "desc":"", "class":"") ,("field":"Perspective","name":"c:perspective","obj":Perspective,"attrEx":"","nodeType":"","attrName":"", "desc":"", "class":"") @@ -8772,10 +8774,11 @@ Type TChart = Class(TChartImpl) Serialize(); //以下数据不更新,只更新Series Plotarea.Layout := nil; - Plotarea.CatAx := nil; - Plotarea.ValAx := nil; - Plotarea.SerAx := nil; - Plotarea.SpPr := nil; + Plotarea.CatAx := new TcAxs(Plotarea, 'c:catAx'); + Plotarea.ValAx := new TcAxs(Plotarea, 'c:valAx'); + Plotarea.SerAx := new TcAxs(Plotarea, 'c:serAx'); + Plotarea.SpPr := new TspPr(Plotarea, 'c:spPr'); + tmp := Plotarea.Chart.ExtNodes; Plotarea.Chart := new TcCharts(); Plotarea.Chart.ExtNodes := tmp; @@ -8937,7 +8940,7 @@ private SerAx.AxID := 832256642; SerAx.Scaling.Max := YAxis.Max; SerAx.Scaling.Min := YAxis.Min; - CatAx.Scaling.Orientation := YAxis.ReverseOrder ? 'maxMin' : 'minMax'; + SerAx.Scaling.Orientation := YAxis.ReverseOrder ? 'maxMin' : 'minMax'; SerAx.Del := YAxis.None; SerAx.AxPos := XAxis.ReverseOrder ? 't' : 'b'; SerAx.TickLblPos := 'nextTo'; @@ -9179,7 +9182,7 @@ private setXVal(ser.XVal, i); setYVal(ser.YVal, i); setBubbleSize(ser.BubbleSize, i); - setBubble3D(ser.Bubble3D, i); + setBubble3D(ser, i); End; o.chart.Ser := SerArr; End; @@ -9196,33 +9199,38 @@ private strRef.strCache.pt.V := name; End; - Function setBubble3D(Bubble3D, i); + Function setBubble3D(ser, i); Begin if Type <> 'bubble3d' then return; - Bubble3D := true; + ser.Bubble3D := true; End; Function setBubbleSize(BubbleSize, i); Begin if not (Type in array('bubble', 'bubble3d')) then return; - BubbleSize.NumRef.F := Series[i]['Values']; + _setVal(BubbleSize, i); End; Function setYVal(Val, i); Begin if not (Type in array('scatter', 'bubble', 'bubble3d')) then return; - setVal(Val, i); + _setVal(Val, i); End; Function setXVal(xVal, i); Begin if not (Type in array('scatter')) then return; - setCat(xVal, i); + _setCat(xVal, i); End; Function setVal(Val, ind); Begin if Type in array('scatter', 'bubble', 'bubble3d') then return; + _setVal(Val, ind); + End; + + Function _setVal(Val, ind); + Begin data := Series[ind]['Values']; if ifstring(data) then Val.NumRef.F := data; //excel图表(Sheet1!$C$2:$C$6) @@ -9244,6 +9252,11 @@ private Function setCat(Cat, ind); Begin if Type in array('scatter', 'bubble', 'bubble3d') then return; + _setCat(Cat, ind); + End; + + Function _setCat(Cat, ind); + Begin Categories := Series[ind]['Categories']; if ifstring(Categories) then cat.StrRef.F := Categories; //excel图表(Sheet1!$B$2:$B$6) @@ -9419,7 +9432,7 @@ private 'col3dcylinderstacked': 'bar3DChart', 'col3dcylinderpercentstacked': 'bar3DChart', 'bubble': 'bubbleChart', - 'bubble3D': 'bubbleChart'); + 'bubble3d': 'bubbleChart'); return 'c:' $ m[t]; End; @@ -9439,44 +9452,44 @@ private m := array( 'area': 'standard', 'areastacked': 'stacked', - 'areapercentstacked': 'percentstacked', + 'areapercentstacked': 'percentStacked', 'area3d': 'standard', 'area3dstacked': 'stacked', - 'area3dpercentstacked': 'percentstacked', + 'area3dpercentstacked': 'percentStacked', 'bar': 'clustered', 'barstacked': 'stacked', - 'barpercentstacked': 'percentstacked', + 'barpercentstacked': 'percentStacked', 'bar3dclustered': 'clustered', 'bar3dstacked': 'stacked', - 'bar3dpercentstacked': 'percentstacked', + 'bar3dpercentstacked': 'percentStacked', 'bar3dconeclustered': 'clustered', 'bar3dconestacked': 'stacked', - 'bar3dconepercentstacked': 'percentstacked', + 'bar3dconepercentstacked': 'percentStacked', 'bar3dpyramidclustered': 'clustered', 'bar3dpyramidstacked': 'stacked', - 'bar3dpyramidpercentstacked': 'percentstacked', + 'bar3dpyramidpercentstacked': 'percentStacked', 'bar3dcylinderclustered': 'clustered', 'bar3dcylinderstacked': 'stacked', - 'bar3dcylinderpercentstacked': 'percentstacked', + 'bar3dcylinderpercentstacked': 'percentStacked', 'col': 'clustered', 'colstacked': 'stacked', - 'colpercentstacked': 'percentstacked', + 'colpercentstacked': 'percentStacked', 'col3d': 'standard', 'col3dclustered': 'clustered', 'col3dstacked': 'stacked', - 'col3dpercentstacked': 'percentstacked', + 'col3dpercentstacked': 'percentStacked', 'col3dcone': 'standard', 'col3dconeclustered': 'clustered', 'col3dconestacked': 'stacked', - 'col3dconepercentstacked': 'percentstacked', + 'col3dconepercentstacked': 'percentStacked', 'col3dpyramid': 'standard', 'col3dpyramidclustered': 'clustered', 'col3dpyramidstacked': 'stacked', - 'col3dpyramidpercentstacked': 'percentstacked', + 'col3dpyramidpercentstacked': 'percentStacked', 'col3dcylinder': 'standard', 'col3dcylinderclustered': 'clustered', 'col3dcylinderstacked': 'stacked', - 'col3dcylinderpercentstacked': 'percentstacked', + 'col3dcylinderpercentstacked': 'percentStacked', 'line': 'standard'); return m[t]; End; diff --git a/funcext/TSOffice/TSUtils/ErrorMessage.tsf b/funcext/TSOffice/TSUtils/ErrorMessage.tsf index 1b1cfbd..d389d81 100644 --- a/funcext/TSOffice/TSUtils/ErrorMessage.tsf +++ b/funcext/TSOffice/TSUtils/ErrorMessage.tsf @@ -12,13 +12,13 @@ Type ErrorMessage = class class Function SheetExist(sheetName) Begin - sheetName := ifString(sheetName) ?: ''; + sheetName := ifString(sheetName) ?: ' '; return array(2, sheetName + ' already exists.'); End; class Function SheetNotExist(sheetName) Begin - sheetName := ifString(sheetName) ?: ''; + sheetName := ifString(sheetName) ?: ' '; return array(3, sheetName + ' does not exist.'); End; diff --git a/funcext/TSOffice/TSUtils/TSChart.tsf b/funcext/TSOffice/TSUtils/TSChart.tsf index f7c299d..334fe59 100644 --- a/funcext/TSOffice/TSUtils/TSChart.tsf +++ b/funcext/TSOffice/TSUtils/TSChart.tsf @@ -104,6 +104,7 @@ Type TSChart = Class Begin chartData_.Serialize(IsWord()); //初始化图表数据 task := array(('c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p/a:r/a:t', 'pcdata', chartData_.Title), + ('c:chartSpace/c:chart/c:plotVisOnly', 'val', chartData_.plotVisOnly), ('c:chartSpace/c:chart/c:dispBlanksAs', 'val', chartData_.ShowBlanksAs), ('c:chartSpace/c:chart/c:legend', 'Del', ifnil(chartData_.Legend)), ('c:chartSpace/c:chart/c:plotArea', 'unmarshal', chartData_.plotArea.Marshal()), diff --git a/funcext/TSOffice/worksheet/xlsxRichText.tsf b/funcext/TSOffice/worksheet/xlsxRichText.tsf deleted file mode 100644 index 6c65225..0000000 --- a/funcext/TSOffice/worksheet/xlsxRichText.tsf +++ /dev/null @@ -1,18 +0,0 @@ -Type xlsxRichText = Class - file_; //TSExcelFile对象 - sheet_;//XmlSheet对象 - Function Create(); overload; - Begin - End; - - class Function NewObject(sheetname, self); - Begin - file_ := file; - o = file_.WorkBook().GetSheetObj(sheetname); - if not ifObj(o) then return 0; - richTxt := new xlsxRichText(); - richTxt.sheet_ = o; - richTxt.file_ := file; - return richTxt; - End; -End; \ No newline at end of file