user3510330
user3510330

Reputation: 97

syncfusion chart background line will be dotted line

I want my chart backgroud line will be dotted. Which property can i use for dotted in syncfusion? I tried but i coudn't do this. I don't know exactly which propertly will use for dotted line. Here is my code:

         control.AutoTempFileCleanUp = true;
        control.OutputFormat = ImageProviderOutputFormat.DiskFile;
        control.Model.Series.Clear();
        ChartModel chartModel = new ChartModel();
        ChartSeries chart = new ChartSeries(yAxisBar1LegendName, ChartSeriesType.Column);
        chart.Text = yAxisBar1LegendName;


       control.ChartArea.PrimaryXAxis.TickLabelsDrawingMode = ChartAxisTickLabelDrawingMode.UserMode;

        // = string.Format("");
        control.ChartArea.PrimaryXAxis.Labels.Add(new ChartAxisLabel("", Color.Black, new Font("Arial", 10), 0, "", ChartValueType.Custom));
        int counter = 1;

        DoubleRange dr = new DoubleRange(1, 100);

        foreach (DataRow row in ds.Tables[0].Rows)
        {

            double bar1Value = Convert.ToDouble(row[yAxisValueColumn1]);

            chart.Points.Add(counter, bar1Value);

            control.ChartArea.PrimaryXAxis.Labels.Add(new ChartAxisLabel(row["ModuleCode"].ToString(), Color.Black, new Font("Arial", 10), counter, "", ChartValueType.Custom));
            counter++;
        }

        chart.PrepareStyle += new ChartPrepareStyleInfoHandler(series_PrepareStyle);

        control.ChartArea.PrimaryXAxis.DrawGrid = false;
        control.PrimaryXAxis.GridLineType.ForeColor = Color.DarkGray;
        control.PrimaryYAxis.GridLineType.ForeColor = Color.DarkGray;
        control.PrimaryXAxis.LineType.ForeColor = Color.DarkGray;
        control.PrimaryYAxis.LineType.ForeColor = Color.DarkGray;
        control.Text = chartHeader;
        control.ChartArea.PrimaryYAxis.Title = yAxisText;
        control.ChartArea.PrimaryXAxis.Title = xAxisText;
        control.ChartArea.PrimaryXAxis.TitleAlignment = StringAlignment.Center;
        control.ChartArea.PrimaryXAxis.IsVisible = true;
        control.ChartArea.PrimaryXAxis.LabelAlignment = StringAlignment.Center;
        control.ChartArea.PrimaryXAxis.VisibleRange.Min = 0;
        control.ChartArea.PrimaryXAxis.VisibleRange.Max = counter;
        control.ChartArea.PrimaryXAxis.VisibleRange.Interval = 1;

        control.ChartArea.PrimaryYAxis.EdgeLabelsDrawingMode = ChartAxisEdgeLabelsDrawingMode.Center;
        control.ChartArea.PrimaryYAxis.GridDrawMode = ChartAxisGridDrawingMode.Default;
        //control.PrimaryXAxis.EdgeLabelsDrawingMode = ChartAxisEdgeLabelsDrawingMode.Center;
        control.PrimaryXAxis.Font = new Font("Arial", 10F);
        control.PrimaryYAxis.Font = new Font("Arial", 10F);




        counter = 0;
        foreach (ChartSeries series in control.Series)
        {
            Color color;
            if (counter == 0)
            {
                color = Color.Green;

            else
            {
                color = Color.Red;

            }
            series.Style.Interior = new BrushInfo(color);
            series.Style.Border.Color = Color.DarkGray;
            series.Style.Font.Bold = true;
            series.Style.TextColor = Color.Black;
            series.Style.TextOrientation = ChartTextOrientation.Left;
            series.Style.TextFormat = "{0}";
            counter++;
        }

        control.Width = 650;
        control.Series3D = false;
        control.ShowLegend = false;
        control.BorderStyle = BorderStyle.None;
        control.BorderAppearance.SkinStyle = ChartBorderSkinStyle.None;
        //control.Legend.Alignment = ChartAlignment.Far;
    }

Here is my chart image:

Upvotes: 0

Views: 520

Answers (1)

Saravana Kumar
Saravana Kumar

Reputation: 11

Thanks for using syncfusion products.

We have analyzed your query. If you want to customize the grid lines in axis, then you can use the “DashStyle” property in GridLineType which property is used to change the line style. And you can also specify the grid line style as Dash, DashDot, DashDotDot, Dot, Solid in axis.

And please find the below code snippet

this.ChartWebControl1.PrimaryYAxis.GridLineType.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDot;

And we have also prepared a sample for your reference in ASP.NET classic platform and attached in the below location.

Sample Link : http://www.syncfusion.com/downloads/support/directtrac/160606/ze/Sample1273790903

Please find the output of the sample below:
Please find the output of the sample below

And also we wish to let you know that the above mentioned property is also applicable for chart control in windows forms, ASP.NET classic and ASP.NET MVC classic platforms.

Please contact us via syncfusion support, if you have any queries related to using syncfusion products.

Upvotes: 1

Related Questions