示例#1
0
    private void BuildChart(DataTable labs)
    {
        SessionHandler sh        = new SessionHandler(Session);
        int            patientId = sh.GetPatientId();

        // get a list of selected charting types
        var selectedLabs = from labItem in LabCheckList.Items.Cast <ListItem>()
                           where labItem.Selected
                           select labItem.Value;

        if (selectedLabs.Count() > 0)
        {
            LabCheckList2.Visible = true;

            if (LabCheckList2.SelectedValue.Length > 0)
            {
                selectedLabs = selectedLabs.Union
                                   (from labItem in LabCheckList2.Items.Cast <ListItem>()
                                   where labItem.Selected
                                   select labItem.Value);


                MainChart.BuildChart(labs, selectedLabs);


                // if there are exactly two labs to chart, use right Y axis for second series
                if (MainChart.Series.Count.Equals(2))
                {
                    MainChart.ChartAreas[0].AxisY.Enabled = AxisEnabled.True;
                    MainChart.Series[0].YAxisType         = AxisType.Primary;
                    MainChart.Series[0].XAxisType         = AxisType.Primary;
                    MainChart.Series[0].XValueType        = ChartValueType.DateTime;
//                    MainChart.ChartAreas[0].AxisY.LineColor = MainChart.Series[0].Color;
//                    MainChart.ChartAreas[0].AxisY.LineWidth = 2;
                    MainChart.ChartAreas[0].AxisY.TitleForeColor = MainChart.Series[0].Color;

                    MainChart.ChartAreas[0].AxisY2.Enabled           = AxisEnabled.True;
                    MainChart.ChartAreas[0].AxisY2.MajorGrid.Enabled = false;
                    MainChart.Series[1].YAxisType  = AxisType.Secondary;
                    MainChart.Series[1].XAxisType  = AxisType.Primary;
                    MainChart.Series[1].XValueType = ChartValueType.DateTime;
                    //                   MainChart.ChartAreas[0].AxisY2.LineColor = MainChart.Series[1].Color;
//                    MainChart.ChartAreas[0].AxisY2.LineWidth = 2;
//                    MainChart.ChartAreas[0].AxisY2.MajorTickMark.LineColor = MainChart.Series[1].Color;
                    MainChart.ChartAreas[0].AxisY2.Title           = MainChart.Series[1].Name;
                    MainChart.ChartAreas[0].AxisY2.TextOrientation = TextOrientation.Rotated270;
                    MainChart.ChartAreas[0].AxisY2.TitleForeColor  = MainChart.Series[1].Color;
//                    MainChart.ChartAreas[0].AxisY2.TitleFont = new Font(MainChart.ChartAreas[0].AxisY2.TitleFont, FontStyle.Bold);

                    MainChart.ChartAreas[0].AxisX.Minimum = (MainChart.Series[0].Points[0].XValue < MainChart.Series[1].Points[0].XValue) ? MainChart.Series[0].Points[0].XValue : MainChart.Series[1].Points[0].XValue;
                }

                MainChart.ChartAreas[0].AxisY.Title           = MainChart.Series[0].Name;
                MainChart.ChartAreas[0].AxisY.TextOrientation = TextOrientation.Rotated90;
//                MainChart.ChartAreas[0].AxisY.TitleFont = new Font(MainChart.ChartAreas[0].AxisY.TitleFont, FontStyle.Bold);
            }
            else
            {
                MainChart.BuildChart(labs, selectedLabs);
            }


            SetMinMaxDates(labs, selectedLabs);



            // override default width
            if (!String.IsNullOrEmpty(Request.QueryString["width"]))
            {
                MainChart.Width = int.Parse(Request.QueryString["width"]);
            }

            // override default height
            if (!String.IsNullOrEmpty(Request.QueryString["height"]))
            {
                MainChart.Height = int.Parse(Request.QueryString["height"]);
            }

            chartErrors.Visible   = false;
            chartErrors.InnerHtml = "";
            foreach (string selectedLab in selectedLabs)
            {
                if (LabHasBadPoints.Contains(selectedLab))
                {
                    chartErrors.Visible    = true;
                    chartErrors.InnerHtml += ("One or more " + selectedLab + " values could not be graphed.<br/><br/>");
                }
            }
        }
    }