1

I have drawn a chart though devexpress winforms control. DateTime is in X axis and Y axis has few values. The data I provide does not contain axis data at regular intervals. For example it will have a data for today, 3 days after today , 1 year after today and so on - they are not equally placed. I want to highlight the data points for which data has been provided. I have made grid lines visible using:

((XYDiagram)chartControl1.Diagram).AxisX.GridLines.MinorVisible = true;
((XYDiagramchartControl1.Diagram).AxisY.GridLines.Visible = true;
((XYDiagram)chartControl1.Diagram).AxisY.GridLines.MinorVisible = true;

But this draws grid lines at equal intervals and spacings. How can I specifically highlight the data points I have given...

2
  • Please clarify, are you trying to highlight the grid lines or the data points?
    – E.T.
    Commented Aug 5, 2013 at 12:59
  • Gridlines for the data point I have given. For example if I have provided today's data with a value 50 there should be a gridline drawn from that point to both axes. The point where the two gridlines meet the X and Y axis should be marked in the axes( just as any other grid line). Commented Aug 7, 2013 at 7:37

1 Answer 1

3

I hope I understand you correctly :)

You can use the Constant Lines!

    private void Form1_Load(object sender, EventArgs e)
    {
        Series series1 = new Series("Series 1", ViewType.Point);
        series1.Points.Add(new SeriesPoint(1, 50));
        series1.Points.Add(new SeriesPoint(2, 150));
        series1.Points.Add(new SeriesPoint(4, 20));
        series1.Points.Add(new SeriesPoint(7, 210));
        series1.Points.Add(new SeriesPoint(12, 70));
        chartControl1.Series.Add(series1);

        XYDiagram diagram = chartControl1.Diagram as XYDiagram;
        foreach (SeriesPoint item in series1.Points)
        {
            DrawConstantLines(diagram, int.Parse(item.Argument), diagram.AxisX);
            DrawConstantLines(diagram, (int)item.Values[0], diagram.AxisY);
        }
    }

    private void DrawConstantLines(XYDiagram diagram, int value, Axis axis)
    {
        ConstantLine constantLine1 = new ConstantLine();
        axis.ConstantLines.Add(constantLine1);
        constantLine1.AxisValue = value;
    }
4
  • This does not show up like grid lines. the point where the constant line meets X axis and Y axis are not displayed as with the grid lines. Is there a way to add them too? Commented Aug 7, 2013 at 11:41
  • Those points are not displayed for each grid line. How about just using labels instead?
    – E.T.
    Commented Aug 7, 2013 at 12:35
  • series1.LabelsVisibility = DevExpress.Utils.DefaultBoolean.True; series1.Label.PointOptions.PointView = PointView.ArgumentAndValues;
    – E.T.
    Commented Aug 7, 2013 at 12:37
  • @user2645830 You can also add a caption to the line :)
    – E.T.
    Commented Aug 7, 2013 at 13:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.