Пример #1
0
 private void bgw_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     Util.Flush();
     btn_start.IsEnabled = true;
     if (e.Error != null)
     {
         System.Windows.MessageBox.Show(e.Error.Message.ToString());
         tb_log.Text += e.Error.Message.ToString() + "\n";
     }
     if (clusterList != null)
     {
         ArrayList values1 = new ArrayList(); ArrayList values3 = new ArrayList(); ArrayList values2 = new ArrayList();
         ArrayList temp = clusterList.valList;
         for (int i = 0; i < temp.Count; i++)
         {
             double[] dt = (double[])temp[i];
             values1.Add(dt[0]); values2.Add(dt[1]); values3.Add(dt[2]);
         }
         if (values1 != null && values2 != null && values3 != null)
         {
             ChartHelper      ch = new ChartHelper();
             ChartInformation ci = new ChartInformation();
             ci.ImportLineData(values1, values2, values3);
             Chart m_chart = ch.CreateChart(ci);
             WindowResultLineChart m_window = new WindowResultLineChart(m_chart);
             m_window.Show();
         }
     }
 }
Пример #2
0
        public Chart CreateChart(ChartInformation ci)
        {
            m_chart = new Chart();

            m_chart.ToolBarEnabled = true;
            m_chart.ZoomingEnabled = true;
            m_chart.ZoomingMode    = ZoomingMode.MouseDragAndWheel;

            m_chart.BorderThickness = ci.m_BorderThickness;
            m_chart.Theme           = ci.m_Theme;
            m_chart.View3D          = ci.m_View3D;

            Axis m_axisX = new Axis();

            m_axisX.Title = ci.m_axisXTitle;
            m_chart.AxesX.Add(m_axisX);

            Axis m_asixY = new Axis();

            m_asixY.Title         = ci.m_axisYTitle;
            m_asixY.Enabled       = true;
            m_asixY.StartFromZero = true;
            m_asixY.AxisType      = AxisTypes.Primary;
            //m_asixY.AxisMaximum = ci.m_axisYMaximum;
            //m_asixY.Interval = ci.m_axisYInterval;
            m_chart.AxesY.Add(m_asixY);
            for (int i = 0; i < ci.dsc.Count; i++)
            {
                DataSeries ds = new DataSeries();
                ds.LegendText = ci.dsc[i].LegendText;
                ds.RenderAs   = ci.dsc[i].RenderAs;
                ds.AxisYType  = ci.dsc[i].AxisYType;
                ds.DataPoints = new DataPointCollection(ci.dsc[i].DataPoints);
                m_chart.Series.Add(ds);
            }
            m_chart.Rendered += new EventHandler(chart_Rendered);
            //添加图例点击响应事件
            SetLegendwithClickHandler();
            return(m_chart);
        }