コード例 #1
0
        protected override void GenerateChartData(Dictionary<DataTable, List<DescriptiveStatistics>> stratifiedFrequencyTables, Strata strata = null)
        {
            lock (syncLockData)
            {
                string second_y_var = string.Empty;

                if (GadgetOptions.InputVariableList.ContainsKey("second_y_var"))
                {
                    second_y_var = GadgetOptions.InputVariableList["second_y_var"];
                }

                List<XYColumnChartData> dataList = new List<XYColumnChartData>();

                foreach (KeyValuePair<DataTable, List<DescriptiveStatistics>> tableKvp in stratifiedFrequencyTables)
                {
                    double count = 0;
                    foreach (DescriptiveStatistics ds in tableKvp.Value)
                    {
                        count = count + ds.observations;
                    }

                    string strataValue = tableKvp.Key.TableName;
                    DataTable table = tableKvp.Key;
                    DataTable epiCurveTable = new DataTable("epiCurveTable");
                    epiCurveTable.Columns.Add(new DataColumn(table.Columns[0].ColumnName, typeof(string)));
                    epiCurveTable.Columns.Add(new DataColumn(table.Columns[1].ColumnName, typeof(double)));

                    DataColumn[] parentPrimaryKeyColumns = new DataColumn[1];
                    parentPrimaryKeyColumns[0] = epiCurveTable.Columns[0];
                    epiCurveTable.PrimaryKey = parentPrimaryKeyColumns;

                    int step = 1;
                    int.TryParse(GadgetOptions.InputVariableList["step"], out step);

                    string interval = "day";
                    if (GadgetOptions.InputVariableList.ContainsKey("interval"))
                    {
                        interval = GadgetOptions.InputVariableList["interval"];
                    }

                    switch (interval)
                    {
                        case "year":
                            CalculateByYear(table, epiCurveTable, step);
                            break;
                        case "minute":
                            CalculateByMinute(table, epiCurveTable, step);
                            break;
                        case "hour":
                            CalculateByHour(table, epiCurveTable, step);
                            break;
                        case "month":
                            CalculateByMonth(table, epiCurveTable, step);
                            break;
                        default:
                        case "day":
                            CalculateByDay(table, epiCurveTable, step);
                            break;
                    }

                    foreach (DataRow row in epiCurveTable.Rows)
                    {
                        XYColumnChartData chartData = new XYColumnChartData();
                        chartData.X = strataValue;
                        chartData.Y = (double)row[1];

                        chartData.S = row[0].ToString();

                        //Debug.Print(chartData.S + " : " + chartData.Y);

                        dataList.Add(chartData);
                    }
                }

                this.Dispatcher.BeginInvoke(new SetChartDataDelegate(SetChartData), dataList, strata);
            }
        }
コード例 #2
0
        protected override void SetChartData(List<XYColumnChartData> dataList, Strata strata)
        {
            HistogramChartSettings chartSettings = new HistogramChartSettings();
            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);

            double from;
            bool success = Double.TryParse(txtFromValue.Text, out from);
            if (success) { chartSettings.YAxisFrom = from; }

            double to;
            success = Double.TryParse(txtToValue.Text, out to);
            if (success) { chartSettings.YAxisTo = to; }

            double step;
            success = Double.TryParse(txtStepValue.Text, out step);
            if (success) { chartSettings.YAxisStep = step; }

            chartSettings.ShowDefaultGridLines = (bool)checkboxGridLines.IsChecked;
            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;
            }

            switch (cmbBarType.SelectedIndex)
            {
                case 1:
                    chartSettings.BarKind = BarKind.Cylinder;
                    break;
                case 2:
                    chartSettings.BarKind = BarKind.Rectangle;
                    break;
                case 3:
                    chartSettings.BarKind = BarKind.RoundedBlock;
                    break;
                default:
                case 0:
                    chartSettings.BarKind = BarKind.Block;
                    break;
            }

            switch (cmbBarSpacing.SelectedIndex)
            {
                case 1:
                    chartSettings.BarSpacing = BarSpacing.None;
                    break;
                case 2:
                    chartSettings.BarSpacing = BarSpacing.Small;
                    break;
                case 3:
                    chartSettings.BarSpacing = BarSpacing.Medium;
                    break;
                case 4:
                    chartSettings.BarSpacing = BarSpacing.Large;
                    break;
                case 0:
                default:
                    chartSettings.BarSpacing = BarSpacing.Default;
                    break;
            }

            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.ShowAnnotations = (bool)checkboxAnnotations.IsChecked;
            chartSettings.ShowAnnotationsY2 = false;
            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.Y2AxisLabel = string.Empty;
            chartSettings.Y2AxisLegendTitle = string.Empty;

            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;
            }

            Controls.Charting.HistogramChart columnChart = new Controls.Charting.HistogramChart(DashboardHelper, GadgetOptions, chartSettings, dataList);
            columnChart.Margin = new Thickness(0, 0, 0, 16);
            columnChart.MouseEnter += new MouseEventHandler(chart_MouseEnter);
            columnChart.MouseLeave += new MouseEventHandler(chart_MouseLeave);
            panelMain.Children.Add(columnChart);
        }
