2020년 8월 12일 수요일

[Unity] Graph 사용 예

 



using System.Collections;
using System.Collections.Generic;
using ChartAndGraph;
using UnityEngine;
using System;
using UnityEngine.UI;

public class GraphDraw : MonoBehaviour {


    public GraphChart No1_Grahp;
    
    public BarChart No2_Grahp;
    [Header("새로생긴 데이터 한번에 뿌려주기 위한용")]
    public BarChart No2_Graph_1;
    public BarChart No2_Graph_2;
    public BarChart No2_Graph_3;
    public BarChart No2_Graph_4;


    //public BarChart No3_Grahp;//그래프 3번이 사라지고 txt_GuidancePredict,txt_TGT로 대체
    public Text txt_GuidancePredict;
    public Text txt_TGT;

    public GraphChart PredictValue_Graph;
    public GraphChart PredictPrice_Graph;

    public GraphChart GuidanceValue_Graph;
    public GraphChart GuidancePrice_Graph;


    [Space]
    [Header("Category Porperty")]
    public Material linematerial;
    public MaterialTiling lineTiling;
    public Material pointmaterial;
    public ChartItemEffect lineHoverPrefab;
    public ChartItemEffect pointHoverPrefab;



    public void AddCategory_for_ManualGraph(GraphChart graphChartstring categoryNameMaterial linemat,float lineThickness = 2float pointsize = 3)
    {
        graphChart.DataSource.RemoveCategory(categoryName);
        graphChart.DataSource.AddCategory(categoryNamelinemat1lineTilingnullfalsepointmaterial0);
        graphChart.DataSource.Set2DCategoryPrefabs(categoryNamelineHoverPrefabpointHoverPrefab);
    }


    public void AddCategory(GraphChart graphChartstring categoryName,float lineThickness =2,float pointsize =3)
    {
        graphChart.DataSource.RemoveCategory(categoryName);
        graphChart.DataSource.AddCategory(categoryNamelinemateriallineThicknesslineTilingnullfalsepointmaterialpointsize);
        graphChart.DataSource.Set2DCategoryPrefabs(categoryNamelineHoverPrefabpointHoverPrefab);
    }

    //Graph1 Point

    public IEnumerator addPoint(GraphChart graphChart,string categoryNameDateTime xfloat y)
    {
        graphChart.DataSource.StartBatch();
        //double xVal = ChartDateUtility.DateToValue_New(x); //기존 하루만 그릴때
        double xVal = ChartDateUtility.DateToValue(x); //오케이 완벽해!!

        //double xVal = x.Second;
        StartCoroutine(graphChart.DataSource.AddPointToCategory_Ver2_IEnumerator(categoryName, (float)xValy));
        graphChart.DataSource.EndBatch();
        yield return new WaitForEndOfFrame();
    }


    public IEnumerator addPoint(BarChart barChart,string categoryName,string groupName,double value)
    {

        //if (!barChart.DataSource.AutomaticMaxValue)
        //    barChart.DataSource.AutomaticMaxValue = true;
        
        
        barChart.DataSource.StartBatch();
        barChart.DataSource.SetValue(categoryNamegroupNamevalue);
        barChart.DataSource.EndBatch();


        yield return new WaitForEndOfFrame();
    }

    public void FCE_GraphClear()
    {
        No1_Grahp.DataSource.ClearCategory("SKID");
        No1_Grahp.DataSource.ClearCategory("NSKD");
        No1_Grahp.DataSource.ClearCategory("TGT");

        NewGraphClear(No2_Grahp);
        
        

        txt_GuidancePredict.text = "";
        txt_TGT.text = "";
        //No3_Grahp.DataSource.SetValue("SKID", "가이던스 예측 온도", 0);
        //No3_Grahp.DataSource.SetValue("NSKD", "가이던스 예측 온도", 0);
        //No3_Grahp.DataSource.SetValue("SKID", "현재 예측 온도", 0);
        //No3_Grahp.DataSource.SetValue("NSKD", "현재 예측 온도", 0);
    }

    public void FCE_Zone_GraphClear()
    {
        NewGraphClear(No2_Graph_1);
        NewGraphClear(No2_Graph_2);
        NewGraphClear(No2_Graph_3);
        NewGraphClear(No2_Graph_4);
    }

    public void NewGraphClear(BarChart newGraph)
    {
        newGraph.DataSource.SetValue("GSV""예열대T"0);
        newGraph.DataSource.SetValue("GSV""예열대B"0);
        newGraph.DataSource.SetValue("GSV""가열대T"0);
        newGraph.DataSource.SetValue("GSV""가열대B"0);
        newGraph.DataSource.SetValue("GSV""균열대T"0);
        newGraph.DataSource.SetValue("GSV""균열대B"0);

        newGraph.DataSource.SetValue("SV""예열대T"0);
        newGraph.DataSource.SetValue("SV""예열대B"0);
        newGraph.DataSource.SetValue("SV""가열대T"0);
        newGraph.DataSource.SetValue("SV""가열대B"0);
        newGraph.DataSource.SetValue("SV""균열대T"0);
        newGraph.DataSource.SetValue("SV""균열대B"0);

    }

    //Graph1 Point
}


댓글 없음:

댓글 쓰기

git rejected error(feat. cherry-pick)

 문제 아무 생각 없이 pull을 받지않고 로컬에서 작업! 커밋, 푸시 진행을 해버렷다. push에선 remote와 다르니 당연히 pull을 진행해라고 하지만 로컬에서 작업한 내용을 백업하지 않고 진행하기에는 부담스럽다(로컬작업 유실 가능성) 해결하려...