private static void SetLayoutProperties(ExcelChartEx chart, XmlElement ser) { var layoutPr = ser.SelectSingleNode("cx:layoutPr", chart.NameSpaceManager); switch (chart.ChartType) { case eChartType.BoxWhisker: layoutPr.InnerXml = "<cx:parentLabelLayout val=\"banner\"/><cx:visibility outliers=\"1\" nonoutliers=\"0\" meanMarker=\"1\" meanLine=\"0\"/><cx:statistics quartileMethod=\"exclusive\"/>"; break; case eChartType.Histogram: case eChartType.Pareto: layoutPr.InnerXml = "<cx:binning intervalClosed=\"r\"/>"; break; case eChartType.RegionMap: var ci = CultureInfo.CurrentCulture; layoutPr.InnerXml = $"<cx:geography attribution = \"Powered by Bing\" cultureRegion = \"{ci.TwoLetterISOLanguageName}\" cultureLanguage = \"{ci.Name}\" ><cx:geoCache provider=\"{{E9337A44-BEBE-4D9F-B70C-5C5E7DAFC167}}\"><cx:binary/></cx:geoCache></cx:geography>"; break; case eChartType.Waterfall: layoutPr.InnerXml = "<cx:visibility connectorLines=\"0\" />"; break; } }
private static object AddAxisReferense(ExcelChartEx chart) { if (chart.ChartType == eChartType.Pareto) { return("<cx:axisId val=\"1\"/>"); } else { return(""); } }
internal ExcelHistogramChartSerie(ExcelChartEx chart, XmlNamespaceManager ns, XmlNode node, int index = -1) : base(chart, ns, node) { if (index == -1) { _index = chart.Series.Count * (chart.ChartType == eChartType.Pareto ? 2 : 1); } else { _index = index; } }
/// <summary> /// Default constructor /// </summary> /// <param name="chart">The chart</param> /// <param name="ns">Namespacemanager</param> /// <param name="node">Topnode</param> internal ExcelChartExSerie(ExcelChartEx chart, XmlNamespaceManager ns, XmlNode node) : base(chart, ns, node, "cx") { SchemaNodeOrder = new string[] { "tx", "spPr", "valueColors", "valueColorPositions", "dataPt", "dataLabels", "dataId", "layoutPr", "axisId" }; _dataNode = node.SelectSingleNode($"../../../../cx:chartData/cx:data[@id={DataId}]", ns); if ((chart.ChartType == eChartType.BoxWhisker || chart.ChartType == eChartType.Histogram || chart.ChartType == eChartType.Pareto || chart.ChartType == eChartType.Waterfall || chart.ChartType == eChartType.Pareto) && chart.Series.Count == 0) { AddAxis(); chart.LoadAxis(); } }
internal static XmlElement CreateSeriesElement(ExcelChartEx chart, eChartType type, int index, XmlNode referenceNode = null, bool isPareto = false) { var plotareaNode = chart._chartXmlHelper.CreateNode("cx:plotArea/cx:plotAreaRegion"); var ser = plotareaNode.OwnerDocument.CreateElement("cx", "series", ExcelPackage.schemaChartExMain); XmlNodeList node = plotareaNode.SelectNodes("cx:series", chart.NameSpaceManager); if (node.Count > 0) { plotareaNode.InsertAfter(ser, referenceNode ?? node[node.Count - 1]); } else { var f = XmlHelperFactory.Create(chart.NameSpaceManager, plotareaNode); f.InserAfter(plotareaNode, "cx:plotSurface", ser); } ser.SetAttribute("formatIdx", index.ToString()); ser.SetAttribute("uniqueId", "{" + Guid.NewGuid().ToString() + "}"); ser.SetAttribute("layoutId", GetLayoutId(type, isPareto)); return(ser); }
internal static XmlElement CreateSeriesAndDataElement(ExcelChartEx chart, bool hasCatSerie) { XmlElement ser = CreateSeriesElement(chart, chart.ChartType, chart.Series.Count); ser.InnerXml = $"<cx:dataId val=\"{chart.Series.Count}\"/><cx:layoutPr/>{AddAxisReferense(chart)}"; SetLayoutProperties(chart, ser); chart._chartXmlHelper.CreateNode("../cx:chartData", true); var dataElement = (XmlElement)chart._chartXmlHelper.CreateNode("../cx:chartData/cx:data", false, true); dataElement.SetAttribute("id", chart.Series.Count.ToString()); var innerXml = ""; if (hasCatSerie == true) { innerXml += $"<cx:strDim type=\"cat\"><cx:f></cx:f><cx:nf></cx:nf></cx:strDim>"; } innerXml += $"<cx:numDim type=\"{GetNumType(chart.ChartType)}\"><cx:f></cx:f><cx:nf></cx:nf></cx:numDim>"; dataElement.InnerXml = innerXml; return(ser); }
internal ExcelRegionMapChartSerie(ExcelChartEx chart, XmlNamespaceManager ns, XmlNode node) : base(chart, ns, node) { }
internal ExcelBoxWhiskerChartSerie(ExcelChartEx chart, XmlNamespaceManager ns, XmlNode node) : base(chart, ns, node) { }
internal ExcelWaterfallChartSerie(ExcelChartEx chart, XmlNamespaceManager ns, XmlNode node) : base(chart, ns, node) { }