コード例 #3
0
        protected override void SetChartData(List<XYColumnChartData> dataList, Strata strata)
        {
            #region Input Validation
            if (dataList == null)
            {
                throw new ArgumentNullException("dataList");
            }
            #endregion // Input Validation

            if (dataList.Count > 0)
            {
                ColumnChartSettings chartSettings = new ColumnChartSettings();
                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;

                double from;
                bool success = Double.TryParse(txtFromValue.Text, out from);
                if (success) { chartSettings.YAxisFrom = from; }

                double to;
                success = Double.TryParse(txtToValue.Text, out to);
                if (success) { chartSettings.YAxisTo = to; }

                double step;
                success = Double.TryParse(txtStepValue.Text, out step);
                if (success) { chartSettings.YAxisStep = step; }

                switch (cmbOrientation.SelectedIndex)
                {
                    case 1:
                        chartSettings.Orientation = Orientation.Horizontal;
                        break;
                    case 0:
                    default:
                        chartSettings.Orientation = Orientation.Vertical;
                        break;
                }

                switch (cmbBarType.SelectedIndex)
                {
                    case 1:
                        chartSettings.BarKind = BarKind.Cylinder;
                        break;
                    case 2:
                        chartSettings.BarKind = BarKind.Rectangle;
                        break;
                    case 3:
                        chartSettings.BarKind = BarKind.RoundedBlock;
                        break;
                    default:
                    case 0:
                        chartSettings.BarKind = BarKind.Block;
                        break;
                }

                switch (cmbBarSpacing.SelectedIndex)
                {
                    case 1:
                        chartSettings.BarSpacing = BarSpacing.None;
                        break;
                    case 2:
                        chartSettings.BarSpacing = BarSpacing.Small;
                        break;
                    case 3:
                        chartSettings.BarSpacing = BarSpacing.Medium;
                        break;
                    case 4:
                        chartSettings.BarSpacing = BarSpacing.Large;
                        break;
                    case 0:
                    default:
                        chartSettings.BarSpacing = BarSpacing.Default;
                        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.ShowAnnotations = (bool)checkboxAnnotations.IsChecked;
                chartSettings.ShowAnnotationsY2 = (bool)checkboxAnnotationsY2.IsChecked;
                chartSettings.ShowLegend = (bool)checkboxShowLegend.IsChecked;
                chartSettings.ShowLegendBorder = (bool)checkboxShowLegendBorder.IsChecked;
                chartSettings.ShowLegendVarNames = (bool)checkboxShowVarName.IsChecked;
                chartSettings.UseDiffColors = (bool)checkboxUseDiffColors.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.Y2AxisFormattingString = txtY2AxisFormatString.Text;
                chartSettings.Y2AxisLabel = txtY2AxisLabelValue.Text;
                chartSettings.Y2AxisLegendTitle = txtY2AxisLegendTitle.Text;

                if (cmbSecondYAxis.SelectedIndex == 3)
                {
                    chartSettings.Y2AxisFormattingString = "P0";
                    chartSettings.Y2IsCumulativePercent = true;
                }

                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 lineThickness = cmbLineThicknessY2.SelectedIndex + 1;
                chartSettings.Y2LineThickness = (double)lineThickness;

                EpiDashboard.Controls.Charting.ColumnChart columnChart = new EpiDashboard.Controls.Charting.ColumnChart(DashboardHelper, GadgetOptions, chartSettings, dataList);
                columnChart.Margin = new Thickness(0, 0, 0, 16);
                columnChart.MouseEnter += new MouseEventHandler(chart_MouseEnter);
                columnChart.MouseLeave += new MouseEventHandler(chart_MouseLeave);
                panelMain.Children.Add(columnChart);
            }
        }
コード例 #4
0
        protected override void SetChartData(List<XYColumnChartData> dataList, Strata strata)
        {
            #region Input Validation
                if (dataList == null)
                {
                    throw new ArgumentNullException("dataList");
                }
                #endregion // Input Validation
                AreaChartParameters areaParameters = (AreaChartParameters)Parameters;

                if (dataList.Count > 0)
                {
                    if (strata != null)
                    {
                        areaParameters.ChartStrataTitle = strata.Filter;
                    }
                    else
                    {
                        areaParameters.ChartStrataTitle = String.Empty;
                    }
                    EpiDashboard.Controls.Charting.AreaChart areaChart = new EpiDashboard.Controls.Charting.AreaChart(DashboardHelper, areaParameters, 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);
                }
        }
コード例 #5
0
        protected override void SetChartData(List<XYColumnChartData> dataList, Strata strata)
        {
            #region Input Validation
            if (dataList == null)
            {
                throw new ArgumentNullException("dataList");
            }
            #endregion // Input Validation

            if (dataList.Count > 0)
            {
                LineChartSettings chartSettings = new LineChartSettings();
                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;

                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.ShowAnnotations = (bool)checkboxAnnotations.IsChecked;
                chartSettings.ShowAnnotationsY2 = (bool)checkboxAnnotationsY2.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.Y2AxisFormattingString = txtY2AxisFormatString.Text;
                chartSettings.Y2AxisLabel = txtY2AxisLabelValue.Text;
                chartSettings.Y2AxisLegendTitle = txtY2AxisLegendTitle.Text;

                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 (cmbLineType.SelectedIndex)
                {
                    case 1:
                        chartSettings.LineKind = LineKind.Polygon;
                        break;
                    case 2:
                        chartSettings.LineKind = LineKind.Smooth;
                        break;
                    case 3:
                        chartSettings.LineKind = LineKind.Step;
                        break;
                    default:
                    case 0:
                        chartSettings.LineKind = LineKind.Auto;
                        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;
                }

                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;
                }

                int lineThicknessY2 = cmbLineThicknessY2.SelectedIndex + 1;
                chartSettings.Y2LineThickness = (double)lineThicknessY2;

                int lineThicknessY1 = cmbLineThickness.SelectedIndex + 1;
                chartSettings.LineThickness = (double)lineThicknessY1;

                EpiDashboard.Controls.Charting.LineChart lineChart = new EpiDashboard.Controls.Charting.LineChart(DashboardHelper, GadgetOptions, chartSettings, dataList);
                lineChart.Margin = new Thickness(0, 0, 0, 16);
                lineChart.MouseEnter += new MouseEventHandler(chart_MouseEnter);
                lineChart.MouseLeave += new MouseEventHandler(chart_MouseLeave);
                panelMain.Children.Add(lineChart);
            }
        }
