Group: Forum Members
Last Active: 2 Years Ago
Posts: 21,
Visits: 74
|
Hi I created a simle chart, make grid visible on X axis in Red color . Then I added a button and if I click on the button I ' d like to change X Axis Grid color to Yellow .& nbsp ; But it doesn ' t work . Could you help me , please ?& nbsp ; Designer source code:namespace WinFormsApp1 { & nbsp ; partial class Form1 & nbsp ; { & nbsp ;& nbsp ; /// & lt ; summary & gt ; & nbsp ;& nbsp ; /// Required designer variable . & nbsp ;& nbsp ; /// & lt ;/ summary & gt ; & nbsp ;& nbsp ; private System . ComponentModel . IContainer components = null ; & nbsp ;& nbsp ; /// & lt ; summary & gt ; & nbsp ;& nbsp ; /// Clean up any resources being used . & nbsp ;& nbsp ; /// & lt ;/ summary & gt ; & nbsp ;& nbsp ; /// & lt ; param name =" disposing "& gt ; true if managed resources should be disposed ; otherwise , false .& lt ;/ param & gt ; & nbsp ;& nbsp ; protected override void Dispose ( bool disposing ) & nbsp ;& nbsp ; { & nbsp ;& nbsp ;& nbsp ;& nbsp ; if ( disposing & amp ;& amp ; ( components != null )) & nbsp ;& nbsp ;& nbsp ;& nbsp ;{ & nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ; components . Dispose (); & nbsp ;& nbsp ;& nbsp ;& nbsp ;} & nbsp ;& nbsp ;& nbsp ;& nbsp ; base . Dispose ( disposing ); & nbsp ;& nbsp ; } & nbsp ;& nbsp ; # region Windows Form Designer generated code & nbsp ;& nbsp ; /// & lt ; summary & gt ; & nbsp ;& nbsp ; /// Required method for Designer support - do not modify & nbsp ;& nbsp ; /// the contents of this method with the code editor . & nbsp ;& nbsp ; /// & lt ;/ summary & gt ; & nbsp ;& nbsp ; private void InitializeComponent () & nbsp ;& nbsp ; { & nbsp ;& nbsp ;& nbsp ;& nbsp ; this . button1 = new System . Windows . Forms . Button (); & nbsp ;& nbsp ;& nbsp ;& nbsp ; this . SuspendLayout (); & nbsp ;& nbsp ;& nbsp ;& nbsp ;// & nbsp ;& nbsp ;& nbsp ;& nbsp ;// button1 & nbsp ;& nbsp ;& nbsp ;& nbsp ;// & nbsp ;& nbsp ;& nbsp ;& nbsp ; this . button1 . Location = new System . Drawing . Point ( 12 , 12 ); & nbsp ;& nbsp ;& nbsp ;& nbsp ; this . button1 . Name = " button1 "; & nbsp ;& nbsp ;& nbsp ;& nbsp ; this . button1 . Size = new System . Drawing . Size ( 75 , 23 ); & nbsp ;& nbsp ;& nbsp ;& nbsp ; this . button1 . TabIndex = 0 ; & nbsp ;& nbsp ;& nbsp ;& nbsp ; this . button1 . Text = " button1 "; & nbsp ;& nbsp ;& nbsp ;& nbsp ; this . button1 . UseVisualStyleBackColor = true ; & nbsp ;& nbsp ;& nbsp ;& nbsp ; this . button1 . Click += new System . EventHandler ( this . button1_Click ); & nbsp ;& nbsp ;& nbsp ;& nbsp ;// & nbsp ;& nbsp ;& nbsp ;& nbsp ;// Form1 & nbsp ;& nbsp ;& nbsp ;& nbsp ;// & nbsp ;& nbsp ;& nbsp ;& nbsp ; this . AutoScaleDimensions = new System . Drawing . SizeF ( 7F , 15F ); & nbsp ;& nbsp ;& nbsp ;& nbsp ; this . AutoScaleMode = System . Windows . Forms . AutoScaleMode . Font ; & nbsp ;& nbsp ;& nbsp ;& nbsp ; this . ClientSize = new System . Drawing . Size ( 800 , 450 ); & nbsp ;& nbsp ;& nbsp ;& nbsp ; this . Controls . Add ( this . button1 ); & nbsp ;& nbsp ;& nbsp ;& nbsp ; this . Name = " Form1 "; & nbsp ;& nbsp ;& nbsp ;& nbsp ; this . Text = " Form1 "; & nbsp ;& nbsp ;& nbsp ;& nbsp ; this . ResumeLayout ( false ); & nbsp ;& nbsp ; } & nbsp ;& nbsp ; # endregion & nbsp ;& nbsp ; & nbsp ;& nbsp ; private Button button1 ; & nbsp ; } } CS file source code:using Nevron . Chart; using Nevron . GraphicsCore ; using System . Drawing ; namespace WinFormsApp1 { & nbsp ; public partial class Form1 : Form & nbsp ; { & nbsp ;& nbsp ; public Nevron . Chart. WinForm . N ChartControl n ChartControl1 ; & nbsp ;& nbsp ; public Form1 () & nbsp ;& nbsp ; { & nbsp ;& nbsp ;& nbsp ;& nbsp ; InitializeComponent (); & nbsp ;& nbsp ;& nbsp ;& nbsp ; this . n ChartControl1 = new Nevron . Chart. WinForm . N ChartControl (); & nbsp ;& nbsp ;& nbsp ;& nbsp ;// & nbsp ;& nbsp ;& nbsp ;& nbsp ;// _n ChartCtrl & nbsp ;& nbsp ;& nbsp ;& nbsp ;// & nbsp ;& nbsp ;& nbsp ;& nbsp ; this . n ChartControl1 . AllowDrop = true ; & nbsp ;& nbsp ;& nbsp ;& nbsp ; this . n ChartControl1 . AutoRefresh = false ; & nbsp ;& nbsp ;& nbsp ;& nbsp ; this . n ChartControl1 . BackColor = System . Drawing . SystemColors . Control ; & nbsp ;& nbsp ;& nbsp ;& nbsp ; this . n ChartControl1 . Dock = System . Windows . Forms . DockStyle . Fill ; & nbsp ;& nbsp ;& nbsp ;& nbsp ; this . n ChartControl1 . InputKeys = new System . Windows . Forms . Keys [ 0 ]; & nbsp ;& nbsp ;& nbsp ;& nbsp ; this . n ChartControl1 . Location = new System . Drawing . Point ( 0 , 0 ); & nbsp ;& nbsp ;& nbsp ;& nbsp ; this . n ChartControl1 . Name = " _n ChartCtrl "; & nbsp ;& nbsp ;& nbsp ;& nbsp ; this . n ChartControl1 . Size = new System . Drawing . Size ( 743 , 560 ); & nbsp ;& nbsp ;& nbsp ;& nbsp ; this . n ChartControl1 . TabIndex = 0 ; & nbsp ;& nbsp ;& nbsp ;& nbsp ; this . Controls . Add ( this . n ChartControl1 ); & nbsp ;& nbsp ;& nbsp ;& nbsp ;// set a chart title & nbsp ;& nbsp ;& nbsp ;& nbsp ; NLabel title = n ChartControl1 . Labels . AddHeader (" 2D Line Chart"); & nbsp ;& nbsp ;& nbsp ;& nbsp ; title . TextStyle . FontStyle = new NFontStyle (" Times New Roman ", 18 , FontStyle . Italic ); & nbsp ;& nbsp ;& nbsp ;& nbsp ; title . ContentAlignment = ContentAlignment . BottomCenter ; & nbsp ;& nbsp ;& nbsp ;& nbsp ; title . Location = new NPointL ( new NLength ( 50 , NRelativeUnit . ParentPercentage ), new NLength ( 2 , NRelativeUnit . ParentPercentage )); & nbsp ;& nbsp ;& nbsp ;& nbsp ;// no legend & nbsp ;& nbsp ;& nbsp ;& nbsp ; n ChartControl1 . Legends . Clear (); & nbsp ;& nbsp ;& nbsp ;& nbsp ;// configure the chart& nbsp ;& nbsp ;& nbsp ;& nbsp ; N Chart chart = n ChartControl1 . Charts [ 0 ]; & nbsp ;& nbsp ;& nbsp ;& nbsp ;// X Axis & nbsp ;& nbsp ;& nbsp ;& nbsp ; chart. Axis ( StandardAxis . PrimaryX ). ScaleConfigurator . MajorGridStyle . SetShowAtWall ( ChartWallType . Back , true ); & nbsp ;& nbsp ;& nbsp ;& nbsp ; chart. Axis ( StandardAxis . PrimaryX ). ScaleConfigurator . MajorGridStyle . LineStyle . Color = Color . Red ; & nbsp ;& nbsp ;& nbsp ;& nbsp ; N LineSeries line = ( N LineSeries) chart. Series. Add ( SeriesType . Line); & nbsp ;& nbsp ;& nbsp ;& nbsp ; line. Name = " Line Series"; & nbsp ;& nbsp ;& nbsp ;& nbsp ; line. InflateMargins = true ; & nbsp ;& nbsp ;& nbsp ;& nbsp ; line. DataLabelStyle . Format = "& lt ; value & gt ;"; & nbsp ;& nbsp ;& nbsp ;& nbsp ; line. MarkerStyle . Visible = true ; & nbsp ;& nbsp ;& nbsp ;& nbsp ; line. MarkerStyle . PointShape = PointShape . Cylinder ; & nbsp ;& nbsp ;& nbsp ;& nbsp ; line. MarkerStyle . Width = new NLength ( 1 . 5f , NRelativeUnit . ParentPercentage ); & nbsp ;& nbsp ;& nbsp ;& nbsp ; line. MarkerStyle . Height = new NLength ( 1 . 5f , NRelativeUnit . ParentPercentage ); & nbsp ;& nbsp ;& nbsp ;& nbsp ; line. ShadowStyle . Type = ShadowType . GaussianBlur ; & nbsp ;& nbsp ;& nbsp ;& nbsp ; line. ShadowStyle . Offset = new NPointL ( 3 , 3 ); & nbsp ;& nbsp ;& nbsp ;& nbsp ; line. ShadowStyle . FadeLength = new NLength ( 5 ); & nbsp ;& nbsp ;& nbsp ;& nbsp ; line. ShadowStyle . Color = Color . FromArgb ( 55 , 0 , 0 , 0 ); & nbsp ;& nbsp ;& nbsp ;& nbsp ; line. Values . FillRandom ( new Random (), 8 ); & nbsp ;& nbsp ; } & nbsp ;& nbsp ; private void button1_Click ( object sender , EventArgs e ) & nbsp ;& nbsp ; { & nbsp ;& nbsp ;& nbsp ;& nbsp ; n ChartControl1 . Charts [ 0 ]. Axis ( StandardAxis . PrimaryX ). ScaleConfigurator . MajorGridStyle . LineStyle . Color = Color . Yellow ; & nbsp ;& nbsp ;& nbsp ;& nbsp ; n ChartControl1 . Invalidate ( true ); & nbsp ;& nbsp ;& nbsp ;& nbsp ; n ChartControl1 . Charts [ 0 ]. Refresh (); & nbsp ;& nbsp ; } & nbsp ; } }
|
Group: Forum Members
Last Active: Last Month
Posts: 3,055,
Visits: 4,052
|
Hi Syrthey , It looks like there is a small issue with the scale configurator - it does not mark the scale for update so you need to force the update : This code worked Ok : & nbsp ; private void button1_Click ( object sender , EventArgs e ) & nbsp ;& nbsp ; { & nbsp ;& nbsp ;& nbsp ;& nbsp ; n ChartControl1 . Charts [ 0 ]. Axis ( StandardAxis . PrimaryX ). ScaleConfigurator . MajorGridStyle . LineStyle . Color = Color . Yellow ; & nbsp ;& nbsp ;& nbsp ;& nbsp ; n ChartControl1 . Charts [ 0 ]. Axis ( StandardAxis . PrimaryX ). InvalidateScale (); & nbsp ;& nbsp ;& nbsp ;& nbsp ; n ChartControl1 . Refresh (); & nbsp ;& nbsp ; } We ' ll be looking in detail in the problem and the fix will appear in the next major release of the control . We hope this helps - let us know if you have any questions or meet any problems .
Best Regards, Nevron Support Team
|
Group: Forum Members
Last Active: 2 Years Ago
Posts: 21,
Visits: 74
|
Hi! Thank you a lot for workaround! It works
|