MSChart Changing Colors

KadirKadir T??rkiye
edited 3:56PM in FastReport .NET
I'm trying to change MSChart colors to fromARGB which came from data.
here is the code I couldnt understand what is the problem.
public class ReportScript
{
int x = 0 ;
Color[] clr = new Color[3] ;
private void Data1_BeforeLayout(object sender, EventArgs e)
{

}

private void ReportSummary1_BeforeLayout(object sender, EventArgs e)
{
MSChart2.Chart.Series[0].Points[0].Color = clr[0] ;
MSChart2.Chart.Series[0].Points[1].Color = clr[1] ;
MSChart2.Chart.Series[0].Points[2].Color = clr[2] ;
Text25.TextColor = clr[0] ;
Text26.TextColor = clr[1] ;
Text27.TextColor = clr[2] ;

}

private void GroupHeader1_BeforeLayout(object sender, EventArgs e)
{
clr[x] =Color.FromArgb(((Int32)Report.GetColumnValue("VERI.a_renk")));
x+=1 ;
}
}

Thanks for helping.

Comments

  • edited May 2017
    no problem with your code....maybe integer color value problem???
        private void ReportTitle1_BeforeLayout(object sender, EventArgs e)
        {
          Random random = new Random();
          DataPointCollection dpc = MSChart2.Chart.Series[0].Points;
          foreach (DataPoint dp in dpc)
          {
            Color c = Color.FromArgb(random.Next(0, 255), random.Next(0, 255), random.Next(0, 255));
            dp.Color = c;
          }
        }
    
  • KadirKadir T??rkiye
    edited 3:56PM
    Thank you very much for your reply. I am sorry to give you less informaiton about the problem.
    When tried your code (and also mine) I took CS0246 Name or name does not exist ... then I add using
    using System.Windows.Forms.DataVisualization;
    then
    I took CS0234 error, means The type or namespace name 'name' does not exist in the namespace

    ipong wrote: »
    no problem with your code....maybe integer color value problem???
        private void ReportTitle1_BeforeLayout(object sender, EventArgs e)
        {
          Random random = new Random();
          DataPointCollection dpc = MSChart2.Chart.Series[0].Points;
          foreach (DataPoint dp in dpc)
          {
            Color c = Color.FromArgb(random.Next(0, 255), random.Next(0, 255), random.Next(0, 255));
            dp.Color = c;
          }
        }
    
  • edited 3:56PM
    here is working example, replace file in C:\Program Files (x86)\FastReports\FastReport.Net Trial\Demos\Reports
  • KadirKadir T??rkiye
    edited 3:56PM
    Thank you so much ipong.
    This was so helpful.
    By the way, i found where my mistake is...
    Report / Options / script And simply add the assembly... >
    ipong wrote: »
    here is working example, replace file in C:\Program Files (x86)\FastReports\FastReport.Net Trial\Demos\Reports

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.