コード例 #6
0
 protected virtual void SetChartData(List<XYParetoChartData> dataList, Strata strata)
 {
 }
コード例 #7
0
        protected virtual void GenerateChartData(Dictionary<DataTable, List<DescriptiveStatistics>> stratifiedFrequencyTables, Strata strata = null)
        {
            lock (syncLockData)
            {
                string second_y_var = string.Empty;

                Y2Type y2type = Y2Type.None;

                ///ToDo: Remove GadgetOptions code when Parameters obj fully implemented. //////////////////////////////////////
                //if (GadgetOptions.InputVariableList.ContainsKey("second_y_var"))
                //{
                //    second_y_var = GadgetOptions.InputVariableList["second_y_var"];
                //}
                //if (GadgetOptions.InputVariableList.ContainsKey("second_y_var_type") && GadgetOptions.InputVariableList["second_y_var_type"].Equals("rate_per_100k"))
                //{
                //    y2type = Y2Type.RatePer100kPop;
                //}
                //else if (GadgetOptions.InputVariableList.ContainsKey("second_y_var_type") && GadgetOptions.InputVariableList["second_y_var_type"].Equals("cumulative_percent"))
                //{
                //    y2type = Y2Type.CumulativePercent;
                //}
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
                switch ((Parameters as IChartGadgetParameters).Y2AxisType)
                {
                    case 1:
                        if (Parameters.ColumnNames.Count > 1 && !String.IsNullOrEmpty(Parameters.ColumnNames[1]))
                        {
                            second_y_var = Parameters.ColumnNames[1];
                        }
                        break;
                    case 2:
                        y2type = Y2Type.RatePer100kPop;
                        if (Parameters.ColumnNames.Count > 1 && !String.IsNullOrEmpty(Parameters.ColumnNames[1]))
                        {
                            second_y_var = Parameters.ColumnNames[1];
                        }
                        break;
                    case 3:
                        y2type = Y2Type.CumulativePercent;
                        break;
                }

                List<XYColumnChartData> dataList = new List<XYColumnChartData>();

                foreach (KeyValuePair<DataTable, List<DescriptiveStatistics>> tableKvp in stratifiedFrequencyTables)
                {
                    double count = 0;
                    foreach (DescriptiveStatistics ds in tableKvp.Value)
                    {
                        count = count + ds.observations;
                    }

                    string strataValue = tableKvp.Key.TableName;
                    DataTable table = tableKvp.Key;

                    double cumulative_percent = 0;

                    foreach (DataRow row in table.Rows)
                    {
                        XYColumnChartData chartData = new XYColumnChartData();
                        chartData.X = strataValue;
                        chartData.Y = (double)row[1];

                        if (y2type != Y2Type.None)
                        {
                            foreach (DataRow dRow in DashboardHelper.DataSet.Tables[0].Rows)
                            {
                                //if (((row[0].ToString().Equals(dRow[GadgetOptions.MainVariableName].ToString()))||(row[0].ToString().Equals(dRow[Parameters.ColumnNames[0]].ToString()))) && (y2type == Y2Type.CumulativePercent || dRow[second_y_var] != DBNull.Value))
                                if ((row[0].ToString().Equals(dRow[Parameters.ColumnNames[0]].ToString())) && (y2type == Y2Type.CumulativePercent || dRow[second_y_var] != DBNull.Value))
                                {
                                    if (y2type == Y2Type.RatePer100kPop)
                                    {
                                        chartData.Y2 = chartData.Y / (Convert.ToDouble(dRow[second_y_var]) / 100000);
                                    }
                                    else if (y2type == Y2Type.CumulativePercent)
                                    {
                                        chartData.Y2 = cumulative_percent + (chartData.Y / count);
                                        cumulative_percent = chartData.Y2.Value;
                                    }
                                    else
                                    {
                                        chartData.Y2 = Convert.ToDouble(dRow[second_y_var]);
                                    }
                                    break;
                                }
                            }
                        }

                        else if (y2type == Y2Type.CumulativePercent)
                        {
                            foreach (DataRow dRow in DashboardHelper.DataSet.Tables[0].Rows)
                            {
                            }

                        }

                        chartData.S = row[0];
                        if(chartData.S == null || string.IsNullOrEmpty(chartData.S.ToString().Trim()))
                        {
                            chartData.S = Config.Settings.RepresentationOfMissing;
                        }
                        dataList.Add(chartData);
                    }
                }

                this.Dispatcher.BeginInvoke(new SetChartDataDelegate(SetChartData), dataList, strata);
            }
        }
コード例 #8
0
 protected virtual void SetChartData(List<XYColumnChartData> dataList, Strata strata)
 {
 }
コード例 #9
0
        protected override void SetChartData(List<XYColumnChartData> dataList, Strata strata)
        {
            PieChartSettings chartSettings = new PieChartSettings();
            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);

            double pct = 20;
            double.TryParse(txtAnnotationPercent.Text, out pct);

            chartSettings.AnnotationPercent = pct;

            switch (cmbChartKind.SelectedIndex)
            {
                case 0:
                    chartSettings.PieChartKind = PieChartKind.Pie2D;
                    break;
                case 1:
                    chartSettings.PieChartKind = PieChartKind.Pie;
                    break;
                case 2:
                    chartSettings.PieChartKind = PieChartKind.Donut2D;
                    break;
                case 3:
                    chartSettings.PieChartKind = PieChartKind.Donut;
                    break;
            }

            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.ShowAnnotations = (bool)checkboxAnnotations.IsChecked;
            chartSettings.ShowAnnotationValue = (bool)checkboxAnnotationValue.IsChecked;
            chartSettings.ShowAnnotationLabel = (bool)checkboxAnnotationLabel.IsChecked;
            chartSettings.ShowAnnotationPercent = (bool)checkboxAnnotationPercent.IsChecked;

            chartSettings.ShowLegend = (bool)checkboxShowLegend.IsChecked;
            chartSettings.ShowLegendBorder = (bool)checkboxShowLegendBorder.IsChecked;
            chartSettings.ShowLegendVarNames = (bool)checkboxShowVarName.IsChecked;

            Controls.Charting.PieChart pieChart = new Controls.Charting.PieChart(DashboardHelper, GadgetOptions, chartSettings, dataList);
            pieChart.Margin = new Thickness(0, 0, 0, 16);
            //Grid.SetColumn(columnChart, 1);
            pieChart.MouseEnter += new MouseEventHandler(chart_MouseEnter);
            pieChart.MouseLeave += new MouseEventHandler(chart_MouseLeave);
            panelMain.Children.Add(pieChart);
        }
