public AreaChart(DashboardHelper dashboardHelper, GadgetParameters parameters, AreaChartSettings settings, List<XYColumnChartData> dataList) { InitializeComponent(); this.Settings = settings; this.AreaChartSettings = settings; this.Parameters = parameters; this.DashboardHelper = dashboardHelper; SetChartProperties(); SetChartData(dataList); xyChart.Legend.BorderBrush = Brushes.Gray; }
protected override void SetChartData(List<XYColumnChartData> dataList, Strata strata) { AreaChartSettings chartSettings = new AreaChartSettings(); chartSettings.ChartTitle = txtChartTitle.Text; chartSettings.ChartSubTitle = txtChartSubTitle.Text; if (strata != null) { chartSettings.ChartStrataTitle = strata.Filter; } chartSettings.ChartWidth = int.Parse(txtWidth.Text); chartSettings.ChartHeight = int.Parse(txtHeight.Text); chartSettings.ShowDefaultGridLines = (bool)checkboxGridLines.IsChecked; switch (cmbAreaType.SelectedIndex) { case 1: chartSettings.AreaType = LineKind.Polygon; break; case 2: chartSettings.AreaType = LineKind.Smooth; break; case 3: chartSettings.AreaType = LineKind.Step; break; default: case 0: chartSettings.AreaType = LineKind.Auto; break; } switch (cmbComposition.SelectedIndex) { case 0: chartSettings.Composition = CompositionKind.SideBySide; break; case 1: chartSettings.Composition = CompositionKind.Stacked; break; case 2: chartSettings.Composition = CompositionKind.Stacked100; break; } chartSettings.LegendDock = ComponentArt.Win.DataVisualization.Charting.Dock.Right; if (cmbLegendDock.SelectedItem.ToString().Equals(ChartingSharedStrings.LEGEND_DOCK_VALUE_LEFT)) { chartSettings.LegendDock = ComponentArt.Win.DataVisualization.Charting.Dock.Left; } else if (cmbLegendDock.SelectedItem.ToString().Equals(ChartingSharedStrings.LEGEND_DOCK_VALUE_RIGHT)) { chartSettings.LegendDock = ComponentArt.Win.DataVisualization.Charting.Dock.Right; } else if (cmbLegendDock.SelectedItem.ToString().Equals(ChartingSharedStrings.LEGEND_DOCK_VALUE_TOP)) { chartSettings.LegendDock = ComponentArt.Win.DataVisualization.Charting.Dock.Top; } else if (cmbLegendDock.SelectedItem.ToString().Equals(ChartingSharedStrings.LEGEND_DOCK_VALUE_BOTTOM)) { chartSettings.LegendDock = ComponentArt.Win.DataVisualization.Charting.Dock.Bottom; } chartSettings.LegendFontSize = double.Parse(txtLegendFontSize.Text); ComboBoxItem cbi = cmbPalette.SelectedItem as ComboBoxItem; ComponentArt.Win.DataVisualization.Palette palette = ComponentArt.Win.DataVisualization.Palette.GetPalette(cbi.Content.ToString()); chartSettings.Palette = palette; chartSettings.ShowSeriesLine = (bool)checkboxShowSeriesLine.IsChecked; chartSettings.ShowLegend = (bool)checkboxShowLegend.IsChecked; chartSettings.ShowLegendBorder = (bool)checkboxShowLegendBorder.IsChecked; chartSettings.ShowLegendVarNames = (bool)checkboxShowVarName.IsChecked; chartSettings.UseRefValues = (bool)checkboxUseRefValues.IsChecked; chartSettings.XAxisLabel = txtXAxisLabelValue.Text; chartSettings.XAxisLabelRotation = int.Parse(txtXAxisAngle.Text); chartSettings.YAxisLabel = txtYAxisLabelValue.Text; chartSettings.YAxisFormattingString = txtYAxisFormatString.Text; chartSettings.Y2AxisLabel = txtY2AxisLabelValue.Text; chartSettings.Y2AxisLegendTitle = txtY2AxisLegendTitle.Text; chartSettings.Y2AxisFormattingString = txtY2AxisFormatString.Text; int pctTop = 100; int pctBottom = 100; int.TryParse(txtTransTop.Text, out pctTop); int.TryParse(txtTransBottom.Text, out pctBottom); chartSettings.TransparencyTop = pctTop; chartSettings.TransparencyBottom = pctBottom; switch (cmbXAxisLabelType.SelectedIndex) { case 3: chartSettings.XAxisLabelType = XAxisLabelType.Custom; break; case 1: chartSettings.XAxisLabelType = XAxisLabelType.FieldPrompt; Field field = DashboardHelper.GetAssociatedField(GadgetOptions.MainVariableName); if (field == null) { chartSettings.XAxisLabel = GadgetOptions.MainVariableName; } else { chartSettings.XAxisLabel = ((IDataField)field).PromptText; } break; case 2: chartSettings.XAxisLabelType = XAxisLabelType.None; break; default: chartSettings.XAxisLabelType = XAxisLabelType.Automatic; chartSettings.XAxisLabel = GadgetOptions.MainVariableName; break; } switch (cmbLineTypeY2.SelectedIndex) { case 1: chartSettings.LineKindY2 = LineKind.Polygon; break; case 2: chartSettings.LineKindY2 = LineKind.Smooth; break; case 3: chartSettings.LineKindY2 = LineKind.Step; break; default: case 0: chartSettings.LineKindY2 = LineKind.Auto; break; } switch (cmbLineDashTypeY2.SelectedIndex) { case 0: chartSettings.LineDashStyleY2 = LineDashStyle.Dash; break; case 1: chartSettings.LineDashStyleY2 = LineDashStyle.DashDot; break; case 2: chartSettings.LineDashStyleY2 = LineDashStyle.DashDotDot; break; case 3: chartSettings.LineDashStyleY2 = LineDashStyle.Dot; break; default: chartSettings.LineDashStyleY2 = LineDashStyle.Solid; break; } int lineThicknessY2 = cmbLineThicknessY2.SelectedIndex + 1; chartSettings.Y2LineThickness = (double)lineThicknessY2; Controls.Charting.AreaChart areaChart = new Controls.Charting.AreaChart(DashboardHelper, GadgetOptions, chartSettings, dataList); areaChart.Margin = new Thickness(0, 0, 0, 16); areaChart.MouseEnter += new MouseEventHandler(chart_MouseEnter); areaChart.MouseLeave += new MouseEventHandler(chart_MouseLeave); panelMain.Children.Add(areaChart); }