Bind HiLoOpenCloseSeries to collection

Jun 6, 2013 at 9:43 PM
Just as the subject states. I could not find much documentation on the HiLoOpenCloseSeries type of chart. How do you bind a collection to the series? What type of Axis should I use? I already have an observable collection with OpenHiLowClose data in it. It also has a symbol attribute in case I want to chart several symbols on their own series. Currently just trying one symbol.
Coordinator
Jun 7, 2013 at 5:35 AM
Hi,

Query 1: You can create a HiLoOpenCloseSeries with collection by using the below code

//Create a model
public class Model
{
    public double High { get; set; }
    public double Low { get; set; }
    public double Open { get; set; }
    public double Close { get; set; }

    public Model(double high,double low,double open,double close)
    {
        High = high;
        Low = low; 
        Open = open;
        Close = close;
    }      
}

// Create a ViewModel
public class ViewModel
{
    public ObservableCollection<Model> Collection { get; set; }
    public ViewModel()
    {
        Collection = new ObservableCollection<Model>();
        GenerateDatas();
    }
    private void GenerateDatas()
    {
        this.Collection.Add(new Model(10, 1,5,4));
        this.Collection.Add(new Model(10, 1,5,4));
        this.Collection.Add(new Model(10, 1,5,4));
        this.Collection.Add(new Model(10, 1,5,4));
    }
}

   //Use the viewmodel in the Sparrow Chart
   <sparrow:SparrowChart>
   <sparrow:SparrowChart.DataContext> 
          <local:ViewModel/>
   </sparrow:SparrowChart.DataContext>
        <sparrow:SparrowChart.XAxis>
                <sparrow:LinearXAxis/>
        </sparrow:SparrowChart.XAxis>
        <sparrow:SparrowChart.YAxis>
                <sparrow:LinearYAxis/>
        </sparrow:SparrowChart.YAxis>
       <sparrow:HiLoOpenCloseSeries PointsSource={Binding Collection} HighPath="High" LowPath="Low" OpenPath="Open" ClosePath="Close"/>
   </sparrow:SparrowChart>
Query 2: You could use Linear,Category and DateTimeAxis
Query 3: Now sparrow chart doesn't support symbol markers on it. I except this feature will be implemented within the release.

Please let me know if you need more information on this.

Thanks,
Vinoth Kumar J
Jun 7, 2013 at 5:16 PM
That is what I am doing but one thing since I have the Xaxis setup as an DateTimeAxis I have to set the XPath as well. My next question is that when I run the application it auto sizes the X and Y Axis to something that I dont' think is correct. It puts the highest point in the series as the YMaxValue but the YMinValue doesn't set correctly. The X Min and Max values do not set correctly either. On both axis data is showing off screen. Are there labels or markers as well for each of the OHLC Paths? How do you perform zoom and pan functions?
Jun 11, 2013 at 5:24 PM
Is there any more help you can provide to me regarding my last post?
Coordinator
Jun 11, 2013 at 5:28 PM
Hi,

Sorry for the delay in response.

You can set MinValue and MaxValue for axis as follows
              <sparrow:SparrowChart.XAxis>
                    <sparrow:LinearXAxis MinValue="0" MaxValue="6" Interval="1"/>
                </sparrow:SparrowChart.XAxis>
                <sparrow:SparrowChart.YAxis>
                    <sparrow:LinearYAxis MinValue="0" MaxValue="11" Interval="1"/>
                </sparrow:SparrowChart.YAxis>
Now you cannot perform Zoom and Pan interactions i have working on implementing this feature.

Thanks & Regards,
Vinoth Kumar J
Jun 12, 2013 at 7:39 PM
That is one way, but is there a way for the chart to better fit points within the confines of the chart dynamically? With the HiLoOpenCloseSeries the left most HLOC indicator draws the primary vertical line. However, the line drawing leftward off of the main trunk draws off screen. As a feature of the HLOC series, I would expect it to no draw lines off screen dynamically and not have to create an extra bindable property in my view model to ensure that points are not drawn off screen.

Again keep up the good work. This library looks to be very promising to fill a gaping hole in open source charting libraries available for WPF.
Coordinator
Jun 12, 2013 at 7:55 PM
Hi,

Thanks for supporting sparrow toolkit.

I have created a task for dynamic minimum and maximum calculation and please subscribe this workitem.
Automatic Range calculation based on the Series

Thanks,
Vinoth Kumar J
Jun 12, 2013 at 8:13 PM
That is very much appreciated. I think it will make a lot of users happy.

Cheers!