Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. MSChart labels

MSChart labels

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    Hi I've read the article in Code project about the mschart and how to set data. Now I would like to know how to set the labels. Can anyone help? Thanks

    R 1 Reply Last reply
    0
    • L Lost User

      Hi I've read the article in Code project about the mschart and how to set data. Now I would like to know how to set the labels. Can anyone help? Thanks

      R Offline
      R Offline
      Richard Ellis
      wrote on last edited by
      #2

      G'Day Anon I may have the answer for you though I'm not 100% sure because I'm yet to get it working myself - but I have run out of time for the moment. using the example on code project I have added the following code when the GO button is pressed. I have placed it just before the chart is refreshed. The first bit sets the legend (only did 1 to see if it worked) CVcPlot Plot = m_Chart.GetPlot(); CVcSeriesCollection SeriesCollection = Plot.GetSeriesCollection(); CVcSeries Series = SeriesCollection.GetItem(1); Series.SetLegendText(_T("New Text")); The next bit was to do the labels for each point on the axis. It is incomplete and not quite working but hopefully it will give you an idea and you can let me know how to fix it :-) I am getting a bad function argument error when calling SetColumnLabel or SetRowLabel - something to do with my indexes I think. CVcDataGrid DataGrid = m_Chart.GetDataGrid(); short i; CString strLabel; short nRows = DataGrid.GetRowLabelCount(); short nColumns = DataGrid.GetColumnLabelCount(); /* for (i=0; i

      R 3 Replies Last reply
      0
      • R Richard Ellis

        G'Day Anon I may have the answer for you though I'm not 100% sure because I'm yet to get it working myself - but I have run out of time for the moment. using the example on code project I have added the following code when the GO button is pressed. I have placed it just before the chart is refreshed. The first bit sets the legend (only did 1 to see if it worked) CVcPlot Plot = m_Chart.GetPlot(); CVcSeriesCollection SeriesCollection = Plot.GetSeriesCollection(); CVcSeries Series = SeriesCollection.GetItem(1); Series.SetLegendText(_T("New Text")); The next bit was to do the labels for each point on the axis. It is incomplete and not quite working but hopefully it will give you an idea and you can let me know how to fix it :-) I am getting a bad function argument error when calling SetColumnLabel or SetRowLabel - something to do with my indexes I think. CVcDataGrid DataGrid = m_Chart.GetDataGrid(); short i; CString strLabel; short nRows = DataGrid.GetRowLabelCount(); short nColumns = DataGrid.GetColumnLabelCount(); /* for (i=0; i

        R Offline
        R Offline
        Ruca
        wrote on last edited by
        #3

        Hi Richard, Sorry that I'm only answering now, it's just that I've been busy and only had the time to do this now. I tried what you suggested and also get the same "bad function argument" error. So I tried the following: short index; for ( i = 1; i < 11; i++ ) { //strLabel.Format("row %d", i); // strLabel = "Row Text"; index = i * 2; // DataGrid.SetColumnLabel(index, 1, ""); strLabel = DataGrid.GetColumnLabel(index, 1); } And I get all the correct column names, i.e. R1, R2, R3, ... R10. It almost seems to be the actual string variable that seems to give the problem??? Still trying. Have you had any success? Rui Rui

        1 Reply Last reply
        0
        • R Richard Ellis

          G'Day Anon I may have the answer for you though I'm not 100% sure because I'm yet to get it working myself - but I have run out of time for the moment. using the example on code project I have added the following code when the GO button is pressed. I have placed it just before the chart is refreshed. The first bit sets the legend (only did 1 to see if it worked) CVcPlot Plot = m_Chart.GetPlot(); CVcSeriesCollection SeriesCollection = Plot.GetSeriesCollection(); CVcSeries Series = SeriesCollection.GetItem(1); Series.SetLegendText(_T("New Text")); The next bit was to do the labels for each point on the axis. It is incomplete and not quite working but hopefully it will give you an idea and you can let me know how to fix it :-) I am getting a bad function argument error when calling SetColumnLabel or SetRowLabel - something to do with my indexes I think. CVcDataGrid DataGrid = m_Chart.GetDataGrid(); short i; CString strLabel; short nRows = DataGrid.GetRowLabelCount(); short nColumns = DataGrid.GetColumnLabelCount(); /* for (i=0; i

          R Offline
          R Offline
          Ruca
          wrote on last edited by
          #4

          Hi Richard, I tried the following: DataGrid.SetColumnLabel(1, 1, "Column 1"); strLabel = DataGrid.GetColumnLabel(1, 1); AfxMessageBox(strLabel); This enables the C1 text in the datagrid to be changed. This seems to be the name of the first set of data. But I'm still not able to change the Column labels. Does anyone have a clue how to do it? Regards Rui

          1 Reply Last reply
          0
          • R Richard Ellis

            G'Day Anon I may have the answer for you though I'm not 100% sure because I'm yet to get it working myself - but I have run out of time for the moment. using the example on code project I have added the following code when the GO button is pressed. I have placed it just before the chart is refreshed. The first bit sets the legend (only did 1 to see if it worked) CVcPlot Plot = m_Chart.GetPlot(); CVcSeriesCollection SeriesCollection = Plot.GetSeriesCollection(); CVcSeries Series = SeriesCollection.GetItem(1); Series.SetLegendText(_T("New Text")); The next bit was to do the labels for each point on the axis. It is incomplete and not quite working but hopefully it will give you an idea and you can let me know how to fix it :-) I am getting a bad function argument error when calling SetColumnLabel or SetRowLabel - something to do with my indexes I think. CVcDataGrid DataGrid = m_Chart.GetDataGrid(); short i; CString strLabel; short nRows = DataGrid.GetRowLabelCount(); short nColumns = DataGrid.GetColumnLabelCount(); /* for (i=0; i

            R Offline
            R Offline
            Ruca
            wrote on last edited by
            #5

            hi Richard, The following works: COleSafeArray saRet; CString strLabel = ""; DWORD numElements[] = {10, 1}; // 10x10 //DWORD numElements[] = {10}; // Create the safe-array... saRet.Create(VT_R8, 2, numElements); // Initialize it with values... long index[2]; for(index[0] = 0; index[0] < 10; index[0]++) { for(index[1] = 0; index[1] < 1; index[1]++) { double val = index[0]*10; saRet.PutElement(index, &val); } } // Return the safe-array encapsulated in a VARIANT... m_Chart.SetChartData(saRet.Detach()); m_Chart.SetChartType(3); CVcPlot Plot = m_Chart.GetPlot(); CVcSeriesCollection SeriesCollection = Plot.GetSeriesCollection(); CVcSeries Series = SeriesCollection.GetItem(1); Series.SetLegendText(_T("New Text")); CVcDataGrid DataGrid = m_Chart.GetDataGrid(); short i; short nRows = DataGrid.GetRowLabelCount(); short nColumns = DataGrid.GetColumnLabelCount(); /* for (i=0; i { strLabel.Format("col %d", i); DataGrid.SetColumnLabel(i, 1, strLabel); } */ short j; // DataGrid.SetColumnLabelCount(10); // count = DataGrid.GetColumnLabelCount(); for ( i = 1; i < 6; i++ ) { //strLabel.Format("row %d", i); strLabel = "Row Text"; j = i * 2; // DataGrid.SetColumnLabel(j, 1, strLabel); strLabel = DataGrid.GetColumnLabel(j, 1); //AfxMessageBox(strLabel); DataGrid.SetRowLabel(i, 1, "Row"); strLabel = DataGrid.GetRowLabel(i, 1); } m_Chart.SetShowLegend(TRUE); m_Chart.Refresh(); Try it. Thanks for your help Rui

            R 1 Reply Last reply
            0
            • R Ruca

              hi Richard, The following works: COleSafeArray saRet; CString strLabel = ""; DWORD numElements[] = {10, 1}; // 10x10 //DWORD numElements[] = {10}; // Create the safe-array... saRet.Create(VT_R8, 2, numElements); // Initialize it with values... long index[2]; for(index[0] = 0; index[0] < 10; index[0]++) { for(index[1] = 0; index[1] < 1; index[1]++) { double val = index[0]*10; saRet.PutElement(index, &val); } } // Return the safe-array encapsulated in a VARIANT... m_Chart.SetChartData(saRet.Detach()); m_Chart.SetChartType(3); CVcPlot Plot = m_Chart.GetPlot(); CVcSeriesCollection SeriesCollection = Plot.GetSeriesCollection(); CVcSeries Series = SeriesCollection.GetItem(1); Series.SetLegendText(_T("New Text")); CVcDataGrid DataGrid = m_Chart.GetDataGrid(); short i; short nRows = DataGrid.GetRowLabelCount(); short nColumns = DataGrid.GetColumnLabelCount(); /* for (i=0; i { strLabel.Format("col %d", i); DataGrid.SetColumnLabel(i, 1, strLabel); } */ short j; // DataGrid.SetColumnLabelCount(10); // count = DataGrid.GetColumnLabelCount(); for ( i = 1; i < 6; i++ ) { //strLabel.Format("row %d", i); strLabel = "Row Text"; j = i * 2; // DataGrid.SetColumnLabel(j, 1, strLabel); strLabel = DataGrid.GetColumnLabel(j, 1); //AfxMessageBox(strLabel); DataGrid.SetRowLabel(i, 1, "Row"); strLabel = DataGrid.GetRowLabel(i, 1); } m_Chart.SetShowLegend(TRUE); m_Chart.Refresh(); Try it. Thanks for your help Rui

              R Offline
              R Offline
              Richard Ellis
              wrote on last edited by
              #6

              G'Day Rui, I'd forgotten all about this! I'll dig out the code I was playing with at the time and try it out. Thanks for your help! Richard.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups