完善数据操作接口

This commit is contained in:
monitor1394
2019-05-15 09:44:18 +08:00
parent 0b716adb5a
commit e72cfbdd3f
18 changed files with 1916 additions and 15087 deletions

View File

@@ -0,0 +1,34 @@
using UnityEngine;
using XCharts;
public class Demo_PieChart : MonoBehaviour
{
private PieChart chart;
private float time;
private int count = 0;
private void Awake()
{
chart = transform.GetComponent<PieChart>();
chart.ClearData();
}
private void Update()
{
time += Time.deltaTime;
if(time > 1 )
{
time = 0;
if(count < 5)
{
chart.AddData("time" + count, Random.Range(10, 100));
}
else
{
int index = count % 5;
chart.UpdateData("time" + index, Random.Range(10, 100));
}
count++;
}
}
}

View File

@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 1f0aafe148c9e4f4dbf24fc6542722fa
timeCreated: 1557832345
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@@ -1,9 +0,0 @@
fileFormatVersion: 2
guid: a5b436c986812794a9b741314e4a43bd
timeCreated: 1536101749
licenseType: Free
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@@ -781,7 +781,7 @@ RectTransform:
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 42068935}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalPosition: {x: 0, y: 38, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 2067368214}
@@ -1600,7 +1600,7 @@ RectTransform:
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 114085247}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 4, y: -304, z: 0}
m_LocalPosition: {x: -560, y: -1470, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 2037574390}
@@ -2897,6 +2897,80 @@ CanvasRenderer:
type: 2}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 152972887}
--- !u!1 &153116425
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 153116426}
- component: {fileID: 153116428}
- component: {fileID: 153116427}
m_Layer: 0
m_Name: Text
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &153116426
RectTransform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 153116425}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -30, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 586492772}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &153116427
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 153116425}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 708705254, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.93333334, g: 0.93333334, b: 0.93333334, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_FontSize: 16
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 10
m_MaxSize: 40
m_Alignment: 4
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 1
m_VerticalOverflow: 1
m_LineSpacing: 1
m_Text: Legend
--- !u!222 &153116428
CanvasRenderer:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 153116425}
--- !u!1 &154549692
GameObject:
m_ObjectHideFlags: 0
@@ -3071,7 +3145,7 @@ RectTransform:
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 162607949}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 592, y: -304, z: 0}
m_LocalPosition: {x: 4, y: -604, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 426057102}
@@ -9749,7 +9823,7 @@ RectTransform:
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 437239167}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 574, y: 298, z: 0}
m_LocalPosition: {x: 390, y: 298, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 2127319985}
@@ -13153,7 +13227,7 @@ RectTransform:
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 566296163}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 579, y: 150, z: 0}
m_LocalPosition: {x: 1168, y: 169, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1339466387}
@@ -13696,6 +13770,117 @@ CanvasRenderer:
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 582096240}
--- !u!1 &586492771
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 586492772}
- component: {fileID: 586492775}
- component: {fileID: 586492774}
- component: {fileID: 586492773}
m_Layer: 0
m_Name: legend_0
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!224 &586492772
RectTransform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 586492771}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 153116426}
m_Father: {fileID: 874169692}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 1, y: 0.5}
m_AnchorMax: {x: 1, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 60, y: 20}
m_Pivot: {x: 1, y: 0.5}
--- !u!114 &586492773
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 586492771}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 1392445389, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Navigation:
m_Mode: 3
m_SelectOnUp: {fileID: 0}
m_SelectOnDown: {fileID: 0}
m_SelectOnLeft: {fileID: 0}
m_SelectOnRight: {fileID: 0}
m_Transition: 1
m_Colors:
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
m_ColorMultiplier: 1
m_FadeDuration: 0.1
m_SpriteState:
m_HighlightedSprite: {fileID: 0}
m_PressedSprite: {fileID: 0}
m_DisabledSprite: {fileID: 0}
m_AnimationTriggers:
m_NormalTrigger: Normal
m_HighlightedTrigger: Highlighted
m_PressedTrigger: Pressed
m_DisabledTrigger: Disabled
m_Interactable: 1
m_TargetGraphic: {fileID: 586492774}
m_OnClick:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.Button+ButtonClickedEvent, UnityEngine.UI, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null
--- !u!114 &586492774
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 586492771}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.7607843, g: 0.20784314, b: 0.19215687, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Sprite: {fileID: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
--- !u!222 &586492775
CanvasRenderer:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 586492771}
--- !u!1 &588936069
GameObject:
m_ObjectHideFlags: 0
@@ -14103,7 +14288,7 @@ RectTransform:
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 600539469}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 579, y: 150, z: 0}
m_LocalPosition: {x: 395, y: 150, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 385824610}
@@ -15641,6 +15826,80 @@ CanvasRenderer:
type: 2}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 650147471}
--- !u!1 &650548801
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 650548802}
- component: {fileID: 650548804}
- component: {fileID: 650548803}
m_Layer: 0
m_Name: title
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &650548802
RectTransform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 650548801}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 769859530}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 1}
m_AnchorMax: {x: 0.5, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 389, y: 16}
m_Pivot: {x: 0.5, y: 1}
--- !u!114 &650548803
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 650548801}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 708705254, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.31764707, g: 0.3019608, b: 0.3019608, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_FontSize: 16
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 10
m_MaxSize: 40
m_Alignment: 1
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 1
m_VerticalOverflow: 1
m_LineSpacing: 1
m_Text: "\u7528\u4EE3\u7801\u6DFB\u52A0\u548C\u66F4\u65B0\u6570\u636E"
--- !u!222 &650548804
CanvasRenderer:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 650548801}
--- !u!1 &662856233
GameObject:
m_ObjectHideFlags: 0
@@ -15703,6 +15962,80 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &665205749
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 665205750}
- component: {fileID: 665205752}
- component: {fileID: 665205751}
m_Layer: 0
m_Name: Text
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &665205750
RectTransform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 665205749}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 3, y: -3, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 1180428717}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 3, y: -3}
m_SizeDelta: {x: 100, y: 100}
m_Pivot: {x: 0, y: 1}
--- !u!114 &665205751
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 665205749}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 708705254, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_FontSize: 14
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 10
m_MaxSize: 40
m_Alignment: 0
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 1
m_VerticalOverflow: 1
m_LineSpacing: 1
m_Text: Text
--- !u!222 &665205752
CanvasRenderer:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 665205749}
--- !u!1 &665712554
GameObject:
m_ObjectHideFlags: 0
@@ -17444,6 +17777,80 @@ RectTransform:
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 584, y: 300}
m_Pivot: {x: 0, y: 0}
--- !u!1 &756370685
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 756370686}
- component: {fileID: 756370688}
- component: {fileID: 756370687}
m_Layer: 0
m_Name: title_sub
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!224 &756370686
RectTransform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 756370685}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -0, y: -30, z: -0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 769859530}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 1}
m_AnchorMax: {x: 0.5, y: 1}
m_AnchoredPosition: {x: 0, y: -30}
m_SizeDelta: {x: 389, y: 14}
m_Pivot: {x: 0.5, y: 1}
--- !u!114 &756370687
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 756370685}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 708705254, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.31764707, g: 0.3019608, b: 0.3019608, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_FontSize: 14
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 10
m_MaxSize: 40
m_Alignment: 1
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 1
m_VerticalOverflow: 1
m_LineSpacing: 1
m_Text:
--- !u!222 &756370688
CanvasRenderer:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 756370685}
--- !u!1 &765152441
GameObject:
m_ObjectHideFlags: 0
@@ -17564,6 +17971,41 @@ RectTransform:
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 584, y: 300}
m_Pivot: {x: 0, y: 0}
--- !u!1 &769859529
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 769859530}
m_Layer: 0
m_Name: title
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &769859530
RectTransform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 769859529}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 194.5, y: 295, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 650548802}
- {fileID: 756370686}
m_Father: {fileID: 1337014068}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 1}
m_AnchorMax: {x: 0.5, y: 1}
m_AnchoredPosition: {x: 0, y: -5}
m_SizeDelta: {x: 389, y: 300}
m_Pivot: {x: 0.5, y: 1}
--- !u!1 &770291046
GameObject:
m_ObjectHideFlags: 0
@@ -19297,6 +19739,7 @@ RectTransform:
- {fileID: 748093151}
- {fileID: 782140057}
- {fileID: 810882606}
- {fileID: 1337014068}
m_Father: {fileID: 1716672565}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@@ -20406,6 +20849,40 @@ CanvasRenderer:
type: 2}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 863314396}
--- !u!1 &874169691
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 874169692}
m_Layer: 0
m_Name: legend
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &874169692
RectTransform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 874169691}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 384, y: 150, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 586492772}
m_Father: {fileID: 1337014068}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 1, y: 0.5}
m_AnchorMax: {x: 1, y: 0.5}
m_AnchoredPosition: {x: -5, y: 0}
m_SizeDelta: {x: 389, y: 300}
m_Pivot: {x: 1, y: 0.5}
--- !u!1 &878275676
GameObject:
m_ObjectHideFlags: 0
@@ -21801,7 +22278,7 @@ RectTransform:
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 934625862}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 579, y: 150, z: 0}
m_LocalPosition: {x: 395, y: 150, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1820612720}
@@ -21987,7 +22464,7 @@ RectTransform:
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 944142130}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 4, y: -608, z: 0}
m_LocalPosition: {x: 592, y: -304, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1058577084}
@@ -24013,7 +24490,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!224 &1019907807
RectTransform:
m_ObjectHideFlags: 0
@@ -27910,7 +28387,7 @@ RectTransform:
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1180067072}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 292, y: 295, z: 0}
m_LocalPosition: {x: 586.5, y: 333, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1013879342}
@@ -27923,6 +28400,75 @@ RectTransform:
m_AnchoredPosition: {x: 0, y: -5}
m_SizeDelta: {x: 584, y: 300}
m_Pivot: {x: 0.5, y: 1}
--- !u!1 &1180428716
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 1180428717}
- component: {fileID: 1180428719}
- component: {fileID: 1180428718}
m_Layer: 0
m_Name: tooltip
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!224 &1180428717
RectTransform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1180428716}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 665205750}
m_Father: {fileID: 1337014068}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 0, y: -300}
m_SizeDelta: {x: 100, y: 100}
m_Pivot: {x: 0, y: 1}
--- !u!114 &1180428718
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1180428716}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.31764707, g: 0.31764707, b: 0.31764707, a: 0.70980394}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Sprite: {fileID: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
--- !u!222 &1180428719
CanvasRenderer:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1180428716}
--- !u!1 &1182467921
GameObject:
m_ObjectHideFlags: 0
@@ -30743,6 +31289,194 @@ CanvasRenderer:
type: 2}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1331896564}
--- !u!1 &1337014067
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 1497106661024146, guid: 3aced18ddab0f41408ea7b63aeaf8ea4,
type: 2}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 1337014068}
- component: {fileID: 1337014070}
- component: {fileID: 1337014069}
- component: {fileID: 1337014071}
m_Layer: 5
m_Name: piechart_code
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1337014068
RectTransform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 224338819150487340, guid: 3aced18ddab0f41408ea7b63aeaf8ea4,
type: 2}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1337014067}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 2, y: -606, z: 0}
m_LocalScale: {x: 0.99999815, y: 0.99999815, z: 0.99999815}
m_Children:
- {fileID: 769859530}
- {fileID: 874169692}
- {fileID: 1180428717}
m_Father: {fileID: 819552456}
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 2, y: -206.00003}
m_SizeDelta: {x: 389, y: 300}
m_Pivot: {x: 0, y: 0}
--- !u!114 &1337014069
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1337014067}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d44276ba809fd92408b296835f6f7658, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Theme: 1
m_ThemeInfo:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_BackgroundColor:
serializedVersion: 2
rgba: 4294967295
m_ContrastColor:
serializedVersion: 2
rgba: 4283256145
m_TextColor:
serializedVersion: 2
rgba: 4283256145
m_SubTextColor:
serializedVersion: 2
rgba: 4283256145
m_LegendTextColor:
serializedVersion: 2
rgba: 4293848814
m_UnableColor:
serializedVersion: 2
rgba: 4291611852
m_AxisLineColor:
serializedVersion: 2
rgba: 4283256145
m_AxisSplitLineColor:
serializedVersion: 2
rgba: 542200145
m_TooltipBackgroundColor:
serializedVersion: 2
rgba: 3042005329
m_TooltipFlagAreaColor:
serializedVersion: 2
rgba: 542200145
m_TooltipTextColor:
serializedVersion: 2
rgba: 4294967295
m_ColorPalette:
- serializedVersion: 2
rgba: 4281415106
- serializedVersion: 2
rgba: 4283712815
- serializedVersion: 2
rgba: 4289241185
- serializedVersion: 2
rgba: 4284842708
- serializedVersion: 2
rgba: 4289644433
- serializedVersion: 2
rgba: 4286816116
- serializedVersion: 2
rgba: 4280452810
- serializedVersion: 2
rgba: 4288324285
- serializedVersion: 2
rgba: 4285821038
- serializedVersion: 2
rgba: 4285556052
- serializedVersion: 2
rgba: 4292070596
m_Title:
m_Show: 1
m_Text: "\u7528\u4EE3\u7801\u6DFB\u52A0\u548C\u66F4\u65B0\u6570\u636E"
m_TextFontSize: 16
m_SubText:
m_SubTextFontSize: 14
m_ItemGap: 14
m_Location:
m_Align: 2
m_Left: 0
m_Right: 0
m_Top: 5
m_Bottom: 0
m_Legend:
m_JsonData:
m_DataFromJson: 0
m_Show: 0
m_Orient: 0
m_Location:
m_Align: 8
m_Left: 0
m_Right: 5
m_Top: 0
m_Bottom: 0
m_ItemWidth: 60
m_ItemHeight: 20
m_ItemGap: 5
m_ItemFontSize: 16
m_Data:
- Legend
m_Tooltip:
m_Show: 1
m_Series:
m_JsonData:
m_DataFromJson: 0
m_Series: []
m_Large: 0
m_MinShowDataNumber: 0
m_MaxShowDataNumber: 0
m_MaxCacheDataNumber: 0
m_Pie:
m_Name: Pie
m_InsideRadius: 0
m_OutsideRadius: 80
m_TooltipExtraRadius: 10
m_Rose: 0
m_Space: 0
m_Left: 0
m_Right: 0
m_Top: 0
m_Bottom: 0
--- !u!222 &1337014070
CanvasRenderer:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 222203017129847298, guid: 3aced18ddab0f41408ea7b63aeaf8ea4,
type: 2}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1337014067}
--- !u!114 &1337014071
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1337014067}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1f0aafe148c9e4f4dbf24fc6542722fa, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &1339466386
GameObject:
m_ObjectHideFlags: 0
@@ -33225,7 +33959,7 @@ RectTransform:
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1435269578}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 4, y: -912, z: 0}
m_LocalPosition: {x: 30.000015, y: -1170, z: 0}
m_LocalScale: {x: 1.0000014, y: 1.0000014, z: 1.0000014}
m_Children:
- {fileID: 848289442}
@@ -34721,7 +35455,7 @@ RectTransform:
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1509090065}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 292, y: 295, z: 0}
m_LocalPosition: {x: 200, y: 295, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 860469215}
@@ -34986,7 +35720,7 @@ RectTransform:
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1540822016}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 592, y: -1216, z: 0}
m_LocalPosition: {x: 4, y: -1220, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1262762834}
@@ -36431,7 +37165,7 @@ RectTransform:
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1617189392}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalPosition: {x: 0, y: 38, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1205268351}
@@ -36474,7 +37208,7 @@ RectTransform:
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1623435343}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 4, y: -1216, z: 0}
m_LocalPosition: {x: 2, y: -1540, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1180067073}
@@ -37854,7 +38588,7 @@ RectTransform:
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1689000187}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 292, y: 295, z: 0}
m_LocalPosition: {x: 200, y: 295, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 707095281}
@@ -42375,7 +43109,7 @@ RectTransform:
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1898524185}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 592, y: -912, z: 0}
m_LocalPosition: {x: -142.92, y: -1470, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1509090066}
@@ -42910,7 +43644,7 @@ RectTransform:
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1905995011}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 579, y: 150, z: 0}
m_LocalPosition: {x: 395, y: 150, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 260881334}
@@ -45305,7 +46039,7 @@ RectTransform:
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 2037574389}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 292, y: 295, z: 0}
m_LocalPosition: {x: 200, y: 295, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 383353713}
@@ -45386,7 +46120,7 @@ RectTransform:
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 2039923034}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 592, y: -608, z: 0}
m_LocalPosition: {x: 276.39, y: -1470, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1689000188}
@@ -46795,7 +47529,7 @@ RectTransform:
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 2113761314}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: -38, z: 0}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1108712871}

