示例#1
0
        public void updateChartModel(VsChartModel model)
        {
            //MessageBox.Show(System.IO.Directory.GetCurrentDirectory());
            try
            {
                m_chartSample1.ChartDescription.Columns.Clear();
                m_panelChartLegend.ChartLegendDescription.Items.Clear();
                if (model.dataModel.Count > 0)
                {
                    //MessageBox.Show("this" +model.dataModel.Count );


                    //list<colum<value>>
                    List <List <int> > data = new List <List <int> >();
                    List <string>      cams = new List <string>();

                    foreach (string head in model.headerNsme)
                    {
                        data.Add(new List <int>());
                    }


                    foreach (KeyValuePair <string, List <int> > kvp in model.dataModel)
                    {
                        //ChartColumn column = m_chartSample1.AddColumn(kvp);
                        int  sum       = 0;
                        int  c         = 0;
                        bool zeroValue = true;

                        foreach (int v in kvp.Value)
                        {
                            if (v > 0)
                            {
                                zeroValue = false;
                                break;
                            }
                        }

                        if (zeroValue)//debuggg
                        {
                            //c = 0;
                            foreach (int v in kvp.Value)
                            {
                                data[c].Add(v + 1);
                                sum = 0;
                                c++;
                            }

                            //MessageBox.Show("rero");
                        }
                        else
                        {
                            foreach (int v in kvp.Value)
                            {
                                data[c].Add(v);
                                //MessageBox.Show(">0");
                                sum += v;
                                c++;
                            }
                        }

                        cams.Add(kvp.Key);
                    }
                    int cc = 0;
                    foreach (string head in model.headerNsme)
                    {
                        ChartColumn column = m_chartSample1.AddColumn(data[cc].ToArray());
                        cc++;
                        column.Title = head;
                    }

                    Color[] predefinedColors = m_chartSample1.ChartDescription.PredefinedColors;

                    for (int i = 0; i < m_chartSample1.ChartDescription.NumberOfItemsPerColumn; i++)
                    {
                        m_panelChartLegend.AddItem(predefinedColors[i], cams[i]);
                    }

                    this.m_chartSample1.ChartDescription.VerticalAxisStep = 10000;//for auto set when step over
                    m_chartSample1.ChartDescription.BottomMargin          = 80;

                    m_chartSample1.ChartDescription.MainTitle = model.mainTitle;
                    //m_chartSample1.ChartDescription.RenderingMode = ChartRenderingMode.Linear3d;
                    m_chartSample1.ChartDescription.DisplayHiddenSides = false;
                    m_chartSample1.CumulativeMode = ChartCumulativeMode.StartFrom0;

                    this.m_chartSample1.ChartDescription.VerticalAxisMinValue = 1;//for buggggggggggg?????????
                }
                m_panelChartLegend.Invalidate();
                m_chartSample1.Invalidate();
            }
            catch (Exception err)
            {
                logger.Log(LogLevel.Error, err.Message + " " + err.Source + " " + err.StackTrace);;
            }
        }