コード例 #10
0
        protected override void GenerateChartData(Dictionary<DataTable, List<DescriptiveStatistics>> stratifiedFrequencyTables, Strata strata = null)
        {
            lock (syncLockData)
            {
                List<XYColumnChartData> dataList = new List<XYColumnChartData>();

                foreach (KeyValuePair<DataTable, List<DescriptiveStatistics>> tableKvp in stratifiedFrequencyTables)
                {
                    double count = 0;
                    foreach (DescriptiveStatistics ds in tableKvp.Value)
                    {
                        count = count + ds.observations;
                    }

                    string strataValue = tableKvp.Key.TableName;
                    DataTable table = tableKvp.Key;

                    foreach (DataRow row in table.Rows)
                    {
                        XYColumnChartData chartData = new XYColumnChartData();
                        chartData.X = strataValue;
                        chartData.Y = (double)row[1];
                        chartData.S = row[0];

                        if (chartData.S == null || string.IsNullOrEmpty(chartData.S.ToString().Trim()))
                        {
                            chartData.S = Config.Settings.RepresentationOfMissing;
                        }

                        dataList.Add(chartData);
                    }
                }

                this.Dispatcher.BeginInvoke(new SetChartDataDelegate(SetChartData), dataList, strata);
            }
        }
コード例 #11
0
        protected override void SetChartData(List<XYColumnChartData> dataList, Strata strata)
        {
            PieChartParameters chtParameters = (PieChartParameters)Parameters;
            if (dataList.Count > 0)
            {

                if (strata != null)
                {
                    chtParameters.ChartStrataTitle = strata.Filter;
                }
                else
                {
                    chtParameters.ChartStrataTitle = String.Empty;
                }

                Controls.Charting.PieChart pieChart = new Controls.Charting.PieChart(DashboardHelper, chtParameters, dataList);
                pieChart.Margin = new Thickness(0, 0, 0, 16);
                //Grid.SetColumn(columnChart, 1);
                pieChart.MouseEnter += new MouseEventHandler(chart_MouseEnter);
                pieChart.MouseLeave += new MouseEventHandler(chart_MouseLeave);
                panelMain.Children.Add(pieChart);
            }
        }