View File

@@ -24,6 +24,8 @@ namespace XCharts
[SerializeField] private Bar m_Bar = new Bar();
public Bar bar { get { return m_Bar; } }
protected override void Awake()
{
base.Awake();
@@ -52,7 +54,7 @@ namespace XCharts
for (int n = 0; n < serieList.Count; n++)
{
Serie serie = serieList[n];
if (!m_Legend.IsShowSeries(serie.name)) continue;
if (!m_Legend.IsActive(serie.name)) continue;
Color color = m_ThemeInfo.GetColor(serieCount);
int maxCount = maxShowDataNumber > 0 ?
(maxShowDataNumber > serie.data.Count ? serie.data.Count : maxShowDataNumber)
@@ -112,7 +114,7 @@ namespace XCharts
for (int n = 0; n < serieList.Count; n++)
{
Serie serie = serieList[n];
if (!m_Legend.IsShowSeries(serie.name)) continue;
if (!m_Legend.IsActive(serie.name)) continue;
Color color = m_ThemeInfo.GetColor(serieCount);
int maxCount = maxShowDataNumber > 0 ?
(maxShowDataNumber > serie.data.Count ? serie.data.Count : maxShowDataNumber)

View File

@@ -11,8 +11,8 @@ namespace XCharts
{
Value,
Category,
Time,
Log
//Time,
//Log
}
public enum SplitLineType

View File

@@ -2,6 +2,7 @@
using UnityEngine.UI;
using System.Collections.Generic;
using System;
using UnityEngine.EventSystems;
namespace XCharts
{
@@ -101,29 +102,65 @@ namespace XCharts
}
}
public void AddData(string legend, float value)
public void ClearData()
{
m_Series.ClearData();
m_Legend.ClearData();
}
public virtual void AddData(string legend, float value)
{
m_Legend.AddData(legend);
m_Series.AddData(legend, value, m_MaxCacheDataNumber);
RefreshChart();
}
public void AddData(int legend, float value)
public virtual void AddData(int legend, float value)
{
m_Series.AddData(legend, value, m_MaxCacheDataNumber);
}
public void UpdateData(string legend, float value, int dataIndex = 0)
public virtual void UpdateData(string legend, float value, int dataIndex = 0)
{
m_Series.UpdateData(legend, value, dataIndex);
RefreshChart();
}
public void UpdateData(int legendIndex, float value, int dataIndex = 0)
public virtual void UpdateData(int legendIndex, float value, int dataIndex = 0)
{
m_Series.UpdateData(legendIndex, value, dataIndex);
RefreshChart();
}
public virtual void SetActive(string legend,bool active)
{
m_Legend.SetActive(legend, active);
m_Series.SetActive(legend, active);
}
public virtual void SetActive(int index, bool active)
{
m_Legend.SetActive(index, active);
m_Series.SetActive(index, active);
}
public virtual bool IsActive(string name)
{
return m_Legend.IsActive(name) || m_Series.IsActive(name);
}
public virtual bool IsActive(int index)
{
return m_Legend.IsActive(index) || m_Series.IsActive(index);
}
public virtual void RemoveData(string legend)
{
m_Legend.RemoveData(legend);
m_Series.RemoveData(legend);
RefreshChart();
}
public void UpdateTheme(Theme theme)
{
this.m_Theme = theme;
@@ -189,14 +226,15 @@ namespace XCharts
m_Legend.SetButton(i, btn);
m_Legend.UpdateButtonColor(i, m_ThemeInfo.GetColor(i), m_ThemeInfo.unableColor);
btn.GetComponentInChildren<Text>().text = m_Legend.data[i];
btn.onClick.AddListener(delegate ()
ChartHelper.AddEventListener(btn.gameObject, EventTriggerType.PointerDown, (data) =>
{
int index = int.Parse(btn.name.Split('_')[1]);
m_Legend.SetShowData(index, !m_Legend.IsShowSeries(index));
m_Legend.UpdateButtonColor(index, m_ThemeInfo.GetColor(index), m_ThemeInfo.unableColor);
OnYMaxValueChanged();
OnLegendButtonClicked();
RefreshChart();
int count = (data as PointerEventData).clickCount;
int index = int.Parse(data.selectedObject.name.Split('_')[1]);
SetActive(index, !m_Legend.IsActive(index));
m_Legend.UpdateButtonColor(index, m_ThemeInfo.GetColor(index), m_ThemeInfo.unableColor);
OnYMaxValueChanged();
OnLegendButtonClicked();
RefreshChart();
});
}
}
@@ -260,7 +298,7 @@ namespace XCharts
private void CheckTooltip()
{
if (!m_Tooltip.show) return;
if (!m_Tooltip.show || !m_Tooltip.isInited) return;
m_Tooltip.dataIndex = 0;
Vector2 local;

View File

@@ -23,7 +23,7 @@ namespace XCharts
[SerializeField] private int m_ItemFontSize = 18;
[SerializeField] private List<string> m_Data = new List<string>();
[NonSerialized] private List<bool> m_DataShowList = new List<bool>();
[NonSerialized] private List<bool> m_DataActiveList = new List<bool>();
[NonSerialized] private List<Button> m_DataBtnList = new List<Button>();
public bool show { get { return m_Show; } set { m_Show = value; } }
@@ -109,33 +109,67 @@ namespace XCharts
return base.GetHashCode();
}
public bool IsShowSeries(string name)
public bool IsActive(string name)
{
if (string.IsNullOrEmpty(name)) return true;
for(int i = 0; i < data.Count; i++)
{
if (name.Equals(data[i])) return m_DataShowList[i];
if (data[i].Equals(name)) return m_DataActiveList[i];
}
return true;
return false;
}
public bool IsShowSeries(int seriesIndex)
public bool IsActive(int seriesIndex)
{
if (seriesIndex < 0 || seriesIndex > data.Count - 1) seriesIndex = 0;
if (seriesIndex >= data.Count) return false;
if (seriesIndex < 0 || seriesIndex > m_DataShowList.Count - 1)
{
if (seriesIndex >= data.Count) return true;
if (seriesIndex < 0 || seriesIndex > m_DataActiveList.Count - 1)
return true;
}
else
return m_DataActiveList[seriesIndex];
}
public void ClearData()
{
m_Data.Clear();
}
public bool ContainsData(string name)
{
return m_Data.Contains(name);
}
public void RemoveData(string name)
{
if (m_Data.Contains(name))
{
return m_DataShowList[seriesIndex];
m_Data.Remove(name);
}
}
public void SetShowData(int index, bool flag)
public void AddData(string name)
{
m_DataShowList[index] = flag;
if (!m_Data.Contains(name))
{
m_Data.Add(name);
}
}
public void SetActive(int index, bool flag)
{
m_DataActiveList[index] = flag;
}
public void SetActive(string name, bool flag)
{
for (int i = 0; i < data.Count; i++)
{
if (data[i].Equals(name))
{
m_DataActiveList[i] = flag;
break;
}
}
}
public void SetButton(int index, Button btn)
@@ -144,7 +178,7 @@ namespace XCharts
if (index < 0 || index > m_DataBtnList.Count - 1)
{
m_DataBtnList.Add(btn);
m_DataShowList.Add(true);
m_DataActiveList.Add(true);
}
else
{
@@ -156,7 +190,7 @@ namespace XCharts
public void UpdateButtonColor(int index,Color ableColor,Color unableColor)
{
if (IsShowSeries(index))
if (IsActive(index))
{
m_DataBtnList[index].GetComponent<Image>().color = ableColor;
}
@@ -166,18 +200,6 @@ namespace XCharts
}
}
public void SetShowData(string name, bool flag)
{
for (int i = 0; i < data.Count; i++)
{
if (data[i].Equals(name))
{
m_DataShowList[i] = flag;
break;
}
}
}
public void OnChanged()
{
m_Location.OnChanged();

View File

@@ -12,8 +12,8 @@ namespace XCharts
[System.Serializable]
public class Indicator: IEquatable<Indicator>
{
public string m_Name;
public float m_Max;
[SerializeField] private string m_Name;
[SerializeField] private float m_Max;
public string name { get { return m_Name; }set { m_Name = value; } }
public float max { get { return m_Max; }set { m_Max = value; } }

View File

@@ -24,7 +24,7 @@ namespace XCharts
public SerieType type { get { return m_Type; } set { m_Type = value; } }
public string name { get { return m_Name; } set { m_Name = value; } }
public string stack { get { return m_Stack; } set { m_Stack = value; } }
public List<float> data { get { return m_Data; } }
public List<float> data { get { return m_Data; }set { m_Data = value; } }
public float Max
{
@@ -81,7 +81,7 @@ namespace XCharts
m_Data.RemoveAt(index);
}
public void AddData(float value, int maxDataNumber)
public void AddData(float value, int maxDataNumber = 0)
{
if (maxDataNumber > 0)
{

View File

@@ -46,47 +46,121 @@ namespace XCharts
}
}
public void AddData(string legend, float value, int maxDataNumber = 0)
public Serie GetSerie(string name)
{
for (int i = 0; i < m_Series.Count; i++)
{
if (m_Series[i].name.Equals(legend))
if (name.Equals(m_Series[i].name))
{
m_Series[i].AddData(value, maxDataNumber);
break;
return m_Series[i];
}
}
return null;
}
public void AddData(int legend, float value, int maxDataNumber = 0)
public Serie GetSerie(int index)
{
if (legend >= 0 && legend < Count)
if (index >= 0 && index < m_Series.Count)
{
m_Series[legend].AddData(value, maxDataNumber);
return m_Series[index];
}
return null;
}
public void UpdateData(string legend, float value, int dataIndex = 0)
public bool Contains(string name)
{
for (int i = 0; i < m_Series.Count; i++)
{
if (m_Series[i].name.Equals(legend))
if (name.Equals(m_Series[i].name))
{
m_Series[i].UpdateData(dataIndex, value);
break;
return true;
}
}
return false;
}
public void RemoveData(string name)
{
var serie = GetSerie(name);
if (serie != null)
{
m_Series.Remove(serie);
}
}
public void UpdateData(int legendIndex, float value, int dataIndex = 0)
public Serie AddData(string name, float value, int maxDataNumber = 0)
{
for (int i = 0; i < m_Series.Count; i++)
if (m_Series == null)
{
if (i == legendIndex)
{
m_Series[i].UpdateData(dataIndex, value);
break;
}
m_Series = new List<Serie>();
}
var serie = GetSerie(name);
if (serie == null)
{
serie = new Serie();
serie.name = name;
serie.data = new List<float>();
m_Series.Add(serie);
}
serie.AddData(value, maxDataNumber);
return serie;
}
public Serie AddData(int index, float value, int maxDataNumber = 0)
{
var serie = GetSerie(index);
if (serie != null)
{
serie.AddData(value, maxDataNumber);
}
return serie;
}
public void UpdateData(string name, float value, int dataIndex = 0)
{
var serie = GetSerie(name);
if (serie != null)
{
serie.UpdateData(dataIndex, value);
}
}
public void UpdateData(int index, float value, int dataIndex = 0)
{
var serie = GetSerie(index);
if (serie != null)
{
serie.UpdateData(dataIndex, value);
}
}
public bool IsActive(string name)
{
var serie = GetSerie(name);
return serie == null ? false : serie.show;
}
public bool IsActive(int index)
{
var serie = GetSerie(index);
return serie == null ? false : serie.show;
}
public void SetActive(string name, bool active)
{
var serie = GetSerie(name);
if (serie != null)
{
serie.show = active;
}
}
public void SetActive(int index, bool active)
{
var serie = GetSerie(index);
if (serie != null)
{
serie.show = active;
}
}
@@ -125,7 +199,7 @@ namespace XCharts
{
for (int i = 0; i < m_Series.Count; i++)
{
if (legend.IsShowSeries(i))
if (legend.IsActive(i))
{
if (m_Series[i].Max > max) max = m_Series[i].Max;
if (m_Series[i].Min < min) min = m_Series[i].Min;

View File

@@ -18,6 +18,7 @@ namespace XCharts
public int lastDataIndex { get; set; }
public float width { get { return m_BackgroudRect.sizeDelta.x; } }
public float height { get { return m_BackgroudRect.sizeDelta.y; } }
public bool isInited { get { return m_GameObject != null; } }
public static Tooltip defaultTooltip
{
@@ -45,13 +46,19 @@ namespace XCharts
public void SetTextColor(Color color)
{
m_Text.color = color;
if (m_Text)
{
m_Text.color = color;
}
}
public void UpdateTooltipText(string txt)
{
m_Text.text = txt;
m_BackgroudRect.sizeDelta = new Vector2(m_Text.preferredWidth + 8, m_Text.preferredHeight + 8);
if (m_Text)
{
m_Text.text = txt;
m_BackgroudRect.sizeDelta = new Vector2(m_Text.preferredWidth + 8, m_Text.preferredHeight + 8);
}
}
public void SetActive(bool flag)
@@ -68,7 +75,10 @@ namespace XCharts
public Vector3 GetPos()
{
return m_GameObject.transform.localPosition;
if (m_GameObject)
return m_GameObject.transform.localPosition;
else
return Vector3.zero;
}
}
}

View File

@@ -7,6 +7,8 @@ namespace XCharts
{
[SerializeField] private Line m_Line = Line.defaultLine;
public Line line { get { return line; } }
protected override void Awake()
{
base.Awake();
@@ -43,7 +45,7 @@ namespace XCharts
float scaleWid = m_XAxis.GetDataWidth(coordinateWid);
for (int j = 0; j < seriesCount; j++)
{
if (!m_Legend.IsShowSeries(j)) continue;
if (!IsActive(j)) continue;
Serie serie = m_Series.series[j];
Color32 color = m_ThemeInfo.GetColor(j);
Vector3 lp = Vector3.zero;
@@ -131,7 +133,7 @@ namespace XCharts
float scaleWid = m_YAxis.GetDataWidth(coordinateHig);
for (int j = 0; j < seriesCount; j++)
{
if (!m_Legend.IsShowSeries(j)) continue;
if (!IsActive(j)) continue;
Serie serie = m_Series.series[j];
Color32 color = m_ThemeInfo.GetColor(j);
Vector3 lp = Vector3.zero;

View File

@@ -15,6 +15,30 @@ namespace XCharts
private Vector2 m_PieCenter;
private List<float> m_AngleList = new List<float>();
public Pie pie { get { return m_Pie; } }
public override void AddData(string legend, float value)
{
m_Legend.AddData(legend);
var serie = m_Series.AddData(legend,value);
if (serie != null)
{
serie.ClearData();
serie.AddData(value);
RefreshChart();
}
}
public override void UpdateData(string legend, float value, int dataIndex = 0)
{
var serie = m_Series.GetSerie(legend);
if (serie != null)
{
serie.UpdateData(0, value);
RefreshChart();
}
}
protected override void Awake()
{
base.Awake();
@@ -36,7 +60,7 @@ namespace XCharts
m_AngleList.Clear();
for (int i = 0; i < m_Series.Count; i++)
{
if (!m_Legend.IsShowSeries(i))
if (!IsActive(i))
{
m_AngleList.Add(0);
continue;
@@ -70,7 +94,7 @@ namespace XCharts
float total = 0;
for (int i = 0; i < m_Series.Count; i++)
{
if (m_Legend.IsShowSeries(i))
if (IsActive(i))
{
total += m_Series.series[i].GetData(0);
}
@@ -83,7 +107,7 @@ namespace XCharts
float max = 0;
for (int i = 0; i < m_Series.Count; i++)
{
if (m_Legend.IsShowSeries(i) && m_Series.series[i].GetData(0) > max)
if (IsActive(i) && m_Series.series[i].GetData(0) > max)
{
max = m_Series.series[i].GetData(0);
}

View File

@@ -18,6 +18,7 @@ namespace XCharts
private List<Text> indicatorTextList = new List<Text>();
private List<List<Vector3>> dataPosList = new List<List<Vector3>>();
public Radar radar { get { return m_Radar; } }
protected override void Awake()
{
@@ -144,7 +145,7 @@ namespace XCharts
dataPosList.Capacity = m_Series.Count;
for (int i = 0; i < m_Series.Count; i++)
{
if (!m_Legend.IsShowSeries(i))
if (!IsActive(i))
{
dataPosList.Add(new List<Vector3>());
continue;
@@ -286,7 +287,7 @@ namespace XCharts
m_Tooltip.dataIndex = 0;
for (int i = 0; i < m_Series.Count; i++)
{
if (!m_Legend.IsShowSeries(i)) continue;
if (!IsActive(i)) continue;
for (int j = 0; j < dataPosList[i].Count; j++)
{
if (Vector3.Distance(local, dataPosList[i][j]) <= m_Radar.linePointSize * 1.2f)

View File

@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Text.RegularExpressions;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
namespace XCharts
@@ -42,6 +43,18 @@ namespace XCharts
}
}
public static string GetFullName(Transform transform)
{
string name = transform.name;
Transform obj = transform;
while (obj.transform.parent)
{
name += "/"+obj.transform.parent.name;
obj = obj.transform.parent;
}
return name;
}
public static T GetOrAddComponent<T>(Transform transform) where T : Component
{
return GetOrAddComponent<T>(transform.gameObject);
@@ -462,5 +475,17 @@ namespace XCharts
if (max < 0) return (int)-mm;
else return (int)mm;
}
public static void AddEventListener(GameObject obj, EventTriggerType type,
UnityEngine.Events.UnityAction<BaseEventData> call)
{
EventTrigger trigger = GetOrAddComponent<EventTrigger>(obj.gameObject);
EventTrigger.Entry entry1 = new EventTrigger.Entry();
entry1.eventID = type;
entry1.callback = new EventTrigger.TriggerEvent();
entry1.callback.AddListener(call);
trigger.triggers.Clear();
trigger.triggers.Add(entry1);
}
}
}