protected override string DefaultCommand() { if (Variables == null) { throw new Exception("建立 Bar chart 指令時,未給定 Variables"); } Mtb.Column[] vars = (Mtb.Column[])Variables; Mtb.Column[] gps = null; if (GroupingVariables != null) { gps = (Mtb.Column[])GroupingVariables; } if ((BarsRepresent == ChartRepresent.ONE_WAY_TABLE || BarsRepresent == ChartRepresent.TWO_WAY_TABLE) & (gps == null)) { throw new Exception("(Bar chart)使用 Summaried Data,至少給定一個分群欄位"); } StringBuilder cmnd = new StringBuilder(); // local macro 內容 /***************** * 一些注意事項: Chart 可以有多個 Variable 輸入,分成兩類 * 1. F(C...C)*Cg 這是各別F(C)以 Cg 做分群,不需搭配 Summarized * 2. Summarized data,使用 (C...C)*Cg 搭配 Summarized 子命令, * 如果是 Two-way table 則須再加上 VFirst 或 VLast 等指令 * */ switch (BarsRepresent) { case ChartRepresent.COUNT_OF_UNIQUE_VALUES: cmnd.AppendFormat("Chart {0};\r\n", string.Join(" &\r\n", vars.Select(x => x.SynthesizedName).ToArray())); if (gps != null) { cmnd.AppendFormat(" Group {0};\r\n", string.Join(" &\r\n", string.Join(" &\r\n", gps.Select(x => x.SynthesizedName).ToArray()))); } break; case ChartRepresent.A_FUNCTION_OF_A_VARIABLE: cmnd.AppendFormat("Chart {0}({1}) &\r\n", FuncType.ToString(), string.Join(" &\r\n", vars.Select(x => x.SynthesizedName).ToArray())); if (gps != null) { cmnd.AppendFormat("*{0};\r\n", gps[0].SynthesizedName); if (gps.Length >= 2) { cmnd.AppendFormat(" Group {0};\r\n", string.Join(" &\r\n", gps.Select((x, i) => new { colId = x.SynthesizedName, index = i }). Where(x => x.index > 0).Select(x => x.colId).ToArray())); } } else { cmnd.AppendLine(";"); } break; case ChartRepresent.ONE_WAY_TABLE: case ChartRepresent.TWO_WAY_TABLE: cmnd.AppendFormat("Chart ({0})*{1};\r\n", string.Join(" &\r\n", vars.Select(x => x.SynthesizedName).ToArray()), gps[0].SynthesizedName); cmnd.AppendLine("Summarized;"); if (BarsRepresent == ChartRepresent.TWO_WAY_TABLE) { cmnd.AppendLine("Overlay;"); if (TableArrangement == ChartTableArrangementType.RowsOuterMost) { cmnd.AppendLine(" VLast;"); } else { cmnd.AppendLine(" VFirst;"); } } if (gps.Length >= 2) { cmnd.AppendFormat(" Group {0};\r\n", string.Join(" &\r\n", gps.Select((x, i) => new { colId = x.SynthesizedName, index = i }). Where(x => x.index > 0).Select(x => x.colId).ToArray())); } break; } cmnd.Append(GetOptionCommand()); cmnd.Append(YScale.GetCommand()); cmnd.Append(XScale.GetCommand()); // if (StackType == ChartStackType.Stack && DataLabel.Visible && AdjDatlabAtStackBar) { } cmnd.Append(DataLabel.GetCommand()); cmnd.Append(Bar.GetCommand()); cmnd.Append(Symbol.GetCommand()); cmnd.Append(Connectline.GetCommand()); cmnd.Append(Panel.GetCommand()); cmnd.Append(Legend.GetCommand()); cmnd.Append(GetAnnotationCommand()); cmnd.Append(GetRegionCommand()); return(cmnd.ToString() + "."); }