0
votes

I've got a candlestick chart showing prices with two series representing price and volume. This all works fine and displays as follows.

Correctly Displayed

The point width for these candles is set using _stockSeries["PointWidth"] = "0.6";

I then add a new series to the same chart area indicating points on the chart and the candle width changes to become very thin. I then have to set the PointWidth to ~15000 to get the candles a reasonable width. This number seems to bear no relation to anything on the chart as far as I can tell and is a lot larger than the original 0.6. Can anyone explain what's going on here?

enter image description here

The code used for adding the points is

        var genericPoints = new Series(name);

        if (style != MarkerStyle.None)
            genericPoints.MarkerStyle = style;

        genericPoints.ChartType = SeriesChartType.FastPoint;
        foreach (var price in points)
            genericPoints.Points.AddXY(price.TimeStamp, price.Value);

        _chart.Series.Add(genericPoints);
1
Sounds very strange. PointWidth goes from 0f-2f, so your numbers make no sense. Did you test with other types than fastpoint? How many points do you have? - TaW
@TaW Yes, it seems to happen with all chart types. I've tried Point, Line and FastLine too. There are about 20 points I'm adding. If I add the series with no points then it has no effect on the candles. If I use PixelPointWidth, then the candles are not affected by adding another series. - Will Calderwood
Hm, I can't reproduce. Do reset the PointWidth to a sensible value, i.e. below 1. You may also want to try the PixelPointWidth cust.property instead, see here. Your x-values look, um a bit large. Sure they are correct? - TaW
@TaW PixelPointWidth works fine. (I mentioned that above). Do you know how I can get the width of the chart area? There's ChartArea.Position, but the width of that is zero, I assume because it's set to auto size. I'll try to create an SSCCE. The X values are ms epoch times - they are correct, just not elegant yet. It's a work in progress. :-) - Will Calderwood
You can get it by calling ToRectangleF on it or maybe by calling sth. like axisrescale before. In a hurry atm.. You may want the Innerplotposition. See here for several posts of mine on it.. - TaW

1 Answers

0
votes

Had a similar problem, addressed with

    Private Sub chart_PrePaint(sender As Object, e As ChartPaintEventArgs) Handles chart.PrePaint
    Dim areasize As Double
    areasize = chart.Width * 0.6
    chart.Series("Candles")("PixelPointWidth") = areasize / (chart.Series("Candles").Points.Count)

    End Sub

Hope this helps