コード例 #12
0
        //protected void cmbXAxisLabelType_SelectionChanged(object sender, SelectionChangedEventArgs e)
        //{
        //    TextBox txtXAxisLabelValue = this.FindName("txtXAxisLabelValue") as TextBox;
        //    ComboBox cmbXAxisLabelType = this.FindName("cmbXAxisLabelType") as ComboBox;
        //    if (LoadingCombos || txtXAxisLabelValue == null) return;
        //    SetXAxisLabelControls();
        //}
        //protected void SetXAxisLabelControls()
        //{
        //    TextBox txtXAxisLabelValue = this.FindName("txtXAxisLabelValue") as TextBox;
        //    ComboBox cmbXAxisLabelType = this.FindName("cmbXAxisLabelType") as ComboBox;
        //    switch (cmbXAxisLabelType.SelectedIndex)
        //    {
        //        case 3:
        //            txtXAxisLabelValue.IsEnabled = true;
        //            break;
        //        case 0:
        //        case 1:
        //        case 2:
        //            txtXAxisLabelValue.IsEnabled = false;
        //            txtXAxisLabelValue.Text = string.Empty;
        //            break;
        //    }
        //}
        //protected override void CopyToClipboard()
        //{
        //    object el = this.FindName("panelMain");
        //    if (el is StackPanel)
        //    {
        //        StringBuilder sb = new StringBuilder();
        //        foreach(UIElement element in (el as StackPanel).Children)
        //        {
        //            if (element is Controls.Charting.IChart)
        //            {
        //                sb.AppendLine((element as Controls.Charting.IChart).SendDataToString());
        //            }
        //        }
        //        Clipboard.Clear();
        //        Clipboard.SetText(sb.ToString());
        //    }
        //}
        //protected virtual void cmbField_SelectionChanged(object sender, SelectionChangedEventArgs e)
        //{
        //    if(sender is ComboBox)
        //    {
        //        ComboBox cmbField = sender as ComboBox;
        //        CheckBox checkboxAllValues = null;
        //        CheckBox checkboxCommentLegalLabels = null;
        //        object element = this.FindName("checkboxAllValues");
        //        if(element != null && element is CheckBox)
        //        {
        //            checkboxAllValues = element as CheckBox;
        //        }
        //        element = this.FindName("checkboxCommentLegalLabels");
        //        if(element != null && element is CheckBox)
        //        {
        //            checkboxCommentLegalLabels = element as CheckBox;
        //        }
        //        if (cmbField.SelectedIndex >= 0)
        //        {
        //            Field field = DashboardHelper.GetAssociatedField(cmbField.SelectedItem.ToString());
        //            if (field != null && field is RenderableField)
        //            {
        //                FieldFlags flags = SetFieldFlags(field as RenderableField);
        //                if (checkboxAllValues != null)
        //                {
        //                    if (flags.IsDropDownListField || flags.IsRecodedField)
        //                    {
        //                        checkboxAllValues.IsEnabled = true;
        //                    }
        //                    else
        //                    {
        //                        checkboxAllValues.IsEnabled = false;
        //                        checkboxAllValues.IsChecked = false;
        //                    }
        //                }
        //                if (checkboxCommentLegalLabels != null)
        //                {
        //                    if (flags.IsCommentLegalField || flags.IsOptionField)
        //                    {
        //                        checkboxCommentLegalLabels.IsEnabled = true;
        //                    }
        //                    else
        //                    {
        //                        checkboxCommentLegalLabels.IsEnabled = false;
        //                        checkboxCommentLegalLabels.IsChecked = false;
        //                    }
        //                    if (!flags.IsCommentLegalField && !flags.IsOptionField)
        //                    {
        //                        checkboxCommentLegalLabels.IsChecked = flags.IsCommentLegalField;
        //                    }
        //                }
        //            }
        //        }
        //    }
        //}
        //protected void chart_MouseLeave(object sender, MouseEventArgs e)
        //{
        //    //SelectedChart = null;
        //}
        //protected void chart_MouseEnter(object sender, MouseEventArgs e)
        //{
        //    //object element = this.FindName("gadgetContextMenu");
        //    //if ((element is ContextMenu) && !(element as ContextMenu).IsOpen)
        //    //{
        //    //    SelectedChart = sender as Controls.Charting.IChart;
        //    //}
        //    //else
        //    //{
        //    //    SelectedChart = null;
        //    //}
        //}
        ///// <summary>
        ///// Converts the gadget's output to Html
        ///// </summary>
        ///// <returns></returns>
        //public override string ToHTML(string htmlFileName = "", int count = 0)
        //{
        //    TextBox txtChartTitle = null;
        //    StackPanel panelMain = null;
        //    object el = FindName("txtChartTitle");
        //    if (el is TextBox)
        //    {
        //        txtChartTitle = el as TextBox;
        //    }
        //    el = FindName("panelMain");
        //    if (el is StackPanel)
        //    {
        //        panelMain = el as StackPanel;
        //    }
        //    if (txtChartTitle == null || panelMain == null) return string.Empty;
        //    StringBuilder sb = new StringBuilder();
        //    sb.AppendLine("<h2>" + txtChartTitle.Text + "</h2>");
        //    foreach (UIElement element in panelMain.Children)
        //    {
        //        if (element is EpiDashboard.Controls.Charting.IChart)
        //        {
        //            sb.AppendLine(((EpiDashboard.Controls.Charting.IChart)element).ToHTML(htmlFileName, count, true, false));
        //        }
        //    }
        //    return sb.ToString();
        //}
        //protected enum Y2Type
        //{
        //    None,
        //    SingleField,
        //    RatePer100kPop,
        //    CumulativePercent
        //}
        protected virtual bool GenerateColumnChartData(Dictionary<DataTable, List<DescriptiveStatistics>> stratifiedFrequencyTables, Strata strata = null)
        {
            lock (syncLockData)
            {
                ColumnChartParameters chtParameters = (ColumnChartParameters)Parameters;

                string second_y_var = string.Empty;

                Y2Type y2type = Y2Type.None;

                //CORRECTED BELOW FOR COLUMN_CHART_PARAMETERS
                //if (GadgetOptions.InputVariableList.ContainsKey("second_y_var"))
                //{
                //    second_y_var = GadgetOptions.InputVariableList["second_y_var"];
                //}
                //if (GadgetOptions.InputVariableList.ContainsKey("second_y_var_type") && GadgetOptions.InputVariableList["second_y_var_type"].Equals("rate_per_100k"))
                //{
                //    y2type = Y2Type.RatePer100kPop;
                //}
                //else if (GadgetOptions.InputVariableList.ContainsKey("second_y_var_type") && GadgetOptions.InputVariableList["second_y_var_type"].Equals("cumulative_percent"))
                //{
                //    y2type = Y2Type.CumulativePercent;
                //}

                if (chtParameters.ColumnNames.Count > 1 && !String.IsNullOrEmpty(chtParameters.ColumnNames[1]))
                {
                    second_y_var = chtParameters.ColumnNames[1];
                }

                if (chtParameters.Y2AxisType == 2)
                {
                    y2type = Y2Type.RatePer100kPop;
                }
                else if (chtParameters.Y2AxisType == 3)
                {
                    y2type = Y2Type.CumulativePercent;
                }

                List<XYColumnChartData> dataList = new List<XYColumnChartData>();

                foreach (KeyValuePair<DataTable, List<DescriptiveStatistics>> tableKvp in stratifiedFrequencyTables)
                {
                    double count = 0;
                    foreach (DescriptiveStatistics ds in tableKvp.Value)
                    {
                        count = count + ds.observations;
                    }

                    // If there is only one table and the total for that table is zero, then no data can be displayed and thus no chart can be generated.
                    // Show a message to the user to this effect so they don't wonder why they're seeing a blank gadget.

                    // Commented out for now because of scenarios where the "One chart for each value of" option is used, and we're unsure how to handle
                    // showing this message in that case.

                    //if (count == 0 && stratifiedFrequencyTables.Count == 1)
                    //{
                    //    this.Dispatcher.BeginInvoke(new RenderFinishWithErrorDelegate(RenderFinishWithError), DashboardSharedStrings.GADGET_MSG_NO_DATA);
                    //    return false;
                    //}

                    string strataValue = tableKvp.Key.TableName;
                    DataTable table = tableKvp.Key;

                    double cumulative_percent = 0;

                    foreach (DataRow row in table.Rows)
                    {
                        XYColumnChartData chartData = new XYColumnChartData();
                        chartData.X = strataValue;
                        chartData.Y = (double)row[1];

                        if (y2type != Y2Type.None)
                        {
                            foreach (DataRow dRow in DashboardHelper.DataSet.Tables[0].Rows)
                            {
                                //if (row[0].ToString().Equals(dRow[GadgetOptions.MainVariableName].ToString()) && (y2type == Y2Type.CumulativePercent || dRow[second_y_var] != DBNull.Value))
                                if (row[0].ToString().Equals(dRow[chtParameters.ColumnNames[0]].ToString()) && (y2type == Y2Type.CumulativePercent || dRow[second_y_var] != DBNull.Value))
                                {
                                    if (y2type == Y2Type.RatePer100kPop)
                                    {
                                        chartData.Y2 = chartData.Y / (Convert.ToDouble(dRow[second_y_var]) / 100000);
                                    }
                                    else if (y2type == Y2Type.CumulativePercent)
                                    {
                                        chartData.Y2 = cumulative_percent + (chartData.Y / count);
                                        cumulative_percent = chartData.Y2.Value;
                                    }
                                    else
                                    {
                                        chartData.Y2 = Convert.ToDouble(dRow[second_y_var]);
                                    }
                                    break;
                                }
                            }
                        }

                        else if (y2type == Y2Type.CumulativePercent)
                        {
                            foreach (DataRow dRow in DashboardHelper.DataSet.Tables[0].Rows)
                            {
                            }

                        }

                        chartData.S = row[0];
                        if(chartData.S == null || string.IsNullOrEmpty(chartData.S.ToString().Trim()))
                        {
                            chartData.S = Config.Settings.RepresentationOfMissing;
                        }
                        dataList.Add(chartData);
                    }
                }

                this.Dispatcher.BeginInvoke(new SetChartDataDelegate(SetChartData), dataList, strata);
            }

            return true;
        }
