I am wondering how can I remove the 3 horizontal red lines on the stock graph as shown in image bellow. Please ignore the dots/squares on the image they are irrelevant. I think I have searched every google page there is and went through every option asp.net has... and could not figure out it. Any help is greatly appreciated!

enter image description here

Code that generated this graph:

Double[] test = new Double[] { 10, 50 };

    Chart1.Series[0].ChartType = SeriesChartType.Stock;
    Chart1.Series[0].YAxisType = AxisType.Primary;
    Chart1.Series[0].Color = Color.Red;
    Chart1.Series[0].BorderWidth = 10;
    Chart1.ChartAreas[0].AxisY.MajorGrid.Enabled = false;
    Chart1.ChartAreas[0].AxisX.MajorGrid.Enabled = false;
    Chart1.Series[0]["PixelPointWidth"] = "5";

    Chart1.Series.Add(new Series("Test Series"));
    Chart1.Series[1].ChartType = SeriesChartType.Point;
    Chart1.Series[1].YAxisType = AxisType.Primary;
    Chart1.Series[1].Color = Color.Black;
    Chart1.Series[1].BorderWidth = 3;
    Chart1.Series[1].MarkerSize = 15;

    Chart1.Series.Add(new Series("New Series"));
    Chart1.Series[2].ChartType = SeriesChartType.Point;
    Chart1.Series[2].YAxisType = AxisType.Primary;
    Chart1.Series[2].Color = Color.Orange;
    Chart1.Series[2].BorderWidth = 3;
    Chart1.Series[2].MarkerSize = 15;

    Chart1.Series[0].Points.Add(new Double[] {-10, 50});
    Chart1.Series[1].Points.Add(25);
    Chart1.Series[2].Points.Add(20);

    for (int i = 0; i < 2; i++)
    {
        Chart1.Series[0].Points.Add(test);
        Chart1.Series[1].Points.Add(25);
        Chart1.Series[2].Points.Add(20);
    }
有帮助吗?

解决方案

Okay, after looking into it obsessively, I think that I have a solution. Just adding the two Y values, the chart has a default value of zero for a marker (high or low?). By specifying that you will add the four values (open, close, high, low - not certain about the high/low order), you can hide those lines by making them fall within your open/close range, and by setting the PixelPointWidth to equal or less then your BorderWidth.

// IMPORTANT: add the ", 4" to indicate that you have the four Y values
Chart1.Series.Add(new Series("Stock", 4)); 
Chart1.Series["Stock"].ChartType = SeriesChartType.Stock;
Chart1.Series["Stock"].YAxisType = AxisType.Primary;
Chart1.Series["Stock"].Color = Color.Red;
Chart1.Series["Stock"].BorderWidth = 10;
Chart1.ChartAreas[0].AxisY.MajorGrid.Enabled = false;
Chart1.ChartAreas[0].AxisX.MajorGrid.Enabled = false;

// Set <= BorderWidth, so that it's effectively hidden
Chart1.Series["Stock"]["PixelPointWidth"] = "10"; 
Chart1.Series["Stock"].Points.AddY(10, 50, 20, 30); // open, close, high, low.

That was a little hard to track down. Whew.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top