Hi,
is it possible to set the line style to dashed or dotted and set a backround color. See picture for example. There is line color black and background ist red.
Thanks
I don't believe System.Drawing allows lines to have background or highlights. It's basically an equivalent of Graphics.DrawLine(Pen pen). I'm not sure which of the workarounds I suggested previously would be better; that mainly depends on your application. But I can't think of any other potential workarounds. If you can afford to duplicate some of your data for the sake of displaying an overlayed line, then it's probably the better approach.
DataTable dt = new DataTable();dt.Columns.Add("line1", typeof(double));dt.Columns.Add("line2", typeof(double));
dt.Rows.Add(new object[] { 1, 5});dt.Rows.Add(new object[] { 5, 2});dt.Rows.Add(new object[] { 2, 7});dt.Rows.Add(new object[] { 7, 6});dt.Rows.Add(new object[] { 5, 7});
NumericSeries series1 = new NumericSeries();series1.Data.DataSource = dt;series1.Data.ValueColumn = "line1";series1.PEs.Add(new PaintElement(Color.Yellow));series1.DataBind();
NumericSeries series1overlay = new NumericSeries();series1overlay.Data.DataSource = dt;series1overlay.Data.ValueColumn = "line1";series1overlay.PEs.Add(new PaintElement(Color.Black));series1overlay.DataBind();
NumericSeries series2 = new NumericSeries();series2.Data.DataSource = dt;series2.Data.ValueColumn = "line2";series2.PEs.Add(new PaintElement(Color.LightBlue));series2.DataBind();
NumericSeries series2overlay = new NumericSeries();series2overlay.Data.DataSource = dt;series2overlay.Data.ValueColumn = "line2";series2overlay.PEs.Add(new PaintElement(Color.Black));series2overlay.DataBind();
ultraChart1.Series.Add(series1);ultraChart1.Series.Add(series1overlay);ultraChart1.Series.Add(series2);ultraChart1.Series.Add(series2overlay);
LineAppearance app1 = new LineAppearance();app1.Thickness = 3;
LineAppearance app1overlay = new LineAppearance();app1overlay.LineStyle = new LineStyle(LineCapStyle.NoAnchor, LineCapStyle.NoAnchor, LineDrawStyle.Dash);app1overlay.Thickness = 2;
ultraChart1.LineChart.LineAppearances.Add(app1);ultraChart1.LineChart.LineAppearances.Add(app1overlay);
Hallo Max,
thank you for reply. Is there a other way to highlight a line? I have two or more lines in my chart that have to be black for example and I want to draw them differently.
Do you have any other idea?
Sorry, this is currently not possible. The workaround would be to either draw 2 line series with identical data, but different styles, or handle chart's FillSceneGraph and add a custom Polyline primitive that overlays the existing linechart polyline.