public static void InitializeChartSettings(PCAxis.Chart.ChartSettings settings) { settings.AxisFontSize = Settings.Current.Features.Charts.Font.AxisSize; //settings.ChartType settings.Colors = Settings.Current.Features.Charts.Colors.ToList(); settings.CurrentCulture = PCAxis.Web.Core.Management.LocalizationManager.CurrentCulture; settings.FontName = Settings.Current.Features.Charts.Font.Name; settings.Guidelines = ChartSettings.GuidelinesType.None; if (Settings.Current.Features.Charts.Guidelines.Horizontal) { settings.Guidelines = ChartSettings.GuidelinesType.Horizontal; } if (Settings.Current.Features.Charts.Guidelines.Vertical) { settings.Guidelines |= ChartSettings.GuidelinesType.Vertical; } settings.GuidelinesColor = Settings.Current.Features.Charts.Guidelines.Color; settings.Height = Settings.Current.Features.Charts.Height; settings.LabelOrientation = Settings.Current.Features.Charts.LabelOrientation; settings.LegendFontSize = Settings.Current.Features.Charts.Legend.FontSize; settings.LegendHeight = Settings.Current.Features.Charts.Legend.Height; settings.LineThickness = Settings.Current.Features.Charts.LineThickness; settings.Logotype = Settings.Current.Features.Charts.Logotype; settings.ShowLegend = Settings.Current.Features.Charts.Legend.Visible; settings.TimeSortOrder = Settings.Current.Features.Charts.TimeSortOrder; //settings.Title = PCAxis.Web.Core.Management.PaxiomManager.PaxiomModel.Meta.Title; settings.TitleFontSize = Settings.Current.Features.Charts.Font.TitleSize; settings.Width = Settings.Current.Features.Charts.Width; settings.ShowSource = Settings.Current.Features.Charts.ShowSource; settings.ShowLogo = Settings.Current.Features.Charts.ShowLogo; settings.BackgroundColorGraphs = Settings.Current.Features.Charts.BackgroundColorGraphs; settings.LineThicknessPhrame = Settings.Current.Features.Charts.LineThicknessPhrame; settings.LogotypePath = Settings.Current.General.Paths.ImagesPath; settings.LineColorPhrame = Settings.Current.Features.Charts.LineColorPhrame; }
public PxWebChart(PXModel px, ChartSettings settings, PxChartSettings settingsAsLambda) : base(px, settingsAsLambda) { CurrentCulture = settings.CurrentCulture; Settings = settings; // Source text if (!String.IsNullOrEmpty(px.Meta.Source)) { // Use Source from model if it exists... InfoText = ChartHelper.GetLocalizedString("PxWebChartsSourceLabel", CurrentCulture) + " " + px.Meta.Source; } else { // ...else use localized text InfoText = ChartHelper.GetLocalizedString("PxWebChartsSourceLabel", CurrentCulture) + " " + ChartHelper.GetLocalizedString("PxWebChartsSource", CurrentCulture); } }
public static PxWebChart GetChart(ChartSettings settings, PXModel model) { PxWebChart chart; CultureInfo ci = new CultureInfo(settings.CurrentCulture.Name); if (ci.IsNeutralCulture) { ci = CultureInfo.CreateSpecificCulture(settings.CurrentCulture.Name); } System.Threading.Thread.CurrentThread.CurrentCulture = ci; chart = new PxWebChart(model, settings, c => { if (settings.IsColumnLine) { // Column + Line chart c.ChartTypes = new SeriesChartType[] { SeriesChartType.Column, SeriesChartType.Line }; c.SecondaryAxisFromSeriesNumber = 2; c.SecondaryAxisAddToSeriesName = " " + GetLocalizedString("PxWebChartRightScale", settings.CurrentCulture); c.SecondaryAxisAddToPrimarySeriesName = " " + GetLocalizedString("PxWebChartLeftScale", settings.CurrentCulture); } else { c.ChartType = settings.ChartType; } if (settings.ChartType == SeriesChartType.Pyramid) { c.MaleValueNameForPopulationPyramid = FindPyramidFirstValue(model); } c.OverrideTitle = settings.Title; c.Width = settings.Width; c.Height = settings.Height; c.DecimalPlaces = model.Meta.ShowDecimals == -1 ? model.Meta.Decimals : model.Meta.ShowDecimals; c.ShowGuideLines = ((settings.Guidelines & ChartSettings.GuidelinesType.Vertical) == ChartSettings.GuidelinesType.Vertical); c.LegendHeightAsPctOfChart = settings.LegendHeight; if (settings.ChartType == SeriesChartType.Radar) { c.AutoMoveMostValuesVariableToX = true; } else { c.AutoMoveMostValuesVariableToX = false; } c.Font.Family = new System.Drawing.FontFamily(settings.FontName); c.Font.SizeSmall = settings.AxisFontSize; c.Font.SizeRegular = settings.TitleFontSize; } ); foreach (ChartArea area in chart.ChartAreas) { // Horizontal guidelines area.AxisY.MajorGrid.Enabled = ((settings.Guidelines & ChartSettings.GuidelinesType.Horizontal) == ChartSettings.GuidelinesType.Horizontal); // Guideline color area.AxisY.MajorGrid.LineColor = System.Drawing.ColorTranslator.FromHtml(settings.GuidelinesColor); area.AxisX.MajorGrid.LineColor = System.Drawing.ColorTranslator.FromHtml(settings.GuidelinesColor); area.BackColor = System.Drawing.ColorTranslator.FromHtml(settings.BackgroundColorGraphs); } //If line thickness is more than 0 draw a line around the chart if (settings.LineThicknessPhrame > 0) { chart.BorderlineWidth = settings.LineThicknessPhrame; chart.BorderlineColor = System.Drawing.ColorTranslator.FromHtml(settings.LineColorPhrame); chart.BorderlineDashStyle = ChartDashStyle.Solid; } // Legend //If line thickness on phrame is more then // 0 the backcolor is set to transparent. if (chart.Legends.Count > 0) { foreach (Legend l in chart.Legends) { l.Enabled = settings.ShowLegend; l.LegendStyle = LegendStyle.Table; l.TableStyle = LegendTableStyle.Auto; l.Docking = Docking.Bottom; l.Font = new System.Drawing.Font(settings.FontName, settings.LegendFontSize); if (!settings.ShowLegend) { foreach (ChartArea area in chart.ChartAreas) { area.Position.Height += l.Position.Height; l.Position.Height = 0; } } if (settings.LineThicknessPhrame > 0) { l.BackColor = System.Drawing.Color.Transparent; } } } // Label orientation if (settings.LabelOrientation == ChartSettings.OrientationType.Vertical) { foreach (ChartArea area in chart.ChartAreas) { area.AxisX.LabelStyle.Angle = 90; } } // Line thickness foreach (Series ser in chart.Series) { ser.BorderWidth = settings.LineThickness; if (settings.ChartType == SeriesChartType.Radar) { ser["RadarDrawingStyle"] = "Line"; } } // Chart colors List <Color> lstColors = new List <Color>(); foreach (string col in settings.Colors) { lstColors.Add(ColorTranslator.FromHtml(col)); } chart.Palette = ChartColorPalette.None; chart.PaletteCustomColors = lstColors.ToArray(); return(chart); }
public ChartSerializer() { Settings = new ChartSettings(); Format = ImageFormat.Png; }