コード例 #13
0
        protected virtual void GenerateChartData(Dictionary<DataTable, List<DescriptiveStatistics>> stratifiedFrequencyTables, Strata strata = null)
        {
            lock (syncLockData)
            {
                string second_y_var = string.Empty;

                Y2Type y2type = Y2Type.None;

                if (GadgetOptions.InputVariableList.ContainsKey("second_y_var"))
                {
                    second_y_var = GadgetOptions.InputVariableList["second_y_var"];
                }
                if (GadgetOptions.InputVariableList.ContainsKey("second_y_var_type") && GadgetOptions.InputVariableList["second_y_var_type"].Equals("rate_per_100k"))
                {
                    y2type = Y2Type.RatePer100kPop;
                }
                else if (GadgetOptions.InputVariableList.ContainsKey("second_y_var_type") && GadgetOptions.InputVariableList["second_y_var_type"].Equals("cumulative_percent"))
                {
                    y2type = Y2Type.CumulativePercent;
                }

                List<XYColumnChartData> dataList = new List<XYColumnChartData>();

                foreach (KeyValuePair<DataTable, List<DescriptiveStatistics>> tableKvp in stratifiedFrequencyTables)
                {
                    double count = 0;
                    foreach (DescriptiveStatistics ds in tableKvp.Value)
                    {
                        count = count + ds.observations;
                    }

                    string strataValue = tableKvp.Key.TableName;
                    DataTable table = tableKvp.Key;

                    double cumulative_percent = 0;

                    foreach (DataRow row in table.Rows)
                    {
                        XYColumnChartData chartData = new XYColumnChartData();
                        chartData.X = strataValue;
                        chartData.Y = (double)row[1];

                        if (y2type != Y2Type.None)
                        {
                            foreach (DataRow dRow in DashboardHelper.DataSet.Tables[0].Rows)
                            {
                                if (row[0].ToString().Equals(dRow[GadgetOptions.MainVariableName].ToString()) && (y2type == Y2Type.CumulativePercent || dRow[second_y_var] != DBNull.Value))
                                {
                                    if (y2type == Y2Type.RatePer100kPop)
                                    {
                                        chartData.Y2 = chartData.Y / (Convert.ToDouble(dRow[second_y_var]) / 100000);
                                    }
                                    else if (y2type == Y2Type.CumulativePercent)
                                    {
                                        chartData.Y2 = cumulative_percent + (chartData.Y / count);
                                        cumulative_percent = chartData.Y2.Value;
                                    }
                                    else
                                    {
                                        chartData.Y2 = Convert.ToDouble(dRow[second_y_var]);
                                    }
                                    break;
                                }
                            }
                        }

                        else if (y2type == Y2Type.CumulativePercent)
                        {
                            foreach (DataRow dRow in DashboardHelper.DataSet.Tables[0].Rows)
                            {
                            }

                        }

                        chartData.S = row[0];
                        if (chartData.S == null || string.IsNullOrEmpty(chartData.S.ToString().Trim()))
                        {
                            chartData.S = Config.Settings.RepresentationOfMissing;
                        }
                        dataList.Add(chartData);
                    }

                    var query = from chartData in dataList
                                orderby chartData.S ascending
                                select chartData;

                    XYColumnChartData firstObj = query.First();
                    XYColumnChartData lastObj = query.Last();

                    if (XAxisStart.HasValue && XAxisStart.Value >= 0 &&
                        (table.Columns[0].DataType.ToString().Equals("System.Single") ||
                        table.Columns[0].DataType.ToString().Equals("System.Double") ||
                        table.Columns[0].DataType.ToString().Equals("System.Decimal")))
                    {
                        if (Convert.ToDouble(lastObj.S) > XAxisStart.Value)
                        {
                            XYColumnChartData fillerFirst = new XYColumnChartData();
                            fillerFirst.Y = 0;
                            fillerFirst.X = strataValue;
                            fillerFirst.S = XAxisStart.Value;
                            dataList.Add(fillerFirst);
                        }
                    }

                    if (XAxisEnd.HasValue && XAxisEnd.Value >= 0 &&
                        (table.Columns[0].DataType.ToString().Equals("System.Single") ||
                        table.Columns[0].DataType.ToString().Equals("System.Double") ||
                        table.Columns[0].DataType.ToString().Equals("System.Decimal")))
                    {
                        if (Convert.ToDouble(lastObj.S) < XAxisEnd.Value)
                        {
                            XYColumnChartData fillerLast = new XYColumnChartData();
                            fillerLast.Y = 0;
                            fillerLast.X = strataValue;
                            fillerLast.S = XAxisEnd.Value;
                            dataList.Add(fillerLast);
                        }
                    }
                }

                this.Dispatcher.BeginInvoke(new SetChartDataDelegate(SetChartData), dataList, strata);
            }
        }