none
axchartspace et c# RRS feed

  • Discussion générale

  • Comment à partir des données d'un listvieww, je peux construire un histogramme à partir d'un axchartspace.

    J'ai vraiment besoin d'une reponse.

    voici un extrait de mon code mais qui ne marche pas

    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using Librairy;
    using System.Windows.Forms;
    using System.Collections;
    using Microsoft.Office.Interop.Owc11;

    string[] tabcategory, tabprevision,tabreal;

     ChChart ochart;
     ChSeries oser;

     tabcategory = new string[listViewpreform.Items.Count];
                    tabprevision = new string[listViewpreform.Items.Count];
                    tabreal = new string[listViewpreform.Items.Count];
                   for (int k = 0; k < listViewpreform.Items.Count; k++)
                    {
                        tabcategory[k] = listViewpreform.Items[k].SubItems[0].Text;
                        tabprevision[k] = listViewpreform.Items[k].SubItems[1].Text;
                        tabreal[k] = listViewpreform.Items[k].SubItems[2].Text;
                    }
                     
                      axChartSpace1.Clear();
                      ochart = axChartSpace1.Charts.Add(0);
                      ochart.HasLegend = true;
                      oser = ochart.SeriesCollection.Add(0);
                      oser.SetData(OWC11.ChartDimensionsEnum.chDimSeriesNames,1, listViewpreform.Columns[1].Text);
                      oser.SetData(OWC11.ChartDimensionsEnum.chDimCategories, 1, tabcategory);
                      oser.SetData(OWC11.ChartDimensionsEnum.chDimValues, 1, tabprevision);
                      oser = ochart.SeriesCollection.Add(0);
                      oser.SetData(OWC11.ChartDimensionsEnum.chDimSeriesNames, 1, listViewpreform.Columns[2].Text);
                      oser.SetData(OWC11.ChartDimensionsEnum.chDimCategories, 1, tabcategory);
                      oser.SetData(OWC11.ChartDimensionsEnum.chDimValues, 1, tabreal);

    erreur:datasource index non valid                

    samedi 27 octobre 2012 23:59

Toutes les réponses