Commit 6e1d87bf authored by Sergey Luzyanin's avatar Sergey Luzyanin

fromat code for val axis from source

parent 14cca4d4
......@@ -405,6 +405,7 @@ DrawingObjectsController.prototype.addChartDrawingObject = function(options)
options.style = null;
options.horAxisProps = null;
options.vertAxisProps = null;
options.showMarker = null;
this.editChartCallback(options);
options.style = 1;
options.bCreate = true;
......
......@@ -3012,6 +3012,14 @@ DrawingObjectsController.prototype =
var axis_by_types;
var val_ax, cat_ax;
object_type = chart_type.getObjectType();
var sDefaultValAxFormatCode = null;
if(chart_type && chart_type.series[0]){
var aPoints = AscFormat.getPtsFromSeries(chart_type.series[0]);
if(aPoints[0] && typeof aPoints[0].formatCode === "string" && aPoints[0].formatCode.length > 0){
sDefaultValAxFormatCode = aPoints[0].formatCode;
}
}
need_num_fmt = sDefaultValAxFormatCode;
var checkSwapAxis = function(plotArea, chartType, newChartType)
{
......@@ -3026,7 +3034,7 @@ DrawingObjectsController.prototype =
}
if(!val_ax || !cat_ax)
{
var axis_obj = AscFormat.CreateDefaultAxises(need_num_fmt);
var axis_obj = AscFormat.CreateDefaultAxises(need_num_fmt ? need_num_fmt : "General");
cat_ax = axis_obj.catAx;
val_ax = axis_obj.valAx;
}
......@@ -3110,8 +3118,10 @@ DrawingObjectsController.prototype =
|| type === c_oAscChartTypeSettings.barNormal3d || type === c_oAscChartTypeSettings.barStacked3d
|| type === c_oAscChartTypeSettings.hBarNormal || type === c_oAscChartTypeSettings.hBarStacked
|| type === c_oAscChartTypeSettings.hBarNormal3d || type === c_oAscChartTypeSettings.hBarStacked3d
|| type === c_oAscChartTypeSettings.barNormal3dPerspective)
need_num_fmt = "General";
|| type === c_oAscChartTypeSettings.barNormal3dPerspective){
need_num_fmt = sDefaultValAxFormatCode;
}
else
need_num_fmt = "0%";
......@@ -3238,8 +3248,10 @@ DrawingObjectsController.prototype =
if(!val_axis[i].numFmt)
{
val_axis[i].setNumFmt(new AscFormat.CNumFmt());
val_axis[i].numFmt.setFormatCode(sDefaultValAxFormatCode ? sDefaultValAxFormatCode : "General");
val_axis[i].numFmt.setSourceLinked(true);
}
if(val_axis[i].numFmt.formatCode !== need_num_fmt)
if(need_num_fmt && val_axis[i].numFmt.formatCode !== need_num_fmt)
val_axis[i].numFmt.setFormatCode(need_num_fmt);
}
}
......@@ -3293,8 +3305,10 @@ DrawingObjectsController.prototype =
if(!val_axis[i].numFmt)
{
val_axis[i].setNumFmt(new AscFormat.CNumFmt());
val_axis[i].numFmt.setFormatCode(sDefaultValAxFormatCode ? sDefaultValAxFormatCode : "General");
val_axis[i].numFmt.setSourceLinked(true);
}
if(val_axis[i].numFmt.formatCode !== need_num_fmt)
if(need_num_fmt && val_axis[i].numFmt.formatCode !== need_num_fmt)
val_axis[i].numFmt.setFormatCode(need_num_fmt);
if(need_bar_dir = BAR_DIR_BAR)
val_axis[i].setAxPos(AscFormat.AX_POS_B);
......@@ -3324,7 +3338,7 @@ DrawingObjectsController.prototype =
if(type === c_oAscChartTypeSettings.lineNormal || type === c_oAscChartTypeSettings.lineStacked || type === c_oAscChartTypeSettings.line3d
|| type === c_oAscChartTypeSettings.lineNormalMarker || type === c_oAscChartTypeSettings.lineStackedMarker)
need_num_fmt = "General";
need_num_fmt = sDefaultValAxFormatCode;
else
need_num_fmt = "0%";
......@@ -3340,8 +3354,10 @@ DrawingObjectsController.prototype =
if(!val_axis[i].numFmt)
{
val_axis[i].setNumFmt(new AscFormat.CNumFmt());
val_axis[i].numFmt.setFormatCode(sDefaultValAxFormatCode ? sDefaultValAxFormatCode : "General");
val_axis[i].numFmt.setSourceLinked(true);
}
if(val_axis[i].numFmt.formatCode !== need_num_fmt)
if(need_num_fmt && val_axis[i].numFmt.formatCode !== need_num_fmt)
val_axis[i].numFmt.setFormatCode(need_num_fmt);
}
......@@ -3410,8 +3426,10 @@ DrawingObjectsController.prototype =
if(!val_axis[i].numFmt)
{
val_axis[i].setNumFmt(new AscFormat.CNumFmt());
val_axis[i].numFmt.setFormatCode(sDefaultValAxFormatCode ? sDefaultValAxFormatCode : "General");
val_axis[i].numFmt.setSourceLinked(true);
}
if(val_axis[i].numFmt.formatCode !== need_num_fmt)
if(need_num_fmt && val_axis[i].numFmt.formatCode !== need_num_fmt)
val_axis[i].numFmt.setFormatCode(need_num_fmt);
}
if(type === c_oAscChartTypeSettings.line3d)
......@@ -3560,7 +3578,7 @@ DrawingObjectsController.prototype =
need_groupping = GROUPING_PERCENT_STACKED;
if(type === c_oAscChartTypeSettings.areaNormal || type === c_oAscChartTypeSettings.areaStacked)
need_num_fmt = "General";
need_num_fmt = sDefaultValAxFormatCode;
else
need_num_fmt = "0%";
......@@ -3574,8 +3592,10 @@ DrawingObjectsController.prototype =
if(!val_axis[i].numFmt)
{
val_axis[i].setNumFmt(new AscFormat.CNumFmt());
val_axis[i].numFmt.setFormatCode(sDefaultValAxFormatCode ? sDefaultValAxFormatCode : "General");
val_axis[i].numFmt.setSourceLinked(true);
}
if(val_axis[i].numFmt.formatCode !== need_num_fmt)
if(need_num_fmt && val_axis[i].numFmt.formatCode !== need_num_fmt)
val_axis[i].numFmt.setFormatCode(need_num_fmt);
}
}
......@@ -3591,8 +3611,10 @@ DrawingObjectsController.prototype =
if(!val_axis[i].numFmt)
{
val_axis[i].setNumFmt(new AscFormat.CNumFmt());
val_axis[i].numFmt.setFormatCode(sDefaultValAxFormatCode ? sDefaultValAxFormatCode : "General");
val_axis[i].numFmt.setSourceLinked(true);
}
if(val_axis[i].numFmt.formatCode !== need_num_fmt)
if(need_num_fmt && val_axis[i].numFmt.formatCode !== need_num_fmt)
val_axis[i].numFmt.setFormatCode(need_num_fmt);
}
new_chart_type.setGrouping(need_groupping);
......@@ -3640,6 +3662,7 @@ DrawingObjectsController.prototype =
if(!val_axis[i].numFmt)
{
val_axis[i].setNumFmt(new AscFormat.CNumFmt());
val_axis[i].numFmt.setSourceLinked(true);
}
if(val_axis[i].numFmt.formatCode !== "General")
val_axis[i].numFmt.setFormatCode("General");
......
......@@ -3277,6 +3277,7 @@ CChartSpace.prototype.recalculateReferences = function()
{
series = charts[i].series;
var bHaveHidden = false, bHaveNoHidden = false;
var bCheckFormatCode = false;
if(charts[i].getObjectType() !== AscDFH.historyitem_type_ScatterChart)
{
for(j = 0; j < series.length; ++j)
......@@ -3297,6 +3298,27 @@ CChartSpace.prototype.recalculateReferences = function()
else
{
bHaveNoHidden = true;
if(!bCheckFormatCode &&
!((charts[i].getObjectType() === AscDFH.historyitem_type_BarChart && charts[i].grouping === AscFormat.BAR_GROUPING_PERCENT_STACKED)
|| (charts[i].getObjectType() !== AscDFH.historyitem_type_BarChart && charts[i].grouping === AscFormat.GROUPING_PERCENT_STACKED))){
bCheckFormatCode = true;
var aAxId = charts[i].axId;
if(aAxId){
for(var s = 0; s < aAxId.length; ++s){
if(aAxId[s].getObjectType() === AscDFH.historyitem_type_ValAx){
if(aAxId[s].numFmt && aAxId[s].numFmt.sourceLinked){
var aPoints = AscFormat.getPtsFromSeries(ser);
if(aPoints[0] && typeof aPoints[0].formatCode === "string" && aPoints[0].formatCode.length > 0){
aAxId[s].numFmt.setFormatCode(aPoints[0].formatCode);
}
else{
aAxId[s].numFmt.setFormatCode("General");
}
}
}
}
}
}
}
}
......@@ -3317,6 +3339,27 @@ CChartSpace.prototype.recalculateReferences = function()
else
{
bHaveNoHidden = true;
if(!bCheckFormatCode){
bCheckFormatCode = true;
var aAxId = charts[i].axId;
if(aAxId){
for(var s = 0; s < aAxId.length; ++s){
if(aAxId[s].getObjectType() === AscDFH.historyitem_type_ValAx){
if((aAxId[s].axPos === AscFormat.AX_POS_L || aAxId[s].axPos === AscFormat.AX_POS_R) && aAxId[s].numFmt && aAxId[s].numFmt.sourceLinked){
var aPoints = AscFormat.getPtsFromSeries(ser);
if(aPoints[0] && typeof aPoints[0].formatCode === "string" && aPoints[0].formatCode.length > 0){
aAxId[s].numFmt.setFormatCode(aPoints[0].formatCode);
}
else{
aAxId[s].numFmt.setFormatCode("General");
}
}
}
}
}
}
}
}
}
......@@ -11563,6 +11606,18 @@ function CreateView3d(nRotX, nRotY, bRAngAx, nDepthPercent)
return oView3d;
}
function GetNumFormatFromSeries(aAscSeries){
if(aAscSeries &&
aAscSeries[0] &&
aAscSeries[0].Val &&
aAscSeries[0].Val.NumCache &&
aAscSeries[0].Val.NumCache[0]){
if(typeof (aAscSeries[0].Val.NumCache[0].numFormatStr) === "string" && aAscSeries[0].Val.NumCache[0].numFormatStr.length > 0){
return aAscSeries[0].Val.NumCache[0].numFormatStr;
}
}
return "General";
}
function CreateLineChart(chartSeries, type, bUseCache, oOptions, b3D)
{
......@@ -11679,7 +11734,7 @@ function CreateLineChart(chartSeries, type, bUseCache, oOptions, b3D)
}
else
{
format_code = "General";
format_code = GetNumFormatFromSeries(asc_series);
}
num_fmt.setFormatCode(format_code);
num_fmt.setSourceLinked(true);
......@@ -11816,7 +11871,7 @@ function CreateBarChart(chartSeries, type, bUseCache, oOptions, b3D, bDepth)
}
else
{
format_code = "General";
format_code = GetNumFormatFromSeries(asc_series);
}
num_fmt.setFormatCode(format_code);
num_fmt.setSourceLinked(true);
......@@ -11965,7 +12020,7 @@ function CreateHBarChart(chartSeries, type, bUseCache, oOptions, b3D)
}
else */
{
format_code = "General";
format_code = GetNumFormatFromSeries(asc_series);
}
num_fmt.setFormatCode(format_code);
num_fmt.setSourceLinked(true);
......@@ -12092,7 +12147,7 @@ function CreateAreaChart(chartSeries, type, bUseCache, oOptions)
}
else
{
format_code = "General";
format_code = GetNumFormatFromSeries(asc_series);
}
num_fmt.setFormatCode(format_code);
num_fmt.setSourceLinked(true);
......@@ -12368,7 +12423,7 @@ function CreateScatterChart(chartSeries, bUseCache, oOptions)
var scaling = val_ax.scaling;
scaling.setOrientation(AscFormat.ORIENTATION_MIN_MAX);
var num_fmt = val_ax.numFmt;
var format_code = "General";
var format_code = GetNumFormatFromSeries(asc_series);
num_fmt.setFormatCode(format_code);
num_fmt.setSourceLinked(true);
if(scatter_chart.series.length > 1)
......@@ -12529,7 +12584,7 @@ function CreateStockChart(chartSeries, bUseCache, oOptions)
scaling.setOrientation(AscFormat.ORIENTATION_MIN_MAX);
var num_fmt = val_ax.numFmt;
var format_code;
format_code = "General";
format_code = GetNumFormatFromSeries(asc_series);
num_fmt.setFormatCode(format_code);
num_fmt.setSourceLinked(true);
var legend = chart.legend;
......@@ -12648,7 +12703,7 @@ function CreateStockChart(chartSeries, bUseCache, oOptions)
oValAx.setAxPos(AscFormat.AX_POS_L);
oValAx.setMajorGridlines(new AscFormat.CSpPr());
var oNumFmt = new AscFormat.CNumFmt();
oNumFmt.setFormatCode("General");
oNumFmt.setFormatCode(GetNumFormatFromSeries(asc_series));
oNumFmt.setSourceLinked(true);
oValAx.setNumFmt(oNumFmt);
oValAx.setMajorTickMark(c_oAscTickMark.TICK_MARK_OUT);
......
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