Question

I am using a tee chart library in xamarin (Android). i am facing a problem to daynamic binding data in "Candle Chart"

The Sample Code Like this!

protected override void OnCreate(Bundle bundle)
{
    base.OnCreate(bundle);
    RequestWindowFeature(WindowFeatures.NoTitle);
    SetContentView(Resource.Layout.CandleChart);

    //InitializeComponent();

    chart = new Steema.TeeChart.TChart(this.ApplicationContext);
    chart.Zoom.Style = Steema.TeeChart.ZoomStyles.InChart;
    Steema.TeeChart.Themes.BlackIsBackTheme myTheme = new Steema.TeeChart.Themes.BlackIsBackTheme(chart.Chart);
    myTheme.Apply();
    Type tmp = (Type)Steema.TeeChart.Utils.SeriesTypesOf[12];
    Steema.TeeChart.Styles.Series series;
    series = chart.Series.Add(tmp);

    series.FillSampleValues();  /* Here i want to fill series with my data listed bellow */

    chart.Aspect.View3D = Needs3D(chart[0]);
    chart.Panel.Transparent = true;

    SetContentView(chart);
}

now i want add series data manually

like :

currentItem.Data.Close

currentItem.Data.Open

currentItem.Data.High

currentItem.Data.Low

currentItem.Time

etc.. so, plz help me to achieve this ..

thanks, in advance

==================================================================================

My Code Like as Bellow

    private void LoadChart(GraphOutput resGraph)
    {
        DataSet_Obj.Tables.Add("CandleTable");
        DataSet_Obj.Tables["CandleTable"].Columns.Add(new DataColumn("Date", System.Type.GetType("System.DateTime")));
        DataSet_Obj.Tables["CandleTable"].Columns.Add(new DataColumn("Open", System.Type.GetType("System.Double")));
        DataSet_Obj.Tables["CandleTable"].Columns.Add(new DataColumn("Close", System.Type.GetType("System.Double")));
        DataSet_Obj.Tables["CandleTable"].Columns.Add(new DataColumn("High", System.Type.GetType("System.Double")));
        DataSet_Obj.Tables["CandleTable"].Columns.Add(new DataColumn("Low", System.Type.GetType("System.Double"))); 

        for (int i = 0; i < resGraph.graphSymbol[0].CandleSticks.Length; i++)
        {
            DataRow_Obj = DataSet_Obj.Tables["CandleTable"].NewRow();
            DataRow_Obj["Date"] = resGraph.graphSymbol[0].CandleSticks[i].CandleTime;        //DateTime 
            DataRow_Obj["Low"] = resGraph.graphSymbol[0].CandleSticks[i].CandleData.Low;     //Float
            DataRow_Obj["Close"] = resGraph.graphSymbol[0].CandleSticks[i].CandleData.Close; //Float
            DataRow_Obj["Open"] = resGraph.graphSymbol[0].CandleSticks[i].CandleData.Open;   //Float
            DataRow_Obj["High"] = resGraph.graphSymbol[0].CandleSticks[i].CandleData.High;   //Float
            DataSet_Obj.Tables["CandleTable"].Rows.Add(DataRow_Obj);
            DataRow_Obj = null;
        }

        Tag_Serie_Candle = new Steema.TeeChart.Styles.Candle ();
        chart.Series.Add(Tag_Serie_Candle);
        chart.Aspect.View3D = Needs3D(chart[0]);
        chart.Panel.Transparent = true;

        try
        {
            Tag_Serie_Candle.DataSource = DataSet_Obj.Tables["CandleTable"];   /* here I got Error Like: "Cannot bind to non-supported datasource: CandleTable" */
            Tag_Serie_Candle.OpenValues.DataMember = DataSet_Obj.Tables["CandleTable"].Columns["Open"].ToString();
            Tag_Serie_Candle.CloseValues.DataMember = DataSet_Obj.Tables["CandleTable"].Columns["Close"].ToString();
            Tag_Serie_Candle.DateValues.DataMember = DataSet_Obj.Tables["CandleTable"].Columns["Date"].ToString();
            Tag_Serie_Candle.DateValues.DateTime = true;
            Tag_Serie_Candle.HighValues.DataMember = DataSet_Obj.Tables["CandleTable"].Columns["High"].ToString();
            Tag_Serie_Candle.LowValues.DataMember = DataSet_Obj.Tables["CandleTable"].Columns["Low"].ToString();
            Tag_Serie_Candle.LabelMember = "Candle Chart";
            Tag_Serie_Candle.CheckDataSource();

            chartpie.AddView(chart, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent));
        }
        catch (Exception exe)
        {
            exe.Message.ToString();
        }
    }
Was it helpful?

Solution

You should do something as in the examples here:

http://www.teechart.net/support/viewtopic.php?f=4&t=2978&p=10547#p10547 http://www.teechart.net/support/viewtopic.php?f=4&t=3291&p=11691#p11691 http://www.teechart.net/support/viewtopic.php?f=4&t=2741&p=11681#p11681

I have found that, at the present moment, this is not working. I added the defect (ID566) list to be fixed as soon as possible (now fixed, see update at the bottom of the reply). If you register at Steema Software's Bugzilla system, you will be able to be in the CC List and be notified about status updates. In the meantime you can manually read values from the DataSet using this code:

Tag_Serie_Candle.DateValues.DateTime = true;

for (int i = 0; i < DataSet_Obj.Tables["CandleTable"].Rows.Count; i++)
{
  DataRow row = DataSet_Obj.Tables["CandleTable"].Rows[i];

  DateTime dt = Convert.ToDateTime(row["Date"]);
  Double open = Convert.ToDouble(row["Open"]);
  Double high = Convert.ToDouble(row["High"]);
  Double low = Convert.ToDouble(row["Low"]);
  Double close = Convert.ToDouble(row["Close"]);

  Tag_Serie_Candle.Add(dt, open, high, low, close);
}

UPDATE: As of 11th February 2014, the defect has been fixed. Anyone interested in testing the solution please let me know.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top