mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-14 20:00:09 +00:00
3.0 - tooltip
This commit is contained in:
@@ -139,6 +139,8 @@ namespace XCharts
|
||||
protected override void DrawExtendeds(SerializedProperty prop)
|
||||
{
|
||||
base.DrawExtendeds(prop);
|
||||
PropertyField(prop, "m_BorderWidth");
|
||||
PropertyField(prop, "m_BorderColor");
|
||||
PropertyField(prop, "m_LineType");
|
||||
PropertyField(prop, "m_LineWidth");
|
||||
PropertyField(prop, "m_LineColor");
|
||||
|
||||
@@ -34,7 +34,8 @@ namespace XCharts
|
||||
PropertyField(prop, "m_BorderColor0");
|
||||
PropertyField(prop, "m_BorderToColor");
|
||||
PropertyField(prop, "m_Opacity");
|
||||
PropertyField(prop, "m_TooltipFormatter");
|
||||
PropertyField(prop, "m_ItemMarker");
|
||||
PropertyField(prop, "m_ItemFormatter");
|
||||
PropertyField(prop, "m_NumericFormatter");
|
||||
PropertyListField(prop, "m_CornerRadius", true);
|
||||
--EditorGUI.indentLevel;
|
||||
|
||||
@@ -30,6 +30,7 @@ namespace XCharts
|
||||
#endif
|
||||
PropertyField(prop, "m_Rotate");
|
||||
PropertyField(prop, "m_Offset");
|
||||
PropertyField(prop, "m_ExtraWidth");
|
||||
PropertyField(prop, "m_Color");
|
||||
PropertyField(prop, "m_BackgroundColor");
|
||||
PropertyField(prop, "m_FontSize");
|
||||
|
||||
@@ -15,6 +15,8 @@ namespace XCharts
|
||||
{
|
||||
public class MainComponentBaseEditor
|
||||
{
|
||||
protected const string MORE = "More";
|
||||
protected bool m_MoreFoldout = false;
|
||||
internal BaseChart chart { get; private set; }
|
||||
internal MainComponent component { get; private set; }
|
||||
|
||||
@@ -84,6 +86,15 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
protected void PropertyFiledMore(System.Action action)
|
||||
{
|
||||
m_MoreFoldout = ChartEditorHelper.DrawHeader(MORE, m_MoreFoldout, false, null, null);
|
||||
if (m_MoreFoldout)
|
||||
{
|
||||
if (action != null) action();
|
||||
}
|
||||
}
|
||||
|
||||
protected void PropertyField(SerializedProperty property)
|
||||
{
|
||||
Assert.IsNotNull(property);
|
||||
|
||||
@@ -18,21 +18,36 @@ namespace XCharts
|
||||
++EditorGUI.indentLevel;
|
||||
PropertyField("m_Type");
|
||||
PropertyField("m_Trigger");
|
||||
PropertyField("m_Formatter");
|
||||
PropertyField("m_AlwayShow");
|
||||
PropertyField("m_TitleFormatter");
|
||||
PropertyField("m_ItemFormatter");
|
||||
PropertyField("m_NumericFormatter");
|
||||
PropertyField("m_FixedWidth");
|
||||
PropertyField("m_FixedHeight");
|
||||
PropertyField("m_MinWidth");
|
||||
PropertyField("m_MinHeight");
|
||||
PropertyField("m_PaddingLeftRight");
|
||||
PropertyField("m_PaddingTopBottom");
|
||||
PropertyField("m_BackgroundImage");
|
||||
PropertyField("m_IgnoreDataDefaultContent");
|
||||
PropertyField("m_Offset");
|
||||
PropertyField("m_TitleHeight");
|
||||
PropertyField("m_ItemHeight");
|
||||
PropertyFiledMore(() =>
|
||||
{
|
||||
PropertyField("m_Marker");
|
||||
PropertyField("m_BorderWidth");
|
||||
PropertyField("m_BorderColor");
|
||||
PropertyField("m_PaddingLeftRight");
|
||||
PropertyField("m_PaddingTopBottom");
|
||||
PropertyField("m_BackgroundImage");
|
||||
PropertyField("m_BackgroundColor");
|
||||
PropertyField("m_FixedWidth");
|
||||
PropertyField("m_FixedHeight");
|
||||
PropertyField("m_MinWidth");
|
||||
PropertyField("m_MinHeight");
|
||||
PropertyField("m_IgnoreDataDefaultContent");
|
||||
PropertyField("m_Offset");
|
||||
PropertyField("m_FixedXEnable");
|
||||
PropertyField("m_FixedX");
|
||||
PropertyField("m_FixedYEnable");
|
||||
PropertyField("m_FixedY");
|
||||
});
|
||||
PropertyField("m_LineStyle");
|
||||
PropertyField("m_TextStyle");
|
||||
PropertyField("m_LabelTextStyle");
|
||||
PropertyField("m_TitleTextStyle");
|
||||
PropertyListField("m_ColumnsTextStyle");
|
||||
--EditorGUI.indentLevel;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,9 +132,9 @@ MonoBehaviour:
|
||||
rgba: 4281415106
|
||||
m_Tooltip:
|
||||
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_TextColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_TextColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
m_TextBackgroundColor: {r: 0.31764707, g: 0.31764707, b: 0.31764707, a: 0.78431374}
|
||||
m_FontSize: 20
|
||||
m_FontSize: 22
|
||||
m_LineType: 0
|
||||
m_LineWidth: 0.8
|
||||
m_LineColor:
|
||||
|
||||
@@ -132,9 +132,9 @@ MonoBehaviour:
|
||||
rgba: 4281415106
|
||||
m_Tooltip:
|
||||
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_TextColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_TextBackgroundColor: {r: 0.31764707, g: 0.31764707, b: 0.31764707, a: 0.78431374}
|
||||
m_FontSize: 20
|
||||
m_TextColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
m_TextBackgroundColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_FontSize: 22
|
||||
m_LineType: 0
|
||||
m_LineWidth: 0.8
|
||||
m_LineColor:
|
||||
|
||||
@@ -1,207 +0,0 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 6c59330ca0f4443b69f06b890a44f32e, type: 3}
|
||||
m_Name: XCTheme-Test1
|
||||
m_EditorClassIdentifier:
|
||||
m_ThemeType: 3
|
||||
m_ThemeName: Test1
|
||||
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_ContrastColor:
|
||||
serializedVersion: 2
|
||||
rgba: 0
|
||||
m_BackgroundColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4292006610
|
||||
m_ColorPalette:
|
||||
- serializedVersion: 2
|
||||
rgba: 4294939209
|
||||
- serializedVersion: 2
|
||||
rgba: 4289920892
|
||||
- serializedVersion: 2
|
||||
rgba: 4284538365
|
||||
- serializedVersion: 2
|
||||
rgba: 4285951743
|
||||
- serializedVersion: 2
|
||||
rgba: 4294564184
|
||||
- serializedVersion: 2
|
||||
rgba: 4287741957
|
||||
- serializedVersion: 2
|
||||
rgba: 4282747647
|
||||
- serializedVersion: 2
|
||||
rgba: 4293085325
|
||||
- serializedVersion: 2
|
||||
rgba: 4294932957
|
||||
m_Common:
|
||||
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_TextColor: {r: 0.7254902, g: 0.72156864, b: 0.80784315, a: 1}
|
||||
m_TextBackgroundColor: {r: 0, g: 0, b: 0, a: 0}
|
||||
m_FontSize: 20
|
||||
m_Title:
|
||||
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_TextColor: {r: 0.93333334, g: 0.94509804, b: 0.98039216, a: 1}
|
||||
m_TextBackgroundColor: {r: 0, g: 0, b: 0, a: 0}
|
||||
m_FontSize: 24
|
||||
m_SubTitle:
|
||||
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_TextColor: {r: 0.7254902, g: 0.72156864, b: 0.80784315, a: 1}
|
||||
m_TextBackgroundColor: {r: 0, g: 0, b: 0, a: 0}
|
||||
m_FontSize: 22
|
||||
m_Legend:
|
||||
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_TextColor: {r: 0.7254902, g: 0.72156864, b: 0.80784315, a: 1}
|
||||
m_TextBackgroundColor: {r: 0, g: 0, b: 0, a: 0}
|
||||
m_FontSize: 20
|
||||
m_UnableColor: {r: 0.8, g: 0.8, b: 0.8, a: 1}
|
||||
m_Axis:
|
||||
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_TextColor: {r: 0.7254902, g: 0.72156864, b: 0.80784315, a: 1}
|
||||
m_TextBackgroundColor: {r: 0, g: 0, b: 0, a: 0}
|
||||
m_FontSize: 18
|
||||
m_LineType: 0
|
||||
m_LineWidth: 0.8
|
||||
m_LineLength: 0
|
||||
m_LineColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4291737785
|
||||
m_SplitLineType: 0
|
||||
m_SplitLineWidth: 0.8
|
||||
m_SplitLineLength: 0
|
||||
m_SplitLineColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4283647816
|
||||
m_TickWidth: 0.8
|
||||
m_TickLength: 5
|
||||
m_TickColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4291737785
|
||||
m_SplitAreaColors:
|
||||
- serializedVersion: 2
|
||||
rgba: 100663295
|
||||
- serializedVersion: 2
|
||||
rgba: 218103807
|
||||
m_Gauge:
|
||||
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_TextColor: {r: 0.7254902, g: 0.72156864, b: 0.80784315, a: 1}
|
||||
m_TextBackgroundColor: {r: 0, g: 0, b: 0, a: 0}
|
||||
m_FontSize: 18
|
||||
m_LineType: 0
|
||||
m_LineWidth: 15
|
||||
m_LineLength: 0
|
||||
m_LineColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4291737785
|
||||
m_SplitLineType: 0
|
||||
m_SplitLineWidth: 0.8
|
||||
m_SplitLineLength: 15
|
||||
m_SplitLineColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4294967295
|
||||
m_TickWidth: 0.8
|
||||
m_TickLength: 5
|
||||
m_TickColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4294967295
|
||||
m_SplitAreaColors:
|
||||
- serializedVersion: 2
|
||||
rgba: 100663295
|
||||
- serializedVersion: 2
|
||||
rgba: 218103807
|
||||
m_BarBackgroundColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4291348680
|
||||
m_StageColor:
|
||||
- m_Percent: 0.2
|
||||
m_Color:
|
||||
serializedVersion: 2
|
||||
rgba: 4289644433
|
||||
- m_Percent: 0.8
|
||||
m_Color:
|
||||
serializedVersion: 2
|
||||
rgba: 4288579171
|
||||
- m_Percent: 1
|
||||
m_Color:
|
||||
serializedVersion: 2
|
||||
rgba: 4281415106
|
||||
m_Tooltip:
|
||||
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_TextColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_TextBackgroundColor: {r: 0.31764707, g: 0.31764707, b: 0.31764707, a: 0.78431374}
|
||||
m_FontSize: 20
|
||||
m_LineType: 0
|
||||
m_LineWidth: 0.8
|
||||
m_LineColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4293848814
|
||||
m_AreaColor:
|
||||
serializedVersion: 2
|
||||
rgba: 542200145
|
||||
m_LabelTextColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4294967295
|
||||
m_LabelBackgroundColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4289177511
|
||||
m_DataZoom:
|
||||
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_TextColor: {r: 0.7254902, g: 0.72156864, b: 0.80784315, a: 1}
|
||||
m_TextBackgroundColor: {r: 0, g: 0, b: 0, a: 0}
|
||||
m_FontSize: 20
|
||||
m_BorderWidth: 0.5
|
||||
m_DataLineWidth: 0.5
|
||||
m_FillerColor:
|
||||
serializedVersion: 2
|
||||
rgba: 869180295
|
||||
m_BorderColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4287262833
|
||||
m_DataLineColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4287262833
|
||||
m_DataAreaColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4287262833
|
||||
m_BackgroundColor:
|
||||
serializedVersion: 2
|
||||
rgba: 0
|
||||
m_VisualMap:
|
||||
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_TextColor: {r: 0.7254902, g: 0.72156864, b: 0.80784315, a: 1}
|
||||
m_TextBackgroundColor: {r: 0, g: 0, b: 0, a: 0}
|
||||
m_FontSize: 18
|
||||
m_BorderWidth: 0
|
||||
m_BorderColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4291611852
|
||||
m_BackgroundColor:
|
||||
serializedVersion: 2
|
||||
rgba: 0
|
||||
m_TriangeLen: 20
|
||||
m_Serie:
|
||||
m_LineWidth: 1.8
|
||||
m_LineSymbolSize: 4
|
||||
m_LineSymbolSelectedSize: 8
|
||||
m_ScatterSymbolSize: 20
|
||||
m_ScatterSymbolSelectedSize: 30
|
||||
m_PieTooltipExtraRadius: 8
|
||||
m_PieSelectedOffset: 8
|
||||
m_CandlestickColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4281415106
|
||||
m_CandlestickColor0:
|
||||
serializedVersion: 2
|
||||
rgba: 4283844145
|
||||
m_CandlestickBorderWidth: 1
|
||||
m_CandlestickBorderColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4281415106
|
||||
m_CandlestickBorderColor0:
|
||||
serializedVersion: 2
|
||||
rgba: 4283844145
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 22c71b519a1e34731aee339407499441
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,207 +0,0 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 6c59330ca0f4443b69f06b890a44f32e, type: 3}
|
||||
m_Name: XCTheme-Test2
|
||||
m_EditorClassIdentifier:
|
||||
m_ThemeType: 3
|
||||
m_ThemeName: Test2
|
||||
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_ContrastColor:
|
||||
serializedVersion: 2
|
||||
rgba: 0
|
||||
m_BackgroundColor:
|
||||
serializedVersion: 2
|
||||
rgba: 3725761966
|
||||
m_ColorPalette:
|
||||
- serializedVersion: 2
|
||||
rgba: 4294939209
|
||||
- serializedVersion: 2
|
||||
rgba: 4289920892
|
||||
- serializedVersion: 2
|
||||
rgba: 4284538365
|
||||
- serializedVersion: 2
|
||||
rgba: 4285951743
|
||||
- serializedVersion: 2
|
||||
rgba: 4294564184
|
||||
- serializedVersion: 2
|
||||
rgba: 4287741957
|
||||
- serializedVersion: 2
|
||||
rgba: 4282747647
|
||||
- serializedVersion: 2
|
||||
rgba: 4293085325
|
||||
- serializedVersion: 2
|
||||
rgba: 4294932957
|
||||
m_Common:
|
||||
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_TextColor: {r: 0.7254902, g: 0.72156864, b: 0.80784315, a: 1}
|
||||
m_TextBackgroundColor: {r: 0, g: 0, b: 0, a: 0}
|
||||
m_FontSize: 20
|
||||
m_Title:
|
||||
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_TextColor: {r: 0.93333334, g: 0.94509804, b: 0.98039216, a: 1}
|
||||
m_TextBackgroundColor: {r: 0, g: 0, b: 0, a: 0}
|
||||
m_FontSize: 24
|
||||
m_SubTitle:
|
||||
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_TextColor: {r: 0.7254902, g: 0.72156864, b: 0.80784315, a: 1}
|
||||
m_TextBackgroundColor: {r: 0, g: 0, b: 0, a: 0}
|
||||
m_FontSize: 22
|
||||
m_Legend:
|
||||
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_TextColor: {r: 0.7254902, g: 0.72156864, b: 0.80784315, a: 1}
|
||||
m_TextBackgroundColor: {r: 0, g: 0, b: 0, a: 0}
|
||||
m_FontSize: 20
|
||||
m_UnableColor: {r: 0.8, g: 0.8, b: 0.8, a: 1}
|
||||
m_Axis:
|
||||
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_TextColor: {r: 0.7254902, g: 0.72156864, b: 0.80784315, a: 1}
|
||||
m_TextBackgroundColor: {r: 0, g: 0, b: 0, a: 0}
|
||||
m_FontSize: 18
|
||||
m_LineType: 0
|
||||
m_LineWidth: 0.8
|
||||
m_LineLength: 0
|
||||
m_LineColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4291737785
|
||||
m_SplitLineType: 0
|
||||
m_SplitLineWidth: 0.8
|
||||
m_SplitLineLength: 0
|
||||
m_SplitLineColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4283647816
|
||||
m_TickWidth: 0.8
|
||||
m_TickLength: 5
|
||||
m_TickColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4291737785
|
||||
m_SplitAreaColors:
|
||||
- serializedVersion: 2
|
||||
rgba: 100663295
|
||||
- serializedVersion: 2
|
||||
rgba: 218103807
|
||||
m_Gauge:
|
||||
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_TextColor: {r: 0.7254902, g: 0.72156864, b: 0.80784315, a: 1}
|
||||
m_TextBackgroundColor: {r: 0, g: 0, b: 0, a: 0}
|
||||
m_FontSize: 18
|
||||
m_LineType: 0
|
||||
m_LineWidth: 15
|
||||
m_LineLength: 0
|
||||
m_LineColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4291737785
|
||||
m_SplitLineType: 0
|
||||
m_SplitLineWidth: 0.8
|
||||
m_SplitLineLength: 15
|
||||
m_SplitLineColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4294967295
|
||||
m_TickWidth: 0.8
|
||||
m_TickLength: 5
|
||||
m_TickColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4294967295
|
||||
m_SplitAreaColors:
|
||||
- serializedVersion: 2
|
||||
rgba: 100663295
|
||||
- serializedVersion: 2
|
||||
rgba: 218103807
|
||||
m_BarBackgroundColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4291348680
|
||||
m_StageColor:
|
||||
- m_Percent: 0.2
|
||||
m_Color:
|
||||
serializedVersion: 2
|
||||
rgba: 4289644433
|
||||
- m_Percent: 0.8
|
||||
m_Color:
|
||||
serializedVersion: 2
|
||||
rgba: 4288579171
|
||||
- m_Percent: 1
|
||||
m_Color:
|
||||
serializedVersion: 2
|
||||
rgba: 4281415106
|
||||
m_Tooltip:
|
||||
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_TextColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_TextBackgroundColor: {r: 0.31764707, g: 0.31764707, b: 0.31764707, a: 0.78431374}
|
||||
m_FontSize: 20
|
||||
m_LineType: 0
|
||||
m_LineWidth: 0.8
|
||||
m_LineColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4293848814
|
||||
m_AreaColor:
|
||||
serializedVersion: 2
|
||||
rgba: 542200145
|
||||
m_LabelTextColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4294967295
|
||||
m_LabelBackgroundColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4289177511
|
||||
m_DataZoom:
|
||||
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_TextColor: {r: 0.7254902, g: 0.72156864, b: 0.80784315, a: 1}
|
||||
m_TextBackgroundColor: {r: 0, g: 0, b: 0, a: 0}
|
||||
m_FontSize: 20
|
||||
m_BorderWidth: 0.5
|
||||
m_DataLineWidth: 0.5
|
||||
m_FillerColor:
|
||||
serializedVersion: 2
|
||||
rgba: 869180295
|
||||
m_BorderColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4287262833
|
||||
m_DataLineColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4287262833
|
||||
m_DataAreaColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4287262833
|
||||
m_BackgroundColor:
|
||||
serializedVersion: 2
|
||||
rgba: 0
|
||||
m_VisualMap:
|
||||
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_TextColor: {r: 0.7254902, g: 0.72156864, b: 0.80784315, a: 1}
|
||||
m_TextBackgroundColor: {r: 0, g: 0, b: 0, a: 0}
|
||||
m_FontSize: 18
|
||||
m_BorderWidth: 0
|
||||
m_BorderColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4291611852
|
||||
m_BackgroundColor:
|
||||
serializedVersion: 2
|
||||
rgba: 0
|
||||
m_TriangeLen: 20
|
||||
m_Serie:
|
||||
m_LineWidth: 1.8
|
||||
m_LineSymbolSize: 4
|
||||
m_LineSymbolSelectedSize: 8
|
||||
m_ScatterSymbolSize: 20
|
||||
m_ScatterSymbolSelectedSize: 30
|
||||
m_PieTooltipExtraRadius: 8
|
||||
m_PieSelectedOffset: 8
|
||||
m_CandlestickColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4281415106
|
||||
m_CandlestickColor0:
|
||||
serializedVersion: 2
|
||||
rgba: 4283844145
|
||||
m_CandlestickBorderWidth: 1
|
||||
m_CandlestickBorderColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4281415106
|
||||
m_CandlestickBorderColor0:
|
||||
serializedVersion: 2
|
||||
rgba: 4283844145
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 675c10db67ba545eb8a55e10f9ed5668
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,207 +0,0 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 6c59330ca0f4443b69f06b890a44f32e, type: 3}
|
||||
m_Name: XCTheme-Test3
|
||||
m_EditorClassIdentifier:
|
||||
m_ThemeType: 3
|
||||
m_ThemeName: Test3
|
||||
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_ContrastColor:
|
||||
serializedVersion: 2
|
||||
rgba: 0
|
||||
m_BackgroundColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4280006363
|
||||
m_ColorPalette:
|
||||
- serializedVersion: 2
|
||||
rgba: 4294939209
|
||||
- serializedVersion: 2
|
||||
rgba: 4289920892
|
||||
- serializedVersion: 2
|
||||
rgba: 4284538365
|
||||
- serializedVersion: 2
|
||||
rgba: 4285951743
|
||||
- serializedVersion: 2
|
||||
rgba: 4294564184
|
||||
- serializedVersion: 2
|
||||
rgba: 4287741957
|
||||
- serializedVersion: 2
|
||||
rgba: 4282747647
|
||||
- serializedVersion: 2
|
||||
rgba: 4293085325
|
||||
- serializedVersion: 2
|
||||
rgba: 4294932957
|
||||
m_Common:
|
||||
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_TextColor: {r: 0.7254902, g: 0.72156864, b: 0.80784315, a: 1}
|
||||
m_TextBackgroundColor: {r: 0, g: 0, b: 0, a: 0}
|
||||
m_FontSize: 20
|
||||
m_Title:
|
||||
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_TextColor: {r: 0.93333334, g: 0.94509804, b: 0.98039216, a: 1}
|
||||
m_TextBackgroundColor: {r: 0, g: 0, b: 0, a: 0}
|
||||
m_FontSize: 24
|
||||
m_SubTitle:
|
||||
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_TextColor: {r: 0.7254902, g: 0.72156864, b: 0.80784315, a: 1}
|
||||
m_TextBackgroundColor: {r: 0, g: 0, b: 0, a: 0}
|
||||
m_FontSize: 22
|
||||
m_Legend:
|
||||
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_TextColor: {r: 0.7254902, g: 0.72156864, b: 0.80784315, a: 1}
|
||||
m_TextBackgroundColor: {r: 0, g: 0, b: 0, a: 0}
|
||||
m_FontSize: 20
|
||||
m_UnableColor: {r: 0.8, g: 0.8, b: 0.8, a: 1}
|
||||
m_Axis:
|
||||
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_TextColor: {r: 0.7254902, g: 0.72156864, b: 0.80784315, a: 1}
|
||||
m_TextBackgroundColor: {r: 0, g: 0, b: 0, a: 0}
|
||||
m_FontSize: 18
|
||||
m_LineType: 0
|
||||
m_LineWidth: 0.8
|
||||
m_LineLength: 0
|
||||
m_LineColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4291737785
|
||||
m_SplitLineType: 0
|
||||
m_SplitLineWidth: 0.8
|
||||
m_SplitLineLength: 0
|
||||
m_SplitLineColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4283647816
|
||||
m_TickWidth: 0.8
|
||||
m_TickLength: 5
|
||||
m_TickColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4291737785
|
||||
m_SplitAreaColors:
|
||||
- serializedVersion: 2
|
||||
rgba: 100663295
|
||||
- serializedVersion: 2
|
||||
rgba: 218103807
|
||||
m_Gauge:
|
||||
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_TextColor: {r: 0.7254902, g: 0.72156864, b: 0.80784315, a: 1}
|
||||
m_TextBackgroundColor: {r: 0, g: 0, b: 0, a: 0}
|
||||
m_FontSize: 18
|
||||
m_LineType: 0
|
||||
m_LineWidth: 15
|
||||
m_LineLength: 0
|
||||
m_LineColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4291737785
|
||||
m_SplitLineType: 0
|
||||
m_SplitLineWidth: 0.8
|
||||
m_SplitLineLength: 15
|
||||
m_SplitLineColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4294967295
|
||||
m_TickWidth: 0.8
|
||||
m_TickLength: 5
|
||||
m_TickColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4294967295
|
||||
m_SplitAreaColors:
|
||||
- serializedVersion: 2
|
||||
rgba: 100663295
|
||||
- serializedVersion: 2
|
||||
rgba: 218103807
|
||||
m_BarBackgroundColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4291348680
|
||||
m_StageColor:
|
||||
- m_Percent: 0.2
|
||||
m_Color:
|
||||
serializedVersion: 2
|
||||
rgba: 4289644433
|
||||
- m_Percent: 0.8
|
||||
m_Color:
|
||||
serializedVersion: 2
|
||||
rgba: 4288579171
|
||||
- m_Percent: 1
|
||||
m_Color:
|
||||
serializedVersion: 2
|
||||
rgba: 4281415106
|
||||
m_Tooltip:
|
||||
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_TextColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_TextBackgroundColor: {r: 0.31764707, g: 0.31764707, b: 0.31764707, a: 0.78431374}
|
||||
m_FontSize: 20
|
||||
m_LineType: 0
|
||||
m_LineWidth: 0.8
|
||||
m_LineColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4293848814
|
||||
m_AreaColor:
|
||||
serializedVersion: 2
|
||||
rgba: 542200145
|
||||
m_LabelTextColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4294967295
|
||||
m_LabelBackgroundColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4289177511
|
||||
m_DataZoom:
|
||||
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_TextColor: {r: 0.7254902, g: 0.72156864, b: 0.80784315, a: 1}
|
||||
m_TextBackgroundColor: {r: 0, g: 0, b: 0, a: 0}
|
||||
m_FontSize: 20
|
||||
m_BorderWidth: 0.5
|
||||
m_DataLineWidth: 0.5
|
||||
m_FillerColor:
|
||||
serializedVersion: 2
|
||||
rgba: 869180295
|
||||
m_BorderColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4287262833
|
||||
m_DataLineColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4287262833
|
||||
m_DataAreaColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4287262833
|
||||
m_BackgroundColor:
|
||||
serializedVersion: 2
|
||||
rgba: 0
|
||||
m_VisualMap:
|
||||
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_TextColor: {r: 0.7254902, g: 0.72156864, b: 0.80784315, a: 1}
|
||||
m_TextBackgroundColor: {r: 0, g: 0, b: 0, a: 0}
|
||||
m_FontSize: 18
|
||||
m_BorderWidth: 0
|
||||
m_BorderColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4291611852
|
||||
m_BackgroundColor:
|
||||
serializedVersion: 2
|
||||
rgba: 0
|
||||
m_TriangeLen: 20
|
||||
m_Serie:
|
||||
m_LineWidth: 1.8
|
||||
m_LineSymbolSize: 4
|
||||
m_LineSymbolSelectedSize: 8
|
||||
m_ScatterSymbolSize: 20
|
||||
m_ScatterSymbolSelectedSize: 30
|
||||
m_PieTooltipExtraRadius: 8
|
||||
m_PieSelectedOffset: 8
|
||||
m_CandlestickColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4281415106
|
||||
m_CandlestickColor0:
|
||||
serializedVersion: 2
|
||||
rgba: 4283844145
|
||||
m_CandlestickBorderWidth: 1
|
||||
m_CandlestickBorderColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4281415106
|
||||
m_CandlestickBorderColor0:
|
||||
serializedVersion: 2
|
||||
rgba: 4283844145
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6e2f85adf3fea474b95fcc1f3341c4f6
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -42,44 +42,11 @@ namespace XCharts
|
||||
/// </summary>
|
||||
public ThemeStyle theme { get { return m_Theme; } set { m_Theme = value; } }
|
||||
/// <summary>
|
||||
/// The title setting of chart.
|
||||
/// 标题组件
|
||||
/// </summary>
|
||||
//public Title title { get { return GetChartComponent<Title>(); } }
|
||||
/// <summary>
|
||||
/// The legend setting of chart.
|
||||
/// 图例组件
|
||||
/// </summary>
|
||||
//public Legend legend { get { return m_Legends.Count > 0 ? m_Legends[0] : null; } }
|
||||
//public List<Legend> legends { get { return m_Legends; } }
|
||||
/// <summary>
|
||||
/// The tooltip setting of chart.
|
||||
/// 提示框组件
|
||||
/// </summary>
|
||||
//public Tooltip tooltip { get { return m_Tooltips.Count > 0 ? m_Tooltips[0] : null; } }
|
||||
/// <summary>
|
||||
/// The series setting of chart.
|
||||
/// 系列列表
|
||||
/// </summary>
|
||||
//public List<Serie> series { get { return m_Series; } }
|
||||
/// <summary>
|
||||
/// Global parameter setting component.
|
||||
/// 全局设置组件。
|
||||
/// </summary>
|
||||
public Settings settings { get { return m_Settings; } }
|
||||
/// <summary>
|
||||
/// dataZoom component.
|
||||
/// 区域缩放组件。
|
||||
/// </summary>
|
||||
//public DataZoom dataZoom { get { return m_DataZooms.Count > 0 ? m_DataZooms[0] : null; } }
|
||||
//public List<DataZoom> dataZooms { get { return m_DataZooms; } }
|
||||
/// <summary>
|
||||
/// visualMap component.
|
||||
/// 视觉映射组件。
|
||||
/// </summary>
|
||||
//public VisualMap visualMap { get { return m_VisualMaps.Count > 0 ? m_VisualMaps[0] : null; } }
|
||||
//public List<VisualMap> visualMaps { get { return m_VisualMaps; } }
|
||||
/// <summary>
|
||||
/// The x of chart.
|
||||
/// 图表的X
|
||||
/// </summary>
|
||||
@@ -450,6 +417,12 @@ namespace XCharts
|
||||
return m_LegendRealShowName.IndexOf(name);
|
||||
}
|
||||
|
||||
public Color32 GetLegendRealShowNameColor(string name)
|
||||
{
|
||||
var index = GetLegendRealShowNameIndex(name);
|
||||
return theme.GetColor(index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置Base Painter的材质球
|
||||
/// </summary>
|
||||
|
||||
@@ -25,7 +25,9 @@ namespace XCharts
|
||||
AddChartComponentWhenNoExist<XAxis>();
|
||||
AddChartComponentWhenNoExist<YAxis>();
|
||||
|
||||
GetChartComponent<Tooltip>().type = Tooltip.Type.Corss;
|
||||
var tooltip = GetChartComponent<Tooltip>();
|
||||
tooltip.type = Tooltip.Type.Shadow;
|
||||
tooltip.trigger = Tooltip.Trigger.Axis;
|
||||
|
||||
RemoveData();
|
||||
Candlestick.AddDefaultSerie(this, GenerateDefaultSerieName());
|
||||
|
||||
@@ -20,7 +20,10 @@ namespace XCharts
|
||||
protected override void Reset()
|
||||
{
|
||||
base.Reset();
|
||||
GetChartComponent<Tooltip>().type = Tooltip.Type.None;
|
||||
|
||||
var tooltip = GetChartComponent<Tooltip>();
|
||||
tooltip.type = Tooltip.Type.None;
|
||||
tooltip.trigger = Tooltip.Trigger.Axis;
|
||||
|
||||
var grid = GetOrAddChartComponent<GridCoord>();
|
||||
grid.left = 100;
|
||||
@@ -37,7 +40,7 @@ namespace XCharts
|
||||
yAxis.boundaryGap = true;
|
||||
yAxis.splitNumber = 10;
|
||||
RemoveData();
|
||||
|
||||
|
||||
var heatmapGridWid = 10f;
|
||||
int xSplitNumber = (int)(grid.context.width / heatmapGridWid);
|
||||
int ySplitNumber = (int)(grid.context.height / heatmapGridWid);
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace XCharts
|
||||
if (grid == null)
|
||||
return;
|
||||
|
||||
if (!grid.context.runtimeIsPointerEnter)
|
||||
if (!grid.context.isPointerEnter)
|
||||
{
|
||||
axis.context.pointerValue = double.PositiveInfinity;
|
||||
}
|
||||
|
||||
@@ -50,7 +50,8 @@ namespace XCharts
|
||||
[SerializeField] private Color32 m_BorderColor0;
|
||||
[SerializeField] private Color32 m_BorderToColor;
|
||||
[SerializeField] [Range(0, 1)] private float m_Opacity = 1;
|
||||
[SerializeField] private string m_TooltipFormatter;
|
||||
[SerializeField] private string m_ItemMarker;
|
||||
[SerializeField] private string m_ItemFormatter;
|
||||
[SerializeField] private string m_NumericFormatter = "";
|
||||
[SerializeField] private float[] m_CornerRadius = new float[] { 0, 0, 0, 0 };
|
||||
|
||||
@@ -71,7 +72,8 @@ namespace XCharts
|
||||
m_BorderColor0 = Color.clear;
|
||||
m_BorderToColor = Color.clear;
|
||||
m_Opacity = 1;
|
||||
m_TooltipFormatter = null;
|
||||
m_ItemFormatter = null;
|
||||
m_ItemMarker = null;
|
||||
m_NumericFormatter = "";
|
||||
if (m_CornerRadius == null)
|
||||
{
|
||||
@@ -209,10 +211,18 @@ namespace XCharts
|
||||
/// <summary>
|
||||
/// 提示框单项的字符串模版格式器。具体配置参考`Tooltip`的`formatter`
|
||||
/// </summary>
|
||||
public string tooltipFormatter
|
||||
public string itemFormatter
|
||||
{
|
||||
get { return m_TooltipFormatter; }
|
||||
set { if (PropertyUtil.SetClass(ref m_TooltipFormatter, value)) SetVerticesDirty(); }
|
||||
get { return m_ItemFormatter; }
|
||||
set { if (PropertyUtil.SetClass(ref m_ItemFormatter, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 提示框单项的字符标志。用在Tooltip中。
|
||||
/// </summary>
|
||||
public string itemMarker
|
||||
{
|
||||
get { return m_ItemMarker; }
|
||||
set { if (PropertyUtil.SetClass(ref m_ItemMarker, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Standard numeric format strings.
|
||||
|
||||
@@ -24,6 +24,7 @@ namespace XCharts
|
||||
[SerializeField] private bool m_AutoWrap = false;
|
||||
[SerializeField] private bool m_AutoAlign = true;
|
||||
[SerializeField] private float m_Rotate = 0;
|
||||
[SerializeField] private float m_ExtraWidth = 0;
|
||||
[SerializeField] private Vector2 m_Offset = Vector2.zero;
|
||||
[SerializeField] private Color m_Color = Color.clear;
|
||||
[SerializeField] private Color m_BackgroundColor = Color.clear;
|
||||
@@ -47,6 +48,15 @@ namespace XCharts
|
||||
set { if (PropertyUtil.SetStruct(ref m_Rotate, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Extra width of text preferred width.
|
||||
/// 额外的宽度
|
||||
/// </summary>
|
||||
public float extraWidth
|
||||
{
|
||||
get { return m_ExtraWidth; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_ExtraWidth, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the offset of position.
|
||||
/// 坐标偏移。
|
||||
/// [Default: `Vector2.zero`]
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace XCharts
|
||||
{
|
||||
var content = serieLabel.formatter;
|
||||
FormatterHelper.ReplaceSerieLabelContent(ref content, numericFormatter, data.runtimeValue,
|
||||
0, serie.serieName, data.name, Color.clear);
|
||||
0, serie.serieName, data.name, data.name, Color.clear);
|
||||
return content;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,10 +25,5 @@ namespace XCharts
|
||||
public float radius { get; internal set; }
|
||||
public float dataRadius { get; internal set; }
|
||||
public bool isPointerEnter { get; set; }
|
||||
/// <summary>
|
||||
/// the data position list of radar.
|
||||
/// 雷达图的所有数据坐标点列表。
|
||||
/// </summary>
|
||||
internal Dictionary<int, List<Vector3>> dataPositionDict = new Dictionary<int, List<Vector3>>();
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,7 @@ namespace XCharts
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
if (chart.isPointerInChart)
|
||||
if (!chart.isPointerInChart)
|
||||
{
|
||||
component.context.isPointerEnter = false;
|
||||
return;
|
||||
|
||||
@@ -71,30 +71,42 @@ namespace XCharts
|
||||
[SerializeField] private bool m_Show = true;
|
||||
[SerializeField] private Type m_Type;
|
||||
[SerializeField] private Trigger m_Trigger = Trigger.Item;
|
||||
[SerializeField] private string m_Formatter;
|
||||
[SerializeField] private string m_ItemFormatter;
|
||||
[SerializeField] private string m_TitleFormatter;
|
||||
[SerializeField] private string m_Marker = "●";
|
||||
[SerializeField] private float m_FixedWidth = 0;
|
||||
[SerializeField] private float m_FixedHeight = 0;
|
||||
[SerializeField] private float m_MinWidth = 0;
|
||||
[SerializeField] private float m_MinHeight = 0;
|
||||
[SerializeField] private string m_NumericFormatter = "";
|
||||
[SerializeField] private float m_PaddingLeftRight = 5f;
|
||||
[SerializeField] private float m_PaddingTopBottom = 5f;
|
||||
[SerializeField] private int m_PaddingLeftRight = 10;
|
||||
[SerializeField] private int m_PaddingTopBottom = 10;
|
||||
[SerializeField] private bool m_IgnoreDataShow = false;
|
||||
[SerializeField] private string m_IgnoreDataDefaultContent = "-";
|
||||
[SerializeField] private bool m_AlwayShow = false;
|
||||
[SerializeField] private Vector2 m_Offset = new Vector2(18f, -25f);
|
||||
[SerializeField] private Sprite m_BackgroundImage;
|
||||
[SerializeField] private TextStyle m_TextStyle = new TextStyle();
|
||||
[SerializeField] private Color m_BackgroundColor;
|
||||
[SerializeField] private float m_BorderWidth = 2f;
|
||||
[SerializeField] private bool m_FixedXEnable = false;
|
||||
[SerializeField] private float m_FixedX = 0f;
|
||||
[SerializeField] private bool m_FixedYEnable = false;
|
||||
[SerializeField] private float m_FixedY = 0f;
|
||||
[SerializeField] private float m_TitleHeight = 25f;
|
||||
[SerializeField] private float m_ItemHeight = 25f;
|
||||
[SerializeField] private Color32 m_BorderColor = new Color32(230, 230, 230, 255);
|
||||
[SerializeField] private LineStyle m_LineStyle = new LineStyle(LineStyle.Type.None);
|
||||
[SerializeField] private TextStyle m_LabelTextStyle = new TextStyle();
|
||||
[SerializeField] private TextStyle m_TitleTextStyle = new TextStyle() { alignment = TextAnchor.MiddleLeft };
|
||||
[SerializeField]
|
||||
private List<TextStyle> m_ColumnsTextStyle = new List<TextStyle>() {
|
||||
new TextStyle() { alignment = TextAnchor.MiddleLeft, extraWidth = 5 },
|
||||
new TextStyle() { alignment = TextAnchor.MiddleLeft, extraWidth = 20 },
|
||||
new TextStyle() { alignment = TextAnchor.MiddleRight, extraWidth = 5 }
|
||||
};
|
||||
|
||||
private GameObject m_GameObject;
|
||||
private GameObject m_Content;
|
||||
private ChartText m_ContentText;
|
||||
private Image m_ContentImage;
|
||||
private RectTransform m_ContentRect;
|
||||
private RectTransform m_ContentTextRect;
|
||||
public TooltipContext context = new TooltipContext();
|
||||
public TooltipView view;
|
||||
|
||||
/// <summary>
|
||||
/// Whether to show the tooltip component.
|
||||
@@ -124,8 +136,8 @@ namespace XCharts
|
||||
set { if (PropertyUtil.SetStruct(ref m_Trigger, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// A string template formatter for the total content of the prompt box. Support for wrapping lines with \n.
|
||||
/// When formatter is not null, use formatter first, otherwise use itemFormatter.
|
||||
/// The string template formatter for the tooltip title content. Support for wrapping lines with \n.
|
||||
/// The placeholder {I} can be set separately to indicate that the title is ignored and not displayed.
|
||||
/// Template variables are {.}, {a}, {b}, {c}, {d}.
|
||||
/// {.} is the dot of the corresponding color of a Serie that is currently indicated or whose index is 0.
|
||||
/// {a} is the series name of the serie that is currently indicated or whose index is 0.
|
||||
@@ -140,8 +152,8 @@ namespace XCharts
|
||||
/// {d1:2: F2} indicates that a formatted string with a value specified separately is F2 (numericFormatter is used when numericFormatter is not specified).
|
||||
/// {d:0.##} indicates that a formatted string with a value specified separately is 0.## (used for percentage, reserved 2 valid digits while avoiding the situation similar to "100.00%" when using f2 ).
|
||||
/// Example: "{a}, {c}", "{a1}, {c1: f1}", "{a1}, {c1:0: f1}", "{a1} : {c1:1-1: f1}"
|
||||
/// 提示框总内容的字符串模版格式器。支持用 \n 换行。当formatter不为空时,优先使用formatter,否则使用itemFormatter。
|
||||
/// 模板变量有{.}、{a}、{b}、{c}、{d}。
|
||||
/// 提示框标题内容的字符串模版格式器。支持用 \n 换行。可以单独设置占位符{i}表示忽略不显示title。
|
||||
/// 模板变量有{.}、{a}、{b}、{c}、{d}、{e}。
|
||||
/// {.}为当前所指示或index为0的serie的对应颜色的圆点。
|
||||
/// {a}为当前所指示或index为0的serie的系列名name。
|
||||
/// {b}为当前所指示或index为0的serie的数据项serieData的name,或者类目值(如折线图的X轴)。
|
||||
@@ -156,13 +168,6 @@ namespace XCharts
|
||||
/// {d:0.##} 表示单独指定了数值的格式化字符串为 0.## (用于百分比,保留2位有效数同时又能避免使用 f2 而出现的类似于"100.00%"的情况 )。
|
||||
/// 示例:"{a}:{c}"、"{a1}:{c1:f1}"、"{a1}:{c1:0:f1}"、"{a1}:{c1:1-1:f1}"
|
||||
/// </summary>
|
||||
public string formatter { get { return m_Formatter; } set { m_Formatter = value; } }
|
||||
/// <summary>
|
||||
/// The string template formatter for the tooltip title content. Support for wrapping lines with \n.
|
||||
/// This is only valid if the itemFormatter is in effect.
|
||||
/// The placeholder {I} can be set separately to indicate that the title is ignored and not displayed.
|
||||
/// 提示框标题内容的字符串模版格式器。支持用 \n 换行。仅当itemFormatter生效时才有效。可以单独设置占位符{i}表示忽略不显示title。
|
||||
/// </summary>
|
||||
public string titleFormatter { get { return m_TitleFormatter; } set { m_TitleFormatter = value; } }
|
||||
/// <summary>
|
||||
/// a string template formatter for a single Serie or data item content. Support for wrapping lines with \n.
|
||||
@@ -170,7 +175,11 @@ namespace XCharts
|
||||
/// 提示框单个serie或数据项内容的字符串模版格式器。支持用 \n 换行。当formatter不为空时,优先使用formatter,否则使用itemFormatter。
|
||||
/// </summary>
|
||||
public string itemFormatter { get { return m_ItemFormatter; } set { m_ItemFormatter = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// the marker of serie.
|
||||
/// serie的符号标志。
|
||||
/// </summary>
|
||||
public string marker { get { return m_Marker; } set { m_Marker = value; } }
|
||||
/// <summary>
|
||||
/// Fixed width. Higher priority than minWidth.
|
||||
/// 固定宽度。比 minWidth 优先。
|
||||
@@ -210,12 +219,12 @@ namespace XCharts
|
||||
/// the text padding of left and right. defaut:5.
|
||||
/// 左右边距。
|
||||
/// </summary>
|
||||
public float paddingLeftRight { get { return m_PaddingLeftRight; } set { m_PaddingLeftRight = value; } }
|
||||
public int paddingLeftRight { get { return m_PaddingLeftRight; } set { m_PaddingLeftRight = value; } }
|
||||
/// <summary>
|
||||
/// the text padding of top and bottom. defaut:5.
|
||||
/// 上下边距。
|
||||
/// </summary>
|
||||
public float paddingTopBottom { get { return m_PaddingTopBottom; } set { m_PaddingTopBottom = value; } }
|
||||
public int paddingTopBottom { get { return m_PaddingTopBottom; } set { m_PaddingTopBottom = value; } }
|
||||
/// <summary>
|
||||
/// Whether to show ignored data on tooltip.
|
||||
/// 是否显示忽略数据在tooltip上。
|
||||
@@ -227,10 +236,15 @@ namespace XCharts
|
||||
/// </summary>
|
||||
public string ignoreDataDefaultContent { get { return m_IgnoreDataDefaultContent; } set { m_IgnoreDataDefaultContent = value; } }
|
||||
/// <summary>
|
||||
/// The image of icon.
|
||||
/// 图标的图片。
|
||||
/// The background image of tooltip.
|
||||
/// 提示框的背景图片。
|
||||
/// </summary>
|
||||
public Sprite backgroundImage { get { return m_BackgroundImage; } set { m_BackgroundImage = value; SetBackground(m_BackgroundImage); } }
|
||||
public Sprite backgroundImage { get { return m_BackgroundImage; } set { m_BackgroundImage = value; SetComponentDirty(); } }
|
||||
/// <summary>
|
||||
/// The background color of tooltip.
|
||||
/// 提示框的背景颜色。
|
||||
/// </summary>
|
||||
public Color backgroundColor { get { return m_BackgroundColor; } set { m_BackgroundColor = value; SetComponentDirty(); } }
|
||||
/// <summary>
|
||||
/// Whether to trigger after always display.
|
||||
/// 是否触发后一直显示。
|
||||
@@ -242,14 +256,77 @@ namespace XCharts
|
||||
/// </summary>
|
||||
public Vector2 offset { get { return m_Offset; } set { m_Offset = value; } }
|
||||
/// <summary>
|
||||
/// the text style of content.
|
||||
/// 提示框内容文本样式。
|
||||
/// the width of tooltip border.
|
||||
/// 边框线宽。
|
||||
/// </summary>
|
||||
public TextStyle textStyle
|
||||
public float borderWidth
|
||||
{
|
||||
get { return m_TextStyle; }
|
||||
set { if (value != null) { m_TextStyle = value; SetComponentDirty(); } }
|
||||
get { return m_BorderWidth; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_BorderWidth, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the color of tooltip border.
|
||||
/// 边框颜色。
|
||||
/// </summary>
|
||||
public Color32 borderColor
|
||||
{
|
||||
get { return m_BorderColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_BorderColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
public bool fixedXEnable
|
||||
{
|
||||
get { return m_FixedXEnable; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_FixedXEnable, value)) SetVerticesDirty(); }
|
||||
}
|
||||
public float fixedX
|
||||
{
|
||||
get { return m_FixedX; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_FixedX, value)) SetVerticesDirty(); }
|
||||
}
|
||||
public bool fixedYEnable
|
||||
{
|
||||
get { return m_FixedYEnable; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_FixedYEnable, value)) SetVerticesDirty(); }
|
||||
}
|
||||
public float fixedY
|
||||
{
|
||||
get { return m_FixedY; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_FixedY, value)) SetVerticesDirty(); }
|
||||
}
|
||||
public float titleHeight
|
||||
{
|
||||
get { return m_TitleHeight; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_TitleHeight, value)) SetComponentDirty(); }
|
||||
}
|
||||
public float itemHeight
|
||||
{
|
||||
get { return m_ItemHeight; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_ItemHeight, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the text style of content.
|
||||
/// 提示框标签的文本样式。
|
||||
/// </summary>
|
||||
public TextStyle labelTextStyle
|
||||
{
|
||||
get { return m_LabelTextStyle; }
|
||||
set { if (value != null) { m_LabelTextStyle = value; SetComponentDirty(); } }
|
||||
}
|
||||
/// <summary>
|
||||
/// 标题的文本样式。
|
||||
/// </summary>
|
||||
public TextStyle titleTextStyle
|
||||
{
|
||||
get { return m_TitleTextStyle; }
|
||||
set { if (value != null) { m_TitleTextStyle = value; SetComponentDirty(); } }
|
||||
}
|
||||
|
||||
public List<TextStyle> columnsTextStyle
|
||||
{
|
||||
get { return m_ColumnsTextStyle; }
|
||||
set { if (value != null) { m_ColumnsTextStyle = value; SetComponentDirty(); } }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the line style of indicator line.
|
||||
/// 指示线样式。
|
||||
@@ -265,14 +342,14 @@ namespace XCharts
|
||||
/// </summary>
|
||||
public override bool componentDirty
|
||||
{
|
||||
get { return m_ComponentDirty || lineStyle.componentDirty || textStyle.componentDirty; }
|
||||
get { return m_ComponentDirty || lineStyle.componentDirty || labelTextStyle.componentDirty; }
|
||||
}
|
||||
|
||||
public override void ClearComponentDirty()
|
||||
{
|
||||
base.ClearComponentDirty();
|
||||
lineStyle.ClearComponentDirty();
|
||||
textStyle.ClearComponentDirty();
|
||||
labelTextStyle.ClearComponentDirty();
|
||||
}
|
||||
/// <summary>
|
||||
/// 当前提示框所指示的Serie索引(目前只对散点图有效)。
|
||||
@@ -285,126 +362,17 @@ namespace XCharts
|
||||
public List<int> runtimeDataIndex { get { return m_RuntimeDateIndex; } internal set { m_RuntimeDateIndex = value; } }
|
||||
private List<int> m_RuntimeDateIndex = new List<int>() { -1, -1 };
|
||||
/// <summary>
|
||||
/// the width of tooltip.
|
||||
/// 提示框宽。
|
||||
/// </summary>
|
||||
public float runtimeWidth { get { return m_ContentRect.sizeDelta.x; } }
|
||||
/// <summary>
|
||||
/// the height of tooltip.
|
||||
/// 提示框高。
|
||||
/// </summary>
|
||||
public float runtimeHeight { get { return m_ContentRect.sizeDelta.y; } }
|
||||
/// <summary>
|
||||
/// Whether the tooltip has been initialized.
|
||||
/// 提示框是否已初始化。
|
||||
/// </summary>
|
||||
public bool runtimeInited { get { return m_GameObject != null; } }
|
||||
/// <summary>
|
||||
/// the gameObject of tooltip.
|
||||
/// 提示框的gameObject。
|
||||
/// </summary>
|
||||
public GameObject runtimeGameObject { get { return m_GameObject; } }
|
||||
/// <summary>
|
||||
/// 当前指示的角度。
|
||||
/// </summary>
|
||||
public float runtimeAngle { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// 绑定提示框gameObject
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
public void SetObj(GameObject obj)
|
||||
{
|
||||
m_GameObject = obj;
|
||||
m_GameObject.SetActive(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 绑定提示框的文本框gameObject
|
||||
/// </summary>
|
||||
/// <param name="content"></param>
|
||||
public void SetContentObj(GameObject content)
|
||||
{
|
||||
m_Content = content;
|
||||
m_ContentRect = m_Content.GetComponent<RectTransform>();
|
||||
m_ContentImage = m_Content.GetComponent<Image>();
|
||||
m_ContentImage.raycastTarget = false;
|
||||
m_ContentText = new ChartText(m_Content);
|
||||
if (m_ContentText != null)
|
||||
{
|
||||
m_ContentTextRect = m_ContentText.gameObject.GetComponentInChildren<RectTransform>();
|
||||
}
|
||||
SetBackground(backgroundImage);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Keep Tooltiop displayed at the top.
|
||||
/// 保持Tooltiop显示在最顶上
|
||||
/// </summary>
|
||||
public void UpdateToTop()
|
||||
public void KeepTop()
|
||||
{
|
||||
if (m_GameObject == null) return;
|
||||
int count = m_GameObject.transform.parent.childCount;
|
||||
m_GameObject.GetComponent<RectTransform>().SetSiblingIndex(count - 1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置提示框文本背景色
|
||||
/// </summary>
|
||||
/// <param name="color"></param>
|
||||
public void SetContentBackgroundColor(Color color)
|
||||
{
|
||||
if (m_ContentImage != null)
|
||||
m_ContentImage.color = color;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置提示框文本背景图片
|
||||
/// </summary>
|
||||
/// <param name="sprite"></param>
|
||||
public void SetBackground(Sprite sprite)
|
||||
{
|
||||
if (m_ContentImage != null)
|
||||
{
|
||||
m_ContentImage.type = Image.Type.Sliced;
|
||||
m_ContentImage.sprite = sprite;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置提示框文本字体颜色
|
||||
/// </summary>
|
||||
/// <param name="color"></param>
|
||||
public void SetContentTextColor(Color color)
|
||||
{
|
||||
if (m_ContentText != null)
|
||||
{
|
||||
m_ContentText.SetColor(color);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置提示框文本内容
|
||||
/// </summary>
|
||||
/// <param name="txt"></param>
|
||||
public void UpdateContentText(string txt)
|
||||
{
|
||||
if (m_ContentText != null)
|
||||
{
|
||||
m_ContentText.SetText(txt);
|
||||
float wid, hig;
|
||||
if (m_FixedWidth > 0) wid = m_FixedWidth;
|
||||
else if (m_MinWidth > 0 && m_ContentText.GetPreferredWidth() < m_MinWidth) wid = m_MinWidth;
|
||||
else wid = m_ContentText.GetPreferredWidth() + m_PaddingLeftRight * 2;
|
||||
if (m_FixedHeight > 0) hig = m_FixedHeight;
|
||||
else if (m_MinHeight > 0 && m_ContentText.GetPreferredHeight() < m_MinHeight) hig = m_MinHeight;
|
||||
else hig = m_ContentText.GetPreferredHeight() + m_PaddingTopBottom * 2;
|
||||
if (m_ContentRect != null) m_ContentRect.sizeDelta = new Vector2(wid, hig);
|
||||
if (m_ContentTextRect != null)
|
||||
{
|
||||
m_ContentTextRect.anchoredPosition = new Vector3(m_PaddingLeftRight, -m_PaddingTopBottom);
|
||||
}
|
||||
}
|
||||
gameObject.transform.SetAsLastSibling();
|
||||
}
|
||||
|
||||
public override void ClearData()
|
||||
@@ -426,18 +394,20 @@ namespace XCharts
|
||||
/// <returns></returns>
|
||||
public bool IsActive()
|
||||
{
|
||||
return m_GameObject != null && m_GameObject.activeInHierarchy;
|
||||
return gameObject != null && gameObject.activeInHierarchy;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置提示框是否显示
|
||||
/// 设置Tooltip组件是否显示
|
||||
/// </summary>
|
||||
/// <param name="flag"></param>
|
||||
public void SetActive(bool flag)
|
||||
{
|
||||
if (!flag && m_AlwayShow) return;
|
||||
if (m_GameObject && m_GameObject.activeInHierarchy != flag)
|
||||
m_GameObject.SetActive(flag);
|
||||
if (gameObject && gameObject.activeInHierarchy != flag)
|
||||
{
|
||||
gameObject.SetActive(alwayShow ? true : flag);
|
||||
}
|
||||
SetContentActive(flag);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -446,26 +416,23 @@ namespace XCharts
|
||||
/// <param name="pos"></param>
|
||||
public void UpdateContentPos(Vector2 pos)
|
||||
{
|
||||
if (m_Content)
|
||||
m_Content.transform.localPosition = pos;
|
||||
}
|
||||
|
||||
public void SetContentActive(bool flag)
|
||||
{
|
||||
if (m_Content)
|
||||
ChartHelper.SetActive(m_Content, flag);
|
||||
if (view != null)
|
||||
{
|
||||
if (fixedXEnable) pos.x = fixedX;
|
||||
if (fixedYEnable) pos.y = fixedY;
|
||||
view.UpdatePosition(pos);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得当前提示框的位置
|
||||
/// 设置文本框是否显示
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Vector3 GetContentPos()
|
||||
/// <param name="flag"></param>
|
||||
public void SetContentActive(bool flag)
|
||||
{
|
||||
if (m_Content)
|
||||
return m_Content.transform.localPosition;
|
||||
else
|
||||
return Vector3.zero;
|
||||
if (view == null)
|
||||
return;
|
||||
view.SetActive(alwayShow ? true : flag);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -526,5 +493,18 @@ namespace XCharts
|
||||
{
|
||||
return trigger == Trigger.Axis;
|
||||
}
|
||||
|
||||
public TextStyle GetColumnTextStyle(int index)
|
||||
{
|
||||
if (m_ColumnsTextStyle.Count == 0)
|
||||
return null;
|
||||
|
||||
if (index < 0)
|
||||
index = 0;
|
||||
else if (index > m_ColumnsTextStyle.Count - 1)
|
||||
index = m_ColumnsTextStyle.Count - 1;
|
||||
|
||||
return m_ColumnsTextStyle[index];
|
||||
}
|
||||
}
|
||||
}
|
||||
30
Assets/XCharts/Runtime/Component/Tooltip/TooltipContext.cs
Normal file
30
Assets/XCharts/Runtime/Component/Tooltip/TooltipContext.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using XUGL;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
public class TooltipData
|
||||
{
|
||||
public string title;
|
||||
public List<SerieParams> param = new List<SerieParams>();
|
||||
}
|
||||
|
||||
public class TooltipContext
|
||||
{
|
||||
public Vector2 pointer;
|
||||
public float width;
|
||||
public float height;
|
||||
public TooltipData data = new TooltipData();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7324ce36c9b2c475bb18abd6618b107c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -16,7 +16,6 @@ namespace XCharts
|
||||
[UnityEngine.Scripting.Preserve]
|
||||
internal sealed class TooltipHandler : MainComponentHandler<Tooltip>
|
||||
{
|
||||
private static StringBuilder s_ContentBuilder = new StringBuilder(200);
|
||||
private List<ChartLabel> m_IndicatorLabels = new List<ChartLabel>();
|
||||
private GameObject m_LabelRoot;
|
||||
private ISerieContainer m_PointerContainer;
|
||||
@@ -30,6 +29,8 @@ namespace XCharts
|
||||
{
|
||||
UpdateTooltip(component);
|
||||
UpdateTooltipIndicatorLabelText(component);
|
||||
if (component.view != null)
|
||||
component.view.Update();
|
||||
}
|
||||
|
||||
public override void DrawTop(VertexHelper vh)
|
||||
@@ -49,13 +50,9 @@ namespace XCharts
|
||||
tooltipObject.transform.localPosition = Vector3.zero;
|
||||
tooltipObject.hideFlags = chart.chartHideFlags;
|
||||
var parent = tooltipObject.transform;
|
||||
var textStyle = tooltip.textStyle;
|
||||
ChartHelper.HideAllObject(tooltipObject.transform);
|
||||
GameObject content = ChartHelper.AddTooltipContent("content", parent, textStyle, chart.theme);
|
||||
tooltip.SetObj(tooltipObject);
|
||||
tooltip.SetContentObj(content);
|
||||
tooltip.SetContentBackgroundColor(TooltipHelper.GetTexBackgroundColor(tooltip, chart.theme.tooltip));
|
||||
tooltip.SetContentTextColor(TooltipHelper.GetTexColor(tooltip, chart.theme.tooltip));
|
||||
|
||||
tooltip.view = TooltipView.CreateView(tooltip, chart.theme, parent);
|
||||
tooltip.SetActive(false);
|
||||
|
||||
m_LabelRoot = ChartHelper.AddObject("label", tooltip.gameObject.transform, chart.chartMinAnchor,
|
||||
@@ -66,6 +63,7 @@ namespace XCharts
|
||||
{
|
||||
var labelName = "label_" + i;
|
||||
var item = ChartHelper.AddTooltipLabel(component, labelName, m_LabelRoot.transform, chart.theme, new Vector2(0.5f, 0.5f));
|
||||
item.SetActive(false);
|
||||
m_IndicatorLabels.Add(item);
|
||||
}
|
||||
};
|
||||
@@ -88,7 +86,7 @@ namespace XCharts
|
||||
private void UpdateTooltip(Tooltip tooltip)
|
||||
{
|
||||
if (tooltip.trigger == Tooltip.Trigger.None) return;
|
||||
if (!chart.isPointerInChart || !tooltip.show || !tooltip.runtimeInited)
|
||||
if (!chart.isPointerInChart || !tooltip.show)
|
||||
{
|
||||
if (tooltip.IsActive())
|
||||
{
|
||||
@@ -232,7 +230,7 @@ namespace XCharts
|
||||
serie.context.pointerAxisDataIndexs.Add((int)xAxis.context.pointerValue);
|
||||
xAxis.context.axisTooltipValue = xAxis.context.pointerValue;
|
||||
}
|
||||
else// if (xAxis.IsTime())
|
||||
else
|
||||
{
|
||||
GetSerieDataIndexByValue(serie, xAxis, grid);
|
||||
}
|
||||
@@ -314,50 +312,71 @@ namespace XCharts
|
||||
{
|
||||
if (tooltip.trigger == Tooltip.Trigger.None) return false;
|
||||
if (serie.context.pointerItemDataIndex < 0) return false;
|
||||
s_ContentBuilder.Length = 0;
|
||||
serie.handler.SetDefaultTooltipContent(tooltip, s_ContentBuilder);
|
||||
|
||||
tooltip.context.data.param.Clear();
|
||||
tooltip.context.data.title = serie.serieName;
|
||||
tooltip.context.pointer = chart.pointerPos;
|
||||
|
||||
serie.handler.UpdateTooltipSerieParams(serie.context.pointerItemDataIndex, false, null,
|
||||
tooltip.marker, tooltip.itemFormatter, tooltip.numericFormatter,
|
||||
ref tooltip.context.data.param,
|
||||
ref tooltip.context.data.title);
|
||||
TooltipHelper.ResetTooltipParamsByItemFormatter(tooltip, chart);
|
||||
|
||||
tooltip.SetActive(true);
|
||||
tooltip.UpdateContentPos(chart.pointerPos + tooltip.offset);
|
||||
TooltipHelper.SetContentAndPosition(tooltip, s_ContentBuilder.ToString(), chart.chartRect);
|
||||
tooltip.view.Refresh();
|
||||
TooltipHelper.LimitInRect(tooltip, chart.chartRect);
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool SetSerieTooltip(Tooltip tooltip, List<Serie> series)
|
||||
{
|
||||
if (tooltip.trigger == Tooltip.Trigger.None) return false;
|
||||
s_ContentBuilder.Length = 0;
|
||||
var showContent = false;
|
||||
if (tooltip.trigger == Tooltip.Trigger.None)
|
||||
return false;
|
||||
|
||||
if (series.Count <= 0)
|
||||
return false;
|
||||
|
||||
string category = null;
|
||||
var showCategory = false;
|
||||
var dataIndex = -1;
|
||||
tooltip.context.data.param.Clear();
|
||||
tooltip.context.pointer = chart.pointerPos;
|
||||
if (m_PointerContainer is GridCoord)
|
||||
{
|
||||
if (tooltip.trigger == Tooltip.Trigger.Axis)
|
||||
{
|
||||
var grid = m_PointerContainer as GridCoord;
|
||||
var category = GetAxisCategory(grid.index);
|
||||
if (!string.IsNullOrEmpty(category))
|
||||
s_ContentBuilder.Append(category).Append(FormatterHelper.PH_NN);
|
||||
}
|
||||
for (int i = 0; i < series.Count; i++)
|
||||
{
|
||||
var serie = series[i];
|
||||
if (serie.handler.SetDefaultTooltipContent(tooltip, s_ContentBuilder))
|
||||
GetAxisCategory(m_PointerContainer.index, ref dataIndex, ref category);
|
||||
if (series.Count <= 1)
|
||||
{
|
||||
showContent = true;
|
||||
if (i != series.Count - 1)
|
||||
s_ContentBuilder.Append(FormatterHelper.PH_NN);
|
||||
showCategory = true;
|
||||
tooltip.context.data.title = series[0].serieName;
|
||||
}
|
||||
else
|
||||
tooltip.context.data.title = category;
|
||||
}
|
||||
if (showContent)
|
||||
{
|
||||
tooltip.SetActive(true);
|
||||
tooltip.SetContentActive(true);
|
||||
tooltip.UpdateContentPos(chart.pointerPos + tooltip.offset);
|
||||
TooltipHelper.SetContentAndPosition(tooltip, s_ContentBuilder.ToString(), chart.chartRect);
|
||||
}
|
||||
|
||||
}
|
||||
return showContent;
|
||||
for (int i = 0; i < series.Count; i++)
|
||||
{
|
||||
var serie = series[i];
|
||||
serie.handler.UpdateTooltipSerieParams(dataIndex, showCategory, category,
|
||||
tooltip.marker, tooltip.itemFormatter, tooltip.numericFormatter,
|
||||
ref tooltip.context.data.param,
|
||||
ref tooltip.context.data.title);
|
||||
}
|
||||
TooltipHelper.ResetTooltipParamsByItemFormatter(tooltip, chart);
|
||||
if (tooltip.context.data.param.Count > 0)
|
||||
{
|
||||
tooltip.SetActive(true);
|
||||
tooltip.view.Refresh();
|
||||
TooltipHelper.LimitInRect(tooltip, chart.chartRect);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private string GetAxisCategory(int gridIndex)
|
||||
private bool GetAxisCategory(int gridIndex, ref int dataIndex, ref string category)
|
||||
{
|
||||
foreach (var component in chart.components)
|
||||
{
|
||||
@@ -366,11 +385,13 @@ namespace XCharts
|
||||
var axis = component as Axis;
|
||||
if (axis.gridIndex == gridIndex && axis.IsCategory())
|
||||
{
|
||||
return axis.GetData((int)axis.context.pointerValue);
|
||||
dataIndex = (int)axis.context.pointerValue;
|
||||
category = axis.GetData(dataIndex);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return false;
|
||||
}
|
||||
|
||||
private void DrawTooltipIndicator(VertexHelper vh, Tooltip tooltip)
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -12,398 +13,63 @@ namespace XCharts
|
||||
{
|
||||
public static class TooltipHelper
|
||||
{
|
||||
|
||||
public static void InitRadarTooltip(ref StringBuilder sb, Tooltip tooltip, Serie serie, RadarCoord radar,
|
||||
ThemeStyle theme)
|
||||
internal static void ResetTooltipParamsByItemFormatter(Tooltip tooltip, BaseChart chart)
|
||||
{
|
||||
if (radar == null) return;
|
||||
if (!serie.show) return;
|
||||
if (serie.radarIndex != radar.index) return;
|
||||
var dataIndex = tooltip.runtimeDataIndex[1];
|
||||
var serieData = serie.GetSerieData(dataIndex);
|
||||
if (!serieData.show) return;
|
||||
var numericFormatter = GetItemNumericFormatter(tooltip, serie, serieData);
|
||||
switch (serie.radarType)
|
||||
if (!string.IsNullOrEmpty(tooltip.titleFormatter))
|
||||
{
|
||||
case RadarType.Multiple:
|
||||
if (radar.isAxisTooltip)
|
||||
{
|
||||
var dimension = tooltip.runtimeDataIndex[2];
|
||||
if (!string.IsNullOrEmpty(serie.serieName))
|
||||
sb.Append(serie.serieName).Append("\n");
|
||||
var total = serie.GetDataTotal(dimension);
|
||||
var first = true;
|
||||
for (int i = 0; i < serie.dataCount; i++)
|
||||
{
|
||||
var sd = serie.GetSerieData(i);
|
||||
if (!sd.show) continue;
|
||||
var key = sd.name;
|
||||
var value = sd.GetData(dimension);
|
||||
var itemFormatter = GetItemFormatter(tooltip, serie, sd);
|
||||
numericFormatter = GetItemNumericFormatter(tooltip, serie, sd);
|
||||
if (!first) sb.Append("\n");
|
||||
first = false;
|
||||
sb.Append("<color=#").Append(theme.GetColorStr(i)).Append(">● </color>");
|
||||
if (string.IsNullOrEmpty(itemFormatter))
|
||||
{
|
||||
if (string.IsNullOrEmpty(key)) key = radar.indicatorList[dataIndex].name;
|
||||
if (string.IsNullOrEmpty(key))
|
||||
sb.AppendFormat("{0}\n", ChartCached.FloatToStr(value, numericFormatter));
|
||||
else
|
||||
sb.AppendFormat("{0}: {1}\n", key, ChartCached.FloatToStr(value, numericFormatter));
|
||||
}
|
||||
else
|
||||
{
|
||||
string content = itemFormatter;
|
||||
FormatterHelper.ReplaceSerieLabelContent(ref content, numericFormatter, value, total, serie.serieName,
|
||||
sd.name, theme.GetColor(i));
|
||||
sb.Append(content);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (serie.index != tooltip.runtimeDataIndex[0]) return;
|
||||
sb.Append(serieData.name);
|
||||
for (int i = 0; i < radar.indicatorList.Count; i++)
|
||||
{
|
||||
var key = radar.indicatorList[i].name;
|
||||
var value = serieData.GetData(i);
|
||||
if ((i == 0 && !string.IsNullOrEmpty(serieData.name)) || i > 0) sb.Append(FormatterHelper.PH_NN);
|
||||
sb.AppendFormat("{0}: {1}", key, ChartCached.FloatToStr(value, numericFormatter));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case RadarType.Single:
|
||||
var key2 = serieData.name;
|
||||
var value2 = serieData.GetData(1);
|
||||
var total2 = serie.GetDataTotal(1);
|
||||
var itemFormatter2 = GetItemFormatter(tooltip, serie, serieData);
|
||||
if (string.IsNullOrEmpty(itemFormatter2))
|
||||
{
|
||||
if (string.IsNullOrEmpty(key2))
|
||||
{
|
||||
key2 = radar.indicatorList[dataIndex].name;
|
||||
}
|
||||
sb.AppendFormat("{0}: {1}", key2, ChartCached.FloatToStr(value2, numericFormatter));
|
||||
}
|
||||
else
|
||||
{
|
||||
string content = itemFormatter2;
|
||||
FormatterHelper.ReplaceSerieLabelContent(ref content, numericFormatter, value2, total2, serie.serieName,
|
||||
serieData.name, theme.GetColor(serie.index));
|
||||
sb.Append(content);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static void InitCoordinateTooltip(ref StringBuilder sb, Tooltip tooltip, Serie serie, int index,
|
||||
ThemeStyle theme, bool isCartesian, DataZoom dataZoom = null)
|
||||
{
|
||||
string key = serie.serieName;
|
||||
double xValue, yValue;
|
||||
serie.GetXYData(index, dataZoom, out xValue, out yValue);
|
||||
var isIngore = serie.IsIgnorePoint(index);
|
||||
if (isIngore) return;
|
||||
var serieData = serie.GetSerieData(index, dataZoom);
|
||||
var numericFormatter = GetItemNumericFormatter(tooltip, serie, serieData);
|
||||
if (isCartesian)
|
||||
{
|
||||
if (serieData != null && serieData.context.highlight)
|
||||
if (tooltip.titleFormatter.Equals("{i}", StringComparison.CurrentCultureIgnoreCase))
|
||||
{
|
||||
sb.Append(key).Append(!string.IsNullOrEmpty(key) ? " : " : "");
|
||||
sb.Append("[").Append(ChartCached.FloatToStr(xValue, numericFormatter)).Append(",")
|
||||
.Append(ChartCached.FloatToStr(yValue, numericFormatter)).Append("]");
|
||||
}
|
||||
}
|
||||
else if (!isIngore || (isIngore && tooltip.ignoreDataShow))
|
||||
{
|
||||
var valueTxt = isIngore ? tooltip.ignoreDataDefaultContent :
|
||||
ChartCached.FloatToStr(yValue, numericFormatter);
|
||||
sb.Append("<color=#").Append(theme.GetColorStr(serie.index)).Append(">● </color>");
|
||||
if (serie is Candlestick)
|
||||
{
|
||||
sb.Append(key).Append(FormatterHelper.PH_NN);
|
||||
var data = serieData.data;
|
||||
var open = ChartCached.FloatToStr(data[0], numericFormatter);
|
||||
var close = ChartCached.FloatToStr(data[1], numericFormatter);
|
||||
var lowest = ChartCached.FloatToStr(data[2], numericFormatter);
|
||||
var heighest = ChartCached.FloatToStr(data[3], numericFormatter);
|
||||
sb.Append(" open: ").Append(open).Append(FormatterHelper.PH_NN);
|
||||
sb.Append(" close: ").Append(close).Append(FormatterHelper.PH_NN);
|
||||
sb.Append(" lowest: ").Append(lowest).Append(FormatterHelper.PH_NN);
|
||||
sb.Append(" heighest: ").Append(heighest);
|
||||
tooltip.context.data.title = string.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.Append(key).Append(!string.IsNullOrEmpty(key) ? " : " : "");
|
||||
sb.Append(valueTxt);
|
||||
tooltip.context.data.title = tooltip.titleFormatter;
|
||||
FormatterHelper.ReplaceContent(ref tooltip.context.data.title, 0,
|
||||
tooltip.numericFormatter, null, chart);
|
||||
}
|
||||
}
|
||||
foreach (var param in tooltip.context.data.param)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(param.itemFormatter))
|
||||
{
|
||||
var content = param.itemFormatter;
|
||||
FormatterHelper.ReplaceSerieLabelContent(ref content,
|
||||
param.numericFormatter,
|
||||
param.value,
|
||||
param.total,
|
||||
param.serieName,
|
||||
param.category,
|
||||
param.serieData.name,
|
||||
param.color);
|
||||
|
||||
param.columns.Clear();
|
||||
|
||||
foreach (var item in content.Split('|'))
|
||||
{
|
||||
param.columns.Add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void InitDefaultContent(ref StringBuilder sb, Tooltip tooltip, Serie serie, int index,
|
||||
BaseChart chart, DataZoom dataZoom = null, bool isCartesian = false,
|
||||
RadarCoord radar = null)
|
||||
public static void LimitInRect(Tooltip tooltip, Rect chartRect)
|
||||
{
|
||||
if (serie is Line || serie is Bar || serie is Candlestick)
|
||||
InitCoordinateTooltip(ref sb, tooltip, serie, index, chart.theme, isCartesian, dataZoom);
|
||||
else if (serie is Radar)
|
||||
InitRadarTooltip(ref sb, tooltip, serie, radar, chart.theme);
|
||||
}
|
||||
if (tooltip.view == null)
|
||||
return;
|
||||
|
||||
public static void SetContentAndPosition(Tooltip tooltip, string content, Rect chartRect)
|
||||
{
|
||||
tooltip.UpdateContentText(content);
|
||||
var pos = tooltip.GetContentPos();
|
||||
if (pos.x + tooltip.runtimeWidth > chartRect.x + chartRect.width)
|
||||
var pos = tooltip.view.GetTargetPos();
|
||||
if (pos.x + tooltip.context.width > chartRect.x + chartRect.width)
|
||||
{
|
||||
pos.x = chartRect.x + chartRect.width - tooltip.runtimeWidth;
|
||||
//pos.x = chartRect.x + chartRect.width - tooltip.context.width;
|
||||
pos.x = pos.x - tooltip.context.width - tooltip.offset.x;
|
||||
}
|
||||
if (pos.y - tooltip.runtimeHeight < chartRect.y)
|
||||
if (pos.y - tooltip.context.height < chartRect.y)
|
||||
{
|
||||
pos.y = chartRect.y + tooltip.runtimeHeight;
|
||||
pos.y = chartRect.y + tooltip.context.height;
|
||||
}
|
||||
tooltip.UpdateContentPos(pos);
|
||||
}
|
||||
|
||||
public static string GetPolarFormatterContent(Tooltip tooltip, BaseChart chart, AngleAxis angleAxis)
|
||||
{
|
||||
if (string.IsNullOrEmpty(tooltip.formatter))
|
||||
{
|
||||
var sb = ChartHelper.sb;
|
||||
sb.Length = 0;
|
||||
var title = tooltip.titleFormatter;
|
||||
var formatTitle = !string.IsNullOrEmpty(title);
|
||||
if ("{i}".Equals(tooltip.titleFormatter))
|
||||
{
|
||||
title = string.Empty;
|
||||
formatTitle = false;
|
||||
}
|
||||
else if (string.IsNullOrEmpty(title))
|
||||
{
|
||||
var angle = angleAxis.clockwise ? tooltip.runtimeAngle : 360 - tooltip.runtimeAngle;
|
||||
title = ChartCached.FloatToStr(angle);
|
||||
}
|
||||
foreach (var serie in chart.series)
|
||||
{
|
||||
if (serie.show && IsSelectedSerie(tooltip, serie.index))
|
||||
{
|
||||
if (formatTitle)
|
||||
{
|
||||
FormatterHelper.ReplaceContent(ref title, 0, tooltip.numericFormatter, serie, chart, null);
|
||||
}
|
||||
var dataIndexList = tooltip.runtimeSerieIndex[serie.index];
|
||||
|
||||
for (int i = 0; i < dataIndexList.Count; i++)
|
||||
{
|
||||
var dataIndex = dataIndexList[i];
|
||||
var serieData = serie.GetSerieData(dataIndex);
|
||||
var itemFormatter = GetItemFormatter(tooltip, serie, serieData);
|
||||
var numericFormatter = GetItemNumericFormatter(tooltip, serie, serieData);
|
||||
double xValue, yValue;
|
||||
serie.GetXYData(dataIndex, null, out xValue, out yValue);
|
||||
if (string.IsNullOrEmpty(itemFormatter))
|
||||
{
|
||||
sb.Append("<color=#").Append(chart.theme.GetColorStr(serie.index)).Append(">● </color>");
|
||||
if (!string.IsNullOrEmpty(serie.serieName))
|
||||
sb.Append(serie.serieName).Append(": ");
|
||||
sb.AppendFormat("{0}", ChartCached.FloatToStr(xValue, numericFormatter));
|
||||
if (i != dataIndexList.Count - 1)
|
||||
{
|
||||
sb.Append(FormatterHelper.PH_NN);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string content = itemFormatter;
|
||||
FormatterHelper.ReplaceContent(ref content, dataIndex, tooltip.numericFormatter, serie, chart, null);
|
||||
var dotColorIndex = serie is Pie || serie is Radar
|
||||
|| serie is Ring ? dataIndex : serie.index;
|
||||
sb.Append(ChartCached.ColorToDotStr(chart.theme.GetColor(dotColorIndex)));
|
||||
sb.Append(content);
|
||||
}
|
||||
}
|
||||
sb.Append(FormatterHelper.PH_NN);
|
||||
}
|
||||
}
|
||||
if (string.IsNullOrEmpty(title))
|
||||
{
|
||||
return FormatterHelper.TrimAndReplaceLine(sb);
|
||||
}
|
||||
else
|
||||
{
|
||||
title = FormatterHelper.TrimAndReplaceLine(title);
|
||||
return title + FormatterHelper.PH_NN + FormatterHelper.TrimAndReplaceLine(sb);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string content = tooltip.formatter;
|
||||
FormatterHelper.ReplaceContent(ref content, 0, tooltip.numericFormatter, null, chart, null);
|
||||
return content;
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetFormatterContent(Tooltip tooltip, int dataIndex, BaseChart chart, DataZoom dataZoom = null,
|
||||
bool isCartesian = false, RadarCoord radar = null)
|
||||
{
|
||||
if (string.IsNullOrEmpty(tooltip.formatter))
|
||||
{
|
||||
var sb = ChartHelper.sb;
|
||||
var title = tooltip.titleFormatter;
|
||||
var formatTitle = !string.IsNullOrEmpty(title);
|
||||
var titleIsIgnroe = false;
|
||||
var needCategory = false;
|
||||
var first = true;
|
||||
var isScatter = false;
|
||||
sb.Length = 0;
|
||||
if ("{i}".Equals(tooltip.titleFormatter))
|
||||
{
|
||||
title = string.Empty;
|
||||
formatTitle = false;
|
||||
titleIsIgnroe = true;
|
||||
}
|
||||
for (int i = 0; i < chart.series.Count; i++)
|
||||
{
|
||||
var serie = chart.GetSerie(i);
|
||||
//if (tooltip.runtimeGridIndex >= 0 && serie.runtimeGridIndex != tooltip.runtimeGridIndex) continue;
|
||||
if (serie is Scatter || serie is EffectScatter)
|
||||
{
|
||||
if (serie.show && IsSelectedSerie(tooltip, serie.index))
|
||||
{
|
||||
isScatter = true;
|
||||
var itemFormatter = GetItemFormatter(tooltip, serie, null);
|
||||
if (string.IsNullOrEmpty(itemFormatter))
|
||||
{
|
||||
if (!first) sb.Append(FormatterHelper.PH_NN);
|
||||
InitDefaultContent(ref sb, tooltip, serie, dataIndex, chart, dataZoom, isCartesian, radar);
|
||||
first = false;
|
||||
continue;
|
||||
}
|
||||
var itemTitle = title;
|
||||
if (!string.IsNullOrEmpty(itemTitle))
|
||||
{
|
||||
FormatterHelper.ReplaceContent(ref itemTitle, dataIndex, tooltip.numericFormatter, serie, chart, dataZoom);
|
||||
sb.Append(itemTitle).Append(FormatterHelper.PH_NN);
|
||||
}
|
||||
var dataIndexList = tooltip.runtimeSerieIndex[serie.index];
|
||||
foreach (var tempIndex in dataIndexList)
|
||||
{
|
||||
string content = itemFormatter;
|
||||
var foundDot = FormatterHelper.ReplaceContent(ref content, tempIndex, tooltip.numericFormatter, serie, chart, dataZoom);
|
||||
if (!foundDot)
|
||||
{
|
||||
sb.Append(ChartCached.ColorToDotStr(chart.theme.GetColor(serie.index)));
|
||||
}
|
||||
sb.Append(content).Append(FormatterHelper.PH_NN);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (IsNeedTooltipSerie(serie, tooltip))
|
||||
{
|
||||
var itemFormatter = string.Empty;
|
||||
if (serie is Gauge)
|
||||
{
|
||||
var serieData = serie.GetSerieData(0, dataZoom);
|
||||
if (serieData == null) continue;
|
||||
itemFormatter = GetItemFormatter(tooltip, serie, serieData);
|
||||
}
|
||||
else
|
||||
{
|
||||
var serieData = serie.GetSerieData(dataIndex, dataZoom);
|
||||
if (serieData == null) continue;
|
||||
itemFormatter = GetItemFormatter(tooltip, serie, serieData);
|
||||
}
|
||||
needCategory = needCategory || (serie is Line || serie is Bar);
|
||||
if (formatTitle)
|
||||
{
|
||||
FormatterHelper.ReplaceContent(ref title, dataIndex, tooltip.numericFormatter, serie, chart, dataZoom);
|
||||
}
|
||||
if (serie.show)
|
||||
{
|
||||
if (string.IsNullOrEmpty(itemFormatter) || serie is Radar)
|
||||
{
|
||||
if (!first) sb.Append(FormatterHelper.PH_NN);
|
||||
InitDefaultContent(ref sb, tooltip, serie, dataIndex, chart, dataZoom, isCartesian, radar);
|
||||
first = false;
|
||||
continue;
|
||||
}
|
||||
string content = itemFormatter;
|
||||
FormatterHelper.ReplaceContent(ref content, dataIndex, tooltip.numericFormatter, serie, chart, dataZoom);
|
||||
if (!first) sb.Append(FormatterHelper.PH_NN);
|
||||
var dotColorIndex = serie is Pie || serie is Radar
|
||||
|| serie is Ring ? dataIndex : i;
|
||||
sb.Append(ChartCached.ColorToDotStr(chart.theme.GetColor(dotColorIndex)));
|
||||
sb.Append(content);
|
||||
first = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isScatter)
|
||||
{
|
||||
return FormatterHelper.TrimAndReplaceLine(sb);
|
||||
}
|
||||
else if (string.IsNullOrEmpty(title))
|
||||
{
|
||||
if (needCategory && !titleIsIgnroe)
|
||||
{
|
||||
var category = chart.GetTooltipCategory(dataIndex, dataZoom);
|
||||
return category + FormatterHelper.PH_NN + FormatterHelper.TrimAndReplaceLine(sb);
|
||||
}
|
||||
else
|
||||
return FormatterHelper.TrimAndReplaceLine(sb);
|
||||
}
|
||||
else
|
||||
{
|
||||
title = FormatterHelper.TrimAndReplaceLine(title);
|
||||
return title + FormatterHelper.PH_NN + FormatterHelper.TrimAndReplaceLine(sb);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string content = tooltip.formatter;
|
||||
FormatterHelper.ReplaceContent(ref content, dataIndex, tooltip.numericFormatter, null, chart, dataZoom);
|
||||
return content;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsNeedTooltipSerie(Serie serie, Tooltip tooltip)
|
||||
{
|
||||
if (serie is Pie || serie is Ring)
|
||||
{
|
||||
if (serie.index < tooltip.runtimeDataIndex.Count)
|
||||
return tooltip.runtimeDataIndex[serie.index] >= 0;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
else if (serie is Gauge)
|
||||
{
|
||||
return serie.index == tooltip.runtimeDataIndex[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsSelectedSerie(Tooltip tooltip, int serieIndex)
|
||||
{
|
||||
if (tooltip.runtimeSerieIndex.ContainsKey(serieIndex))
|
||||
{
|
||||
return tooltip.runtimeSerieIndex[serieIndex].Count > 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static string GetItemFormatter(Tooltip tooltip, Serie serie, SerieData serieData)
|
||||
{
|
||||
var itemStyle = SerieHelper.GetItemStyle(serie, serieData);
|
||||
if (!string.IsNullOrEmpty(itemStyle.tooltipFormatter)) return itemStyle.tooltipFormatter;
|
||||
else return tooltip.itemFormatter;
|
||||
}
|
||||
|
||||
public static string GetItemNumericFormatter(Tooltip tooltip, Serie serie, SerieData serieData)
|
||||
{
|
||||
var itemStyle = SerieHelper.GetItemStyle(serie, serieData);
|
||||
@@ -425,29 +91,5 @@ namespace XCharts
|
||||
return color;
|
||||
}
|
||||
}
|
||||
|
||||
public static Color GetTexColor(Tooltip tooltip, ComponentTheme theme)
|
||||
{
|
||||
if (!ChartHelper.IsClearColor(tooltip.textStyle.color))
|
||||
{
|
||||
return tooltip.textStyle.color;
|
||||
}
|
||||
else
|
||||
{
|
||||
return theme.textColor;
|
||||
}
|
||||
}
|
||||
|
||||
public static Color GetTexBackgroundColor(Tooltip tooltip, ComponentTheme theme)
|
||||
{
|
||||
if (!ChartHelper.IsClearColor(tooltip.textStyle.backgroundColor))
|
||||
{
|
||||
return tooltip.textStyle.backgroundColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
return theme.textBackgroundColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
276
Assets/XCharts/Runtime/Component/Tooltip/TooltipView.cs
Normal file
276
Assets/XCharts/Runtime/Component/Tooltip/TooltipView.cs
Normal file
@@ -0,0 +1,276 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using XUGL;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
public class TooltipViewItem
|
||||
{
|
||||
public GameObject gameObject;
|
||||
public List<ChartText> columns = new List<ChartText>();
|
||||
}
|
||||
public class TooltipView
|
||||
{
|
||||
private static Vector2 anchorMax = new Vector2(0, 1);
|
||||
private static Vector2 anchorMin = new Vector2(0, 1);
|
||||
private static Vector2 pivot = new Vector2(0, 1);
|
||||
private static Vector2 v2_0_05 = new Vector2(0, 0.5f);
|
||||
|
||||
public Tooltip tooltip;
|
||||
public ComponentTheme theme;
|
||||
public GameObject gameObject;
|
||||
public Transform transform;
|
||||
public Image background;
|
||||
public Outline border;
|
||||
public VerticalLayoutGroup layout;
|
||||
public ChartText title;
|
||||
private List<TooltipViewItem> m_Items = new List<TooltipViewItem>();
|
||||
private List<float> m_ColumnMaxWidth = new List<float>();
|
||||
private bool m_Active = false;
|
||||
private Vector3 m_TargetPos;
|
||||
private Vector3 m_CurrentVelocity;
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (!m_Active)
|
||||
return;
|
||||
transform.localPosition = Vector3.SmoothDamp(transform.localPosition, m_TargetPos, ref m_CurrentVelocity, 0.08f);
|
||||
}
|
||||
|
||||
public Vector3 GetCurrentPos()
|
||||
{
|
||||
return transform.localPosition;
|
||||
}
|
||||
|
||||
public Vector3 GetTargetPos()
|
||||
{
|
||||
return m_TargetPos;
|
||||
}
|
||||
|
||||
public void UpdatePosition(Vector3 pos)
|
||||
{
|
||||
m_TargetPos = pos;
|
||||
}
|
||||
|
||||
public void SetActive(bool flag)
|
||||
{
|
||||
m_Active = flag;
|
||||
ChartHelper.SetActive(gameObject, flag);
|
||||
}
|
||||
|
||||
public void Refresh()
|
||||
{
|
||||
if (tooltip == null) return;
|
||||
var data = tooltip.context.data;
|
||||
|
||||
var titleActive = !string.IsNullOrEmpty(data.title);
|
||||
if (titleActive != title.gameObject.activeSelf)
|
||||
title.gameObject.SetActive(titleActive);
|
||||
title.SetText(data.title);
|
||||
|
||||
m_ColumnMaxWidth.Clear();
|
||||
for (int i = 0; i < data.param.Count; i++)
|
||||
{
|
||||
var item = GetItem(i);
|
||||
var param = data.param[i];
|
||||
item.gameObject.SetActive(true);
|
||||
|
||||
for (int j = 0; j < param.columns.Count; j++)
|
||||
{
|
||||
var column = GetItemColumn(item, j);
|
||||
column.SetActive(true);
|
||||
column.SetText(param.columns[j]);
|
||||
|
||||
if (j == 0)
|
||||
column.SetColor(param.color);
|
||||
|
||||
if (j >= m_ColumnMaxWidth.Count)
|
||||
m_ColumnMaxWidth.Add(0);
|
||||
|
||||
var columnWidth = column.GetPreferredWidth();
|
||||
if (m_ColumnMaxWidth[j] < columnWidth)
|
||||
m_ColumnMaxWidth[j] = columnWidth;
|
||||
}
|
||||
for (int j = param.columns.Count; j < item.columns.Count; j++)
|
||||
{
|
||||
item.columns[j].SetActive(false);
|
||||
}
|
||||
}
|
||||
for (int i = data.param.Count; i < m_Items.Count; i++)
|
||||
{
|
||||
m_Items[i].gameObject.SetActive(false);
|
||||
}
|
||||
ResetSize();
|
||||
// border.effectColor = data.param.Count == 1
|
||||
// ? data.param[0].color
|
||||
// : tooltip.borderColor;
|
||||
UpdatePosition(tooltip.context.pointer + tooltip.offset);
|
||||
tooltip.gameObject.transform.SetAsLastSibling();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void ResetSize()
|
||||
{
|
||||
var maxHig = 0f;
|
||||
var maxWid = 0f;
|
||||
if (tooltip.fixedWidth > 0)
|
||||
{
|
||||
maxWid = tooltip.fixedWidth;
|
||||
}
|
||||
else
|
||||
{
|
||||
maxWid = TotalMaxWidth();
|
||||
var titleWid = title.GetPreferredWidth();
|
||||
if (maxWid < titleWid)
|
||||
maxWid = titleWid;
|
||||
}
|
||||
|
||||
if (tooltip.fixedHeight > 0)
|
||||
{
|
||||
maxHig = tooltip.fixedHeight;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!string.IsNullOrEmpty(title.text.text))
|
||||
maxHig += tooltip.titleHeight;
|
||||
maxHig += tooltip.itemHeight * tooltip.context.data.param.Count;
|
||||
maxHig += tooltip.paddingTopBottom * 2;
|
||||
}
|
||||
|
||||
if (tooltip.minWidth > 0 && maxWid < tooltip.minWidth)
|
||||
maxWid = tooltip.minWidth;
|
||||
|
||||
if (tooltip.minHeight > 0 && maxHig < tooltip.minHeight)
|
||||
maxHig = tooltip.minHeight;
|
||||
|
||||
for (int i = 0; i < m_Items.Count; i++)
|
||||
{
|
||||
var item = m_Items[i];
|
||||
item.gameObject.GetComponent<RectTransform>().sizeDelta = new Vector2(maxWid, tooltip.itemHeight);
|
||||
var xPos = 0f;
|
||||
for (int j = 0; j < m_ColumnMaxWidth.Count; j++)
|
||||
{
|
||||
var deltaX = j == m_ColumnMaxWidth.Count - 1 ? maxWid - xPos : m_ColumnMaxWidth[j];
|
||||
item.columns[j].SetSizeDelta(new Vector2(deltaX, tooltip.itemHeight));
|
||||
item.columns[j].SetRectPosition(new Vector3(xPos, 0));
|
||||
xPos += m_ColumnMaxWidth[j];
|
||||
}
|
||||
}
|
||||
tooltip.context.width = maxWid + tooltip.paddingLeftRight * 2;
|
||||
tooltip.context.height = maxHig;
|
||||
background.GetComponent<RectTransform>().sizeDelta = new Vector2(tooltip.context.width, tooltip.context.height);
|
||||
}
|
||||
|
||||
private float TotalMaxWidth()
|
||||
{
|
||||
var total = 0f;
|
||||
foreach (var max in m_ColumnMaxWidth)
|
||||
total += max;
|
||||
return total;
|
||||
}
|
||||
|
||||
private TooltipViewItem GetItem(int i)
|
||||
{
|
||||
if (i < 0) i = 0;
|
||||
if (i < m_Items.Count)
|
||||
{
|
||||
return m_Items[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
var item = CreateViewItem(i, gameObject.transform, tooltip, theme);
|
||||
m_Items.Add(item);
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
private ChartText GetItemColumn(TooltipViewItem item, int i)
|
||||
{
|
||||
if (i < 0) i = 0;
|
||||
if (i < item.columns.Count)
|
||||
{
|
||||
return item.columns[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
var column = CreateViewItemColumn(i, item.gameObject.transform, tooltip, theme);
|
||||
item.columns.Add(column);
|
||||
return column;
|
||||
}
|
||||
}
|
||||
|
||||
public static TooltipView CreateView(Tooltip tooltip, ThemeStyle theme, Transform parent)
|
||||
{
|
||||
var view = new TooltipView();
|
||||
view.tooltip = tooltip;
|
||||
view.theme = theme.tooltip;
|
||||
|
||||
view.gameObject = ChartHelper.AddObject("view", parent, anchorMin, anchorMax, pivot, Vector3.zero);
|
||||
view.gameObject.transform.localPosition = Vector3.zero;
|
||||
view.transform = view.gameObject.transform;
|
||||
|
||||
view.background = ChartHelper.GetOrAddComponent<Image>(view.gameObject);
|
||||
view.background.color = ChartHelper.IsClearColor(tooltip.backgroundColor)
|
||||
? Color.white : tooltip.backgroundColor;
|
||||
|
||||
view.border = ChartHelper.GetOrAddComponent<Outline>(view.gameObject);
|
||||
view.border.enabled = tooltip.borderWidth > 0;
|
||||
view.border.effectColor = tooltip.borderColor;
|
||||
view.border.effectDistance = new Vector2(tooltip.borderWidth, -tooltip.borderWidth);
|
||||
|
||||
view.layout = ChartHelper.GetOrAddComponent<VerticalLayoutGroup>(view.gameObject);
|
||||
view.layout.childControlHeight = false;
|
||||
view.layout.childControlWidth = false;
|
||||
view.layout.childForceExpandHeight = false;
|
||||
view.layout.childForceExpandWidth = false;
|
||||
view.layout.padding = new RectOffset(tooltip.paddingLeftRight,
|
||||
tooltip.paddingLeftRight,
|
||||
tooltip.paddingTopBottom,
|
||||
tooltip.paddingTopBottom);
|
||||
|
||||
view.title = ChartHelper.AddTextObject("title", view.gameObject.transform, anchorMin, anchorMax, v2_0_05,
|
||||
new Vector2(10, tooltip.titleHeight), tooltip.titleTextStyle, theme.tooltip);
|
||||
view.title.SetText("");
|
||||
view.title.SetLocalPosition(new Vector2(3, -3));
|
||||
|
||||
var item = CreateViewItem(0, view.gameObject.transform, tooltip, theme.tooltip);
|
||||
view.m_Items.Add(item);
|
||||
|
||||
view.Refresh();
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
private static TooltipViewItem CreateViewItem(int i, Transform parent, Tooltip tooltip, ComponentTheme theme)
|
||||
{
|
||||
GameObject item1 = ChartHelper.AddObject("item" + i, parent, anchorMin, anchorMax, v2_0_05, Vector3.zero);
|
||||
|
||||
var item = new TooltipViewItem();
|
||||
item.gameObject = item1;
|
||||
item.columns.Add(CreateViewItemColumn(0, item1.transform, tooltip, theme));
|
||||
item.columns.Add(CreateViewItemColumn(1, item1.transform, tooltip, theme));
|
||||
item.columns.Add(CreateViewItemColumn(2, item1.transform, tooltip, theme));
|
||||
return item;
|
||||
}
|
||||
|
||||
private static ChartText CreateViewItemColumn(int i, Transform parent, Tooltip tooltip, ComponentTheme theme)
|
||||
{
|
||||
var value = ChartHelper.AddTextObject("column" + i, parent,
|
||||
v2_0_05, v2_0_05, v2_0_05, new Vector2(100, tooltip.itemHeight),
|
||||
tooltip.GetColumnTextStyle(i), theme);
|
||||
value.SetRectPosition(new Vector3(0, 0));
|
||||
value.SetText("");
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/XCharts/Runtime/Component/Tooltip/TooltipView.cs.meta
Normal file
11
Assets/XCharts/Runtime/Component/Tooltip/TooltipView.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 20bbaf6c402824f5d8abcaf1cee57865
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -88,7 +88,7 @@ namespace XCharts
|
||||
|
||||
public bool IsPointerEnter()
|
||||
{
|
||||
return context.runtimeIsPointerEnter;
|
||||
return context.isPointerEnter;
|
||||
}
|
||||
|
||||
public void UpdateRuntimeData(float chartX, float chartY, float chartWidth, float chartHeight)
|
||||
|
||||
@@ -20,6 +20,6 @@ namespace XCharts
|
||||
public float right { get; internal set; }
|
||||
public float bottom { get; internal set; }
|
||||
public float top { get; internal set; }
|
||||
public bool runtimeIsPointerEnter { get; set; }
|
||||
public bool isPointerEnter { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -49,11 +49,11 @@ namespace XCharts
|
||||
{
|
||||
if (chart.isPointerInChart)
|
||||
{
|
||||
component.context.runtimeIsPointerEnter = component.Contains(chart.pointerPos);
|
||||
component.context.isPointerEnter = component.Contains(chart.pointerPos);
|
||||
}
|
||||
else
|
||||
{
|
||||
component.context.runtimeIsPointerEnter = false;
|
||||
component.context.isPointerEnter = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -214,7 +214,7 @@ namespace XCharts
|
||||
}
|
||||
|
||||
public static void ReplaceSerieLabelContent(ref string content, string numericFormatter, double value, double total,
|
||||
string serieName, string dataName, Color color)
|
||||
string serieName, string category, string dataName, Color color)
|
||||
{
|
||||
var mc = s_RegexForSerieLabel.Matches(content);
|
||||
foreach (var m in mc)
|
||||
@@ -236,7 +236,11 @@ namespace XCharts
|
||||
{
|
||||
content = content.Replace(old, serieName);
|
||||
}
|
||||
else if (p == 'b' || p == 'B' || p == 'e' || p == 'E')
|
||||
else if (p == 'b' || p == 'B')
|
||||
{
|
||||
content = content.Replace(old, category);
|
||||
}
|
||||
else if (p == 'e' || p == 'E')
|
||||
{
|
||||
content = content.Replace(old, dataName);
|
||||
}
|
||||
|
||||
@@ -532,11 +532,25 @@ namespace XCharts
|
||||
else return null;
|
||||
}
|
||||
|
||||
public static string GetNumericFormatter(Serie serie, SerieData serieData)
|
||||
public static string GetNumericFormatter(Serie serie, SerieData serieData, string defaultFormatter = null)
|
||||
{
|
||||
var itemStyle = SerieHelper.GetItemStyle(serie, serieData);
|
||||
if (!string.IsNullOrEmpty(itemStyle.numericFormatter)) return itemStyle.numericFormatter;
|
||||
else return string.Empty;
|
||||
else return defaultFormatter;
|
||||
}
|
||||
|
||||
public static string GetItemFormatter(Serie serie, SerieData serieData, string defaultFormatter = null)
|
||||
{
|
||||
var itemStyle = SerieHelper.GetItemStyle(serie, serieData);
|
||||
if (!string.IsNullOrEmpty(itemStyle.itemFormatter)) return itemStyle.itemFormatter;
|
||||
else return defaultFormatter;
|
||||
}
|
||||
|
||||
public static string GetItemMarker(Serie serie, SerieData serieData, string defaultMarker = null)
|
||||
{
|
||||
var itemStyle = SerieHelper.GetItemStyle(serie, serieData);
|
||||
if (!string.IsNullOrEmpty(itemStyle.itemMarker)) return itemStyle.itemMarker;
|
||||
else return defaultMarker;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -99,7 +99,7 @@ namespace XCharts
|
||||
{
|
||||
var content = serieLabel.formatter;
|
||||
FormatterHelper.ReplaceSerieLabelContent(ref content, numericFormatter, dataValue,
|
||||
dataTotal, serieName, dataName, color);
|
||||
dataTotal, serieName, dataName, dataName, color);
|
||||
return content;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace XCharts
|
||||
{
|
||||
public string langName = "EN";
|
||||
public LangTime time = new LangTime();
|
||||
public LangCandlestick candlestick = new LangCandlestick();
|
||||
|
||||
public string GetMonthAbbr(int month)
|
||||
{
|
||||
@@ -38,6 +39,14 @@ namespace XCharts
|
||||
else
|
||||
return day.ToString();
|
||||
}
|
||||
|
||||
public string GetCandlestickDimensionName(int i)
|
||||
{
|
||||
if (i >= 0 && i < candlestick.dimensionNames.Count)
|
||||
return candlestick.dimensionNames[i];
|
||||
else
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
@@ -54,4 +63,9 @@ namespace XCharts
|
||||
public List<string> dayOfWeekAbbr = new List<string>() {
|
||||
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
|
||||
}
|
||||
|
||||
public class LangCandlestick
|
||||
{
|
||||
public List<string> dimensionNames = new List<string>() { "open", "close", "lowest", "highest" };
|
||||
}
|
||||
}
|
||||
@@ -798,7 +798,7 @@ namespace XCharts
|
||||
var handler = (SerieHandler)Activator.CreateInstance(attrubte.handler);
|
||||
handler.attribute = attrubte;
|
||||
handler.chart = this;
|
||||
handler.SerSerie(serie);
|
||||
handler.SetSerie(serie);
|
||||
serie.handler = handler;
|
||||
m_SerieHandlers.Add(handler);
|
||||
}
|
||||
|
||||
@@ -79,11 +79,6 @@ namespace XCharts
|
||||
handler.RefreshLabelNextFrame();
|
||||
}
|
||||
|
||||
public virtual bool SetDefaultTooltipContent(StringBuilder sb)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
protected virtual void Reset()
|
||||
{
|
||||
|
||||
@@ -10,6 +10,7 @@ namespace XCharts
|
||||
public interface ISerieContainer
|
||||
{
|
||||
//bool runtimeIsPointerEnter { get; }
|
||||
int index { get; }
|
||||
bool IsPointerEnter();
|
||||
}
|
||||
}
|
||||
11
Assets/XCharts/Runtime/Internal/Misc/ITooltipView.cs.meta
Normal file
11
Assets/XCharts/Runtime/Internal/Misc/ITooltipView.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f5ec8a82e2f9043c5b2e0b880fb024b6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -15,6 +15,7 @@ namespace XCharts
|
||||
{
|
||||
public class ChartText
|
||||
{
|
||||
private float m_ExtraWidth;
|
||||
private Text m_Text;
|
||||
public Text text
|
||||
{
|
||||
@@ -137,6 +138,11 @@ namespace XCharts
|
||||
#endif
|
||||
}
|
||||
|
||||
public void SetExtraWidth(float width)
|
||||
{
|
||||
m_ExtraWidth = width;
|
||||
}
|
||||
|
||||
public void SetActive(bool flag)
|
||||
{
|
||||
#if dUI_TextMeshPro
|
||||
@@ -156,6 +162,16 @@ namespace XCharts
|
||||
if (m_Text != null) m_Text.transform.localPosition = position;
|
||||
#endif
|
||||
}
|
||||
|
||||
public void SetRectPosition(Vector3 position)
|
||||
{
|
||||
#if dUI_TextMeshPro
|
||||
if (m_TMPText != null) m_TMPText.GetComponent<RectTransform>().anchoredPosition3D = position;
|
||||
#else
|
||||
if (m_Text != null) m_Text.GetComponent<RectTransform>().anchoredPosition3D = position;
|
||||
#endif
|
||||
}
|
||||
|
||||
public void SetSizeDelta(Vector2 sizeDelta)
|
||||
{
|
||||
#if dUI_TextMeshPro
|
||||
@@ -251,9 +267,9 @@ namespace XCharts
|
||||
public float GetPreferredWidth()
|
||||
{
|
||||
#if dUI_TextMeshPro
|
||||
if (m_TMPText != null) return m_TMPText.preferredWidth;
|
||||
if (m_TMPText != null) return m_TMPText.preferredWidth + m_ExtraWidth;
|
||||
#else
|
||||
if (m_Text != null) return m_Text.preferredWidth;
|
||||
if (m_Text != null) return m_Text.preferredWidth + m_ExtraWidth;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -267,6 +267,7 @@ namespace XCharts
|
||||
chartText.SetFontSize(textStyle.GetFontSize(theme));
|
||||
chartText.SetText("Text");
|
||||
chartText.SetLineSpacing(textStyle.lineSpacing);
|
||||
chartText.SetExtraWidth(textStyle.extraWidth);
|
||||
|
||||
RectTransform rect = GetOrAddComponent<RectTransform>(txtObj);
|
||||
rect.localPosition = Vector3.zero;
|
||||
@@ -472,7 +473,7 @@ namespace XCharts
|
||||
internal static ChartLabel AddTooltipLabel(Tooltip tooltip, string name, Transform parent, ThemeStyle theme, Vector2 pivot,
|
||||
Vector2 anchorMin, Vector2 anchorMax, Vector2 sizeDelta)
|
||||
{
|
||||
var textStyle = tooltip.textStyle;
|
||||
var textStyle = tooltip.labelTextStyle;
|
||||
var labelGameObject = AddObject(name, parent, anchorMin, anchorMax, pivot, sizeDelta);
|
||||
var label = GetOrAddComponent<ChartLabel>(labelGameObject);
|
||||
label.labelBackground = ChartHelper.AddIcon("Background", label.gameObject.transform, 50, 20);
|
||||
|
||||
@@ -24,45 +24,12 @@ namespace XCharts
|
||||
UpdateSerieContext();
|
||||
}
|
||||
|
||||
public override bool SetDefaultTooltipContent(Tooltip tooltip, StringBuilder sb)
|
||||
public override void UpdateTooltipSerieParams(int dataIndex, bool showCategory, string category,
|
||||
string marker, string itemFormatter, string numericFormatter,
|
||||
ref List<SerieParams> paramList, ref string title)
|
||||
{
|
||||
var dataIndex = serie.context.pointerItemDataIndex;
|
||||
if (!serie.context.pointerEnter || dataIndex < 0) return false;
|
||||
var serieData = serie.GetSerieData(dataIndex);
|
||||
if (serieData == null) return false;
|
||||
double xValue, yValue;
|
||||
serie.GetXYData(dataIndex, null, out xValue, out yValue);
|
||||
var isIngore = serie.IsIgnorePoint(dataIndex);
|
||||
var key = serieData.name;
|
||||
var numericFormatter = TooltipHelper.GetItemNumericFormatter(tooltip, serie, serieData);
|
||||
var valueTxt = isIngore ? tooltip.ignoreDataDefaultContent :
|
||||
ChartCached.FloatToStr(yValue, numericFormatter);
|
||||
switch (tooltip.trigger)
|
||||
{
|
||||
case Tooltip.Trigger.Item:
|
||||
var category = string.Empty;
|
||||
var xAxis = chart.GetChartComponent<XAxis>();
|
||||
var yAxis = chart.GetChartComponent<YAxis>();
|
||||
if (yAxis.IsCategory())
|
||||
category = yAxis.GetData((int)yAxis.context.pointerValue);
|
||||
else
|
||||
category = xAxis.IsCategory() ? xAxis.GetData((int)xAxis.context.pointerValue) :
|
||||
ChartCached.FloatToStr(xAxis.context.pointerValue, "F", 2);
|
||||
if (!string.IsNullOrEmpty(serie.serieName))
|
||||
sb.Append(serie.serieName).Append(FormatterHelper.PH_NN);
|
||||
sb.Append("<color=#").Append(chart.theme.GetColorStr(serie.index)).Append(">● </color>");
|
||||
if (!string.IsNullOrEmpty(category))
|
||||
sb.Append(category).Append(":");
|
||||
sb.Append(valueTxt);
|
||||
break;
|
||||
case Tooltip.Trigger.Axis:
|
||||
sb.Append("<color=#").Append(chart.theme.GetColorStr(serie.index)).Append(">● </color>");
|
||||
if (!string.IsNullOrEmpty(serie.serieName))
|
||||
sb.Append(serie.serieName).Append(":");
|
||||
sb.Append(valueTxt);
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
UpdateCoordSerieParams(ref paramList, ref title, dataIndex, showCategory, category,
|
||||
marker, itemFormatter, numericFormatter);
|
||||
}
|
||||
|
||||
public override void DrawSerie(VertexHelper vh)
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using XUGL;
|
||||
@@ -20,6 +21,69 @@ namespace XCharts
|
||||
DrawCandlestickSerie(vh, colorIndex, serie);
|
||||
}
|
||||
|
||||
public override void UpdateTooltipSerieParams(int dataIndex, bool showCategory, string category,
|
||||
string marker, string itemFormatter, string numericFormatter,
|
||||
ref List<SerieParams> paramList, ref string title)
|
||||
{
|
||||
if (dataIndex < 0)
|
||||
dataIndex = serie.context.pointerItemDataIndex;
|
||||
|
||||
if (dataIndex < 0)
|
||||
return;
|
||||
|
||||
var serieData = serie.GetSerieData(dataIndex);
|
||||
if (serieData == null)
|
||||
return;
|
||||
|
||||
title = category;
|
||||
|
||||
var color = chart.GetLegendRealShowNameColor(serie.serieName);
|
||||
var newMarker = SerieHelper.GetItemMarker(serie, serieData, marker);
|
||||
var newItemFormatter = SerieHelper.GetItemFormatter(serie, serieData, itemFormatter);
|
||||
var newNumericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter);
|
||||
|
||||
var param = serie.context.param;
|
||||
param.serieName = serie.serieName;
|
||||
param.serieIndex = serie.index;
|
||||
param.category = category;
|
||||
param.dimension = 1;
|
||||
param.serieData = serieData;
|
||||
param.value = 0;
|
||||
param.total = 0;
|
||||
param.color = color;
|
||||
param.marker = newMarker;
|
||||
param.itemFormatter = newItemFormatter;
|
||||
param.numericFormatter = newNumericFormatter;
|
||||
param.columns.Clear();
|
||||
|
||||
param.columns.Add(param.marker);
|
||||
param.columns.Add(serie.serieName);
|
||||
param.columns.Add(string.Empty);
|
||||
|
||||
paramList.Add(param);
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
param = new SerieParams();
|
||||
param.serieName = serie.serieName;
|
||||
param.serieIndex = serie.index;
|
||||
param.dimension = i;
|
||||
param.serieData = serieData;
|
||||
param.value = serieData.GetData(i);
|
||||
param.total = SerieHelper.GetMaxData(serie, i);
|
||||
param.color = color;
|
||||
param.marker = newMarker;
|
||||
param.itemFormatter = newItemFormatter;
|
||||
param.numericFormatter = newNumericFormatter;
|
||||
param.columns.Clear();
|
||||
|
||||
param.columns.Add(param.marker);
|
||||
param.columns.Add(XCSettings.lang.GetCandlestickDimensionName(i));
|
||||
param.columns.Add(ChartCached.NumberToStr(param.value, param.numericFormatter));
|
||||
|
||||
paramList.Add(param);
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawCandlestickSerie(VertexHelper vh, int colorIndex, Candlestick serie)
|
||||
{
|
||||
if (!serie.show) return;
|
||||
|
||||
@@ -49,25 +49,24 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
}
|
||||
serie.context.pointerEnter = false;
|
||||
serie.context.pointerItemDataIndex = -1;
|
||||
foreach (var serieData in serie.data)
|
||||
{
|
||||
if (serieData.IsInPolygon(chart.pointerPos))
|
||||
{
|
||||
serie.context.pointerEnter = true;
|
||||
serie.context.pointerItemDataIndex = serieData.index;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override bool SetDefaultTooltipContent(Tooltip tooltip, StringBuilder sb)
|
||||
public override void UpdateTooltipSerieParams(int dataIndex, bool showCategory, string category,
|
||||
string marker, string itemFormatter, string numericFormatter,
|
||||
ref List<SerieParams> paramList, ref string title)
|
||||
{
|
||||
if (!serie.context.pointerEnter || serie.context.pointerItemDataIndex < 0) return false;
|
||||
var serieData = serie.GetSerieData(serie.context.pointerItemDataIndex);
|
||||
if (serieData == null) return false;
|
||||
var key = serieData.name;
|
||||
var numericFormatter = TooltipHelper.GetItemNumericFormatter(tooltip, serie, serieData);
|
||||
var value = serieData.GetData(1);
|
||||
if (!string.IsNullOrEmpty(serie.serieName))
|
||||
{
|
||||
sb.Append(serie.serieName).Append(FormatterHelper.PH_NN);
|
||||
}
|
||||
sb.Append("<color=#").Append(chart.theme.GetColorStr(serie.context.pointerItemDataIndex)).Append(">● </color>");
|
||||
if (!string.IsNullOrEmpty(key))
|
||||
sb.Append(key).Append(": ");
|
||||
sb.Append(ChartCached.FloatToStr(value, numericFormatter));
|
||||
return true;
|
||||
UpdateItemSerieParams(ref paramList, ref title, dataIndex, category,
|
||||
marker, itemFormatter, numericFormatter);
|
||||
}
|
||||
|
||||
public override void DrawSerie(VertexHelper vh)
|
||||
@@ -233,6 +232,8 @@ namespace XCharts
|
||||
var p4 = ChartHelper.GetPosition(serie.context.center, currAngle + 90, serie.gaugePointer.width / 2);
|
||||
UGL.DrawTriangle(vh, p2, p3, p1, pointerColor, pointerColor, pointerToColor);
|
||||
UGL.DrawTriangle(vh, p4, p2, p1, pointerColor, pointerColor, pointerToColor);
|
||||
if (serie.data.Count > 0)
|
||||
serie.data[0].SetPolygon(p1, p2, p3, p4);
|
||||
}
|
||||
|
||||
private void DrawLineStyle(VertexHelper vh, Gauge serie)
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using XUGL;
|
||||
@@ -26,18 +27,53 @@ namespace XCharts
|
||||
DrawHeatmapSerie(vh, colorIndex, serie);
|
||||
}
|
||||
|
||||
public override void UpdateTooltipSerieParams(int dataIndex, bool showCategory, string category,
|
||||
string marker, string itemFormatter, string numericFormatter,
|
||||
ref List<SerieParams> paramList, ref string title)
|
||||
{
|
||||
dataIndex = serie.context.pointerItemDataIndex;
|
||||
if (dataIndex < 0)
|
||||
return;
|
||||
|
||||
var serieData = serie.GetSerieData(dataIndex);
|
||||
if (serieData == null)
|
||||
return;
|
||||
|
||||
title = serie.serieName;
|
||||
|
||||
var param = serie.context.param;
|
||||
param.serieName = serie.serieName;
|
||||
param.serieIndex = serie.index;
|
||||
param.dimension = 2;
|
||||
param.serieData = serieData;
|
||||
param.color = chart.theme.GetColor(serie.index);
|
||||
param.marker = SerieHelper.GetItemMarker(serie, serieData, marker);
|
||||
param.itemFormatter = SerieHelper.GetItemFormatter(serie, serieData, itemFormatter);
|
||||
param.numericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter);
|
||||
param.columns.Clear();
|
||||
|
||||
param.columns.Add(param.marker);
|
||||
param.columns.Add(category);
|
||||
param.columns.Add(ChartCached.NumberToStr(serieData.GetData(2), param.numericFormatter));
|
||||
|
||||
paramList.Add(param);
|
||||
}
|
||||
|
||||
private void UpdateSerieContext()
|
||||
{
|
||||
if (!chart.isPointerInChart) return;
|
||||
XAxis xAxis;
|
||||
YAxis yAxis;
|
||||
GridCoord grid;
|
||||
if (!chart.TryGetChartComponent<XAxis>(out xAxis, serie.xAxisIndex)) return;
|
||||
if (!chart.TryGetChartComponent<YAxis>(out yAxis, serie.yAxisIndex)) return;
|
||||
if (!chart.TryGetChartComponent<GridCoord>(out grid, xAxis.gridIndex)) return;
|
||||
serie.context.pointerItemDataIndex = -1;
|
||||
serie.context.pointerEnter = false;
|
||||
if (!grid.IsPointerEnter()) return;
|
||||
|
||||
if (!chart.isPointerInChart)
|
||||
return;
|
||||
|
||||
var grid = chart.GetChartComponent<GridCoord>(serie.containerIndex);
|
||||
if (grid == null)
|
||||
return;
|
||||
|
||||
if (!grid.IsPointerEnter())
|
||||
return;
|
||||
|
||||
foreach (var serieData in serie.data)
|
||||
{
|
||||
if (serieData.context.rect.Contains(chart.pointerPos))
|
||||
@@ -99,6 +135,7 @@ namespace XCharts
|
||||
if (dataIndex >= dataList.Count) continue;
|
||||
var serieData = dataList[dataIndex];
|
||||
var dimension = VisualMapHelper.GetDimension(visualMap, serieData.data.Count);
|
||||
serieData.index = dataIndex;
|
||||
if (serie.IsIgnoreIndex(dataIndex, dimension))
|
||||
{
|
||||
serie.context.dataPoints.Add(Vector3.zero);
|
||||
|
||||
@@ -27,68 +27,12 @@ namespace XCharts
|
||||
UpdateSerieContext();
|
||||
}
|
||||
|
||||
public override bool SetDefaultTooltipContent(Tooltip tooltip, StringBuilder sb)
|
||||
public override void UpdateTooltipSerieParams(int dataIndex, bool showCategory, string category,
|
||||
string marker, string itemFormatter, string numericFormatter,
|
||||
ref List<SerieParams> paramList, ref string title)
|
||||
{
|
||||
var dataIndex = serie.context.pointerItemDataIndex;
|
||||
if (!serie.context.pointerEnter || dataIndex < 0)
|
||||
return false;
|
||||
var serieData = serie.GetSerieData(dataIndex);
|
||||
if (serieData == null)
|
||||
return false;
|
||||
|
||||
double xValue, yValue;
|
||||
serie.GetXYData(dataIndex, null, out xValue, out yValue);
|
||||
|
||||
var isIngore = serie.IsIgnorePoint(dataIndex);
|
||||
var numericFormatter = TooltipHelper.GetItemNumericFormatter(tooltip, serie, serieData);
|
||||
var valueTxt = isIngore
|
||||
? tooltip.ignoreDataDefaultContent
|
||||
: ChartCached.FloatToStr(yValue, numericFormatter);
|
||||
|
||||
switch (tooltip.trigger)
|
||||
{
|
||||
case Tooltip.Trigger.Item:
|
||||
|
||||
var category = string.Empty;
|
||||
var xAxis = chart.GetChartComponent<XAxis>();
|
||||
var yAxis = chart.GetChartComponent<YAxis>();
|
||||
if (yAxis.IsCategory())
|
||||
{
|
||||
category = yAxis.GetData((int)yAxis.context.pointerValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
category = xAxis.IsCategory()
|
||||
? xAxis.GetData((int)xAxis.context.pointerValue)
|
||||
: (isIngore
|
||||
? tooltip.ignoreDataDefaultContent
|
||||
: ChartCached.FloatToStr(xValue, numericFormatter));
|
||||
}
|
||||
if (!string.IsNullOrEmpty(serie.serieName))
|
||||
sb.Append(serie.serieName).Append(FormatterHelper.PH_NN);
|
||||
|
||||
sb.Append("<color=#")
|
||||
.Append(chart.theme.GetColorStr(serie.index))
|
||||
.Append(">● </color>");
|
||||
|
||||
if (!string.IsNullOrEmpty(category))
|
||||
sb.Append(category).Append(":");
|
||||
sb.Append(valueTxt);
|
||||
break;
|
||||
|
||||
case Tooltip.Trigger.Axis:
|
||||
|
||||
sb.Append("<color=#")
|
||||
.Append(chart.theme.GetColorStr(serie.index))
|
||||
.Append(">● </color>");
|
||||
|
||||
if (!string.IsNullOrEmpty(serie.serieName))
|
||||
sb.Append(serie.serieName).Append(":");
|
||||
|
||||
sb.Append(valueTxt);
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
UpdateCoordSerieParams(ref paramList, ref title, dataIndex, showCategory, category,
|
||||
marker, itemFormatter, numericFormatter);
|
||||
}
|
||||
|
||||
public override void DrawSerie(VertexHelper vh)
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
@@ -28,23 +29,12 @@ namespace XCharts
|
||||
DrawPie(vh, serie);
|
||||
}
|
||||
|
||||
public override bool SetDefaultTooltipContent(Tooltip tooltip, StringBuilder sb)
|
||||
public override void UpdateTooltipSerieParams(int dataIndex, bool showCategory, string category,
|
||||
string marker, string itemFormatter, string numericFormatter,
|
||||
ref List<SerieParams> paramList, ref string title)
|
||||
{
|
||||
if (!serie.context.pointerEnter || serie.context.pointerItemDataIndex < 0) return false;
|
||||
var serieData = serie.GetSerieData(serie.context.pointerItemDataIndex);
|
||||
if (serieData == null) return false;
|
||||
var key = serieData.name;
|
||||
var numericFormatter = TooltipHelper.GetItemNumericFormatter(tooltip, serie, serieData);
|
||||
var value = serieData.GetData(1);
|
||||
if (!string.IsNullOrEmpty(serie.serieName))
|
||||
{
|
||||
sb.Append(serie.serieName).Append(FormatterHelper.PH_NN);
|
||||
}
|
||||
sb.Append("<color=#").Append(chart.theme.GetColorStr(serie.context.pointerItemDataIndex)).Append(">● </color>");
|
||||
if (!string.IsNullOrEmpty(key))
|
||||
sb.Append(key).Append(": ");
|
||||
sb.Append(ChartCached.FloatToStr(value, numericFormatter));
|
||||
return true;
|
||||
UpdateItemSerieParams(ref paramList, ref title, dataIndex, category,
|
||||
marker, itemFormatter, numericFormatter);
|
||||
}
|
||||
|
||||
public override void RefreshLabelInternal()
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace XCharts
|
||||
[RequireChartComponent(typeof(RadarCoord))]
|
||||
public class Radar : Serie, INeedSerieContainer
|
||||
{
|
||||
public int containerIndex { get { return radarIndex; } }
|
||||
public int containerIndex { get; internal set; }
|
||||
public int containterInstanceId { get; internal set; }
|
||||
|
||||
public override bool useDataNameForColor { get { return true; } }
|
||||
|
||||
@@ -15,11 +15,10 @@ namespace XCharts
|
||||
[UnityEngine.Scripting.Preserve]
|
||||
internal sealed class RadarHandler : SerieHandler<Radar>
|
||||
{
|
||||
Dictionary<string, int> serieNameSet = new Dictionary<string, int>();
|
||||
|
||||
public override void DrawBase(VertexHelper vh)
|
||||
public override void Update()
|
||||
{
|
||||
serieNameSet.Clear();
|
||||
base.Update();
|
||||
UpdateSerieContext();
|
||||
}
|
||||
|
||||
public override void DrawSerie(VertexHelper vh)
|
||||
@@ -28,14 +27,66 @@ namespace XCharts
|
||||
switch (serie.radarType)
|
||||
{
|
||||
case RadarType.Multiple:
|
||||
DrawMutipleRadar(vh, serie, serie.index);
|
||||
DrawMutipleRadar(vh);
|
||||
break;
|
||||
case RadarType.Single:
|
||||
DrawSingleRadar(vh, serie, serie.index);
|
||||
DrawSingleRadar(vh);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public override void UpdateTooltipSerieParams(int dataIndex, bool showCategory, string category,
|
||||
string marker, string itemFormatter, string numericFormatter,
|
||||
ref List<SerieParams> paramList, ref string title)
|
||||
{
|
||||
if (!serie.context.pointerEnter)
|
||||
return;
|
||||
dataIndex = serie.context.pointerItemDataIndex;
|
||||
if (dataIndex < 0)
|
||||
return;
|
||||
|
||||
if (serie.radarType == RadarType.Single)
|
||||
{
|
||||
UpdateItemSerieParams(ref paramList, ref title, dataIndex, category,
|
||||
marker, itemFormatter, numericFormatter);
|
||||
return;
|
||||
}
|
||||
|
||||
var radar = chart.GetChartComponent<RadarCoord>(serie.radarIndex);
|
||||
if (radar == null)
|
||||
return;
|
||||
|
||||
var serieData = serie.GetSerieData(dataIndex);
|
||||
if (serieData == null)
|
||||
return;
|
||||
|
||||
var color = chart.theme.GetColor(dataIndex);
|
||||
title = serieData.name;
|
||||
for (int i = 0; i < serieData.data.Count; i++)
|
||||
{
|
||||
var indicator = radar.GetIndicator(i);
|
||||
|
||||
var param = new SerieParams();
|
||||
param.serieName = serie.serieName;
|
||||
param.serieIndex = serie.index;
|
||||
param.dimension = i;
|
||||
param.serieData = serieData;
|
||||
param.value = serieData.GetData(i);
|
||||
param.total = indicator.max;
|
||||
param.color = color;
|
||||
param.marker = SerieHelper.GetItemMarker(serie, serieData, marker);
|
||||
param.itemFormatter = SerieHelper.GetItemFormatter(serie, serieData, itemFormatter);
|
||||
param.numericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter);
|
||||
param.columns.Clear();
|
||||
|
||||
param.columns.Add(param.marker);
|
||||
param.columns.Add(indicator == null ? string.Empty : indicator.name);
|
||||
param.columns.Add(ChartCached.NumberToStr(serieData.GetData(i), param.numericFormatter));
|
||||
|
||||
paramList.Add(param);
|
||||
}
|
||||
}
|
||||
|
||||
public override void RefreshLabelInternal()
|
||||
{
|
||||
for (int i = 0; i < chart.series.Count; i++)
|
||||
@@ -109,19 +160,61 @@ namespace XCharts
|
||||
return true;
|
||||
}
|
||||
|
||||
private void DrawMutipleRadar(VertexHelper vh, Serie serie, int i)
|
||||
|
||||
|
||||
private void UpdateSerieContext()
|
||||
{
|
||||
if (!chart.isPointerInChart) return;
|
||||
serie.context.pointerEnter = false;
|
||||
switch (serie.radarType)
|
||||
{
|
||||
case RadarType.Multiple:
|
||||
for (int i = 0; i < serie.data.Count; i++)
|
||||
{
|
||||
var serieData = serie.data[i];
|
||||
serieData.index = i;
|
||||
foreach (var pos in serieData.context.dataPoints)
|
||||
{
|
||||
if (Vector3.Distance(chart.pointerPos, pos) < serie.symbol.size * 2)
|
||||
{
|
||||
serie.context.pointerEnter = true;
|
||||
serie.context.pointerItemDataIndex = i;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case RadarType.Single:
|
||||
for (int i = 0; i < serie.data.Count; i++)
|
||||
{
|
||||
var serieData = serie.data[i];
|
||||
serieData.index = i;
|
||||
if (Vector3.Distance(chart.pointerPos, serieData.context.position) < serie.symbol.size * 2)
|
||||
{
|
||||
serie.context.pointerEnter = true;
|
||||
serie.context.pointerItemDataIndex = i;
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawMutipleRadar(VertexHelper vh)
|
||||
{
|
||||
if (!serie.show) return;
|
||||
var radar = chart.GetChartComponent<RadarCoord>(serie.radarIndex);
|
||||
if (radar == null) return;
|
||||
var tooltip = chart.GetChartComponent<Tooltip>();
|
||||
|
||||
serie.containerIndex = radar.index;
|
||||
serie.containterInstanceId = radar.instanceId;
|
||||
|
||||
var startPoint = Vector3.zero;
|
||||
var toPoint = Vector3.zero;
|
||||
var firstPoint = Vector3.zero;
|
||||
var indicatorNum = radar.indicatorList.Count;
|
||||
var angle = 2 * Mathf.PI / indicatorNum;
|
||||
var centerPos = radar.context.center;
|
||||
var serieNameCount = -1;
|
||||
serie.animation.InitProgress(0, 1);
|
||||
if (!serie.show || serie.animation.HasFadeOut())
|
||||
{
|
||||
@@ -134,43 +227,18 @@ namespace XCharts
|
||||
for (int j = 0; j < serie.data.Count; j++)
|
||||
{
|
||||
var serieData = serie.data[j];
|
||||
int key = i * 1000 + j;
|
||||
if (!radar.context.dataPositionDict.ContainsKey(key))
|
||||
{
|
||||
radar.context.dataPositionDict.Add(i * 1000 + j, new List<Vector3>(serieData.data.Count));
|
||||
}
|
||||
else
|
||||
{
|
||||
radar.context.dataPositionDict[key].Clear();
|
||||
}
|
||||
string dataName = serieData.name;
|
||||
int serieIndex = 0;
|
||||
if (string.IsNullOrEmpty(dataName))
|
||||
{
|
||||
serieNameCount++;
|
||||
serieIndex = serieNameCount;
|
||||
}
|
||||
else if (!serieNameSet.ContainsKey(dataName))
|
||||
{
|
||||
serieNameSet.Add(dataName, serieNameCount);
|
||||
serieNameCount++;
|
||||
serieIndex = serieNameCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
serieIndex = serieNameSet[dataName];
|
||||
}
|
||||
if (!serieData.show)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var isHighlight = IsHighlight(radar, serie, serieData, tooltip, j, 0);
|
||||
var areaColor = SerieHelper.GetAreaColor(serie, chart.theme, serieIndex, isHighlight);
|
||||
var areaToColor = SerieHelper.GetAreaToColor(serie, chart.theme, serieIndex, isHighlight);
|
||||
var lineColor = SerieHelper.GetLineColor(serie, chart.theme, serieIndex, isHighlight);
|
||||
var isHighlight = serie.context.pointerEnter;
|
||||
var areaColor = SerieHelper.GetAreaColor(serie, chart.theme, j, isHighlight);
|
||||
var areaToColor = SerieHelper.GetAreaToColor(serie, chart.theme, j, isHighlight);
|
||||
var lineColor = SerieHelper.GetLineColor(serie, chart.theme, j, isHighlight);
|
||||
var lineWidth = serie.lineStyle.GetWidth(chart.theme.serie.lineWidth);
|
||||
int dataCount = radar.indicatorList.Count;
|
||||
List<Vector3> pointList = radar.context.dataPositionDict[key];
|
||||
serieData.context.dataPoints.Clear();
|
||||
for (int n = 0; n < dataCount; n++)
|
||||
{
|
||||
if (n >= serieData.data.Count) break;
|
||||
@@ -205,7 +273,7 @@ namespace XCharts
|
||||
}
|
||||
startPoint = toPoint;
|
||||
}
|
||||
pointList.Add(startPoint);
|
||||
serieData.context.dataPoints.Add(startPoint);
|
||||
}
|
||||
if (serie.areaStyle.show)
|
||||
{
|
||||
@@ -217,16 +285,16 @@ namespace XCharts
|
||||
}
|
||||
if (serie.symbol.show && serie.symbol.type != SymbolType.None)
|
||||
{
|
||||
for (int m = 0; m < pointList.Count; m++)
|
||||
for (int m = 0; m < serieData.context.dataPoints.Count; m++)
|
||||
{
|
||||
var point = pointList[m];
|
||||
isHighlight = IsHighlight(radar, serie, serieData, tooltip, j, m);
|
||||
var point = serieData.context.dataPoints[m];
|
||||
isHighlight = serie.context.pointerEnter;
|
||||
var symbolSize = isHighlight
|
||||
? serie.symbol.GetSelectedSize(null, chart.theme.serie.lineSymbolSelectedSize)
|
||||
: serie.symbol.GetSize(null, chart.theme.serie.lineSymbolSize);
|
||||
var symbolColor = SerieHelper.GetItemColor(serie, serieData, chart.theme, serieIndex, isHighlight);
|
||||
var symbolToColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, serieIndex, isHighlight);
|
||||
var symbolEmptyColor = SerieHelper.GetItemBackgroundColor(serie, serieData, chart.theme, serieIndex, isHighlight, false);
|
||||
var symbolColor = SerieHelper.GetItemColor(serie, serieData, chart.theme, j, isHighlight);
|
||||
var symbolToColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, j, isHighlight);
|
||||
var symbolEmptyColor = SerieHelper.GetItemBackgroundColor(serie, serieData, chart.theme, j, isHighlight, false);
|
||||
var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, chart.theme, isHighlight);
|
||||
var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, isHighlight);
|
||||
chart.DrawSymbol(vh, serie.symbol.type, symbolSize, symbolBorder, point, symbolColor,
|
||||
@@ -245,67 +313,30 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsHighlight(RadarCoord radar, Serie serie, SerieData serieData, Tooltip tooltip, int dataIndex, int dimension)
|
||||
private void DrawSingleRadar(VertexHelper vh)
|
||||
{
|
||||
if (serie.highlight || serieData.context.highlight) return true;
|
||||
if (tooltip == null) return false;
|
||||
var selectedSerieIndex = tooltip.runtimeDataIndex[0];
|
||||
if (selectedSerieIndex < 0) return false;
|
||||
if (chart.GetSerie(selectedSerieIndex).radarIndex != serie.radarIndex) return false;
|
||||
switch (serie.radarType)
|
||||
{
|
||||
case RadarType.Multiple:
|
||||
if (radar.isAxisTooltip)
|
||||
{
|
||||
var selectedDimension = tooltip.runtimeDataIndex[2];
|
||||
return selectedDimension == dimension;
|
||||
}
|
||||
else if (tooltip.runtimeDataIndex.Count >= 2)
|
||||
{
|
||||
return tooltip.runtimeDataIndex[0] == serie.index && tooltip.runtimeDataIndex[1] == dataIndex;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
case RadarType.Single:
|
||||
return tooltip.runtimeDataIndex[1] == dataIndex;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
var radar = chart.GetChartComponent<RadarCoord>(serie.radarIndex);
|
||||
if (radar == null)
|
||||
return;
|
||||
|
||||
private void DrawSingleRadar(VertexHelper vh, Serie serie, int i)
|
||||
{
|
||||
var indicatorNum = radar.indicatorList.Count;
|
||||
var angle = 2 * Mathf.PI / indicatorNum;
|
||||
var centerPos = radar.context.center;
|
||||
serie.animation.InitProgress(0, 1);
|
||||
serie.context.dataPoints.Clear();
|
||||
if (!serie.show || serie.animation.HasFadeOut())
|
||||
{
|
||||
return;
|
||||
}
|
||||
var startPoint = Vector3.zero;
|
||||
var toPoint = Vector3.zero;
|
||||
var firstPoint = Vector3.zero;
|
||||
var lastColor = ColorUtil.clearColor32;
|
||||
var firstColor = ColorUtil.clearColor32;
|
||||
|
||||
var radar = chart.GetChartComponent<RadarCoord>(serie.radarIndex);
|
||||
var tooltip = chart.GetChartComponent<Tooltip>();
|
||||
var indicatorNum = radar.indicatorList.Count;
|
||||
var angle = 2 * Mathf.PI / indicatorNum;
|
||||
var centerPos = radar.context.center;
|
||||
var serieNameCount = -1;
|
||||
serie.animation.InitProgress(0, 1);
|
||||
if (!serie.show || serie.animation.HasFadeOut())
|
||||
{
|
||||
return;
|
||||
}
|
||||
var rate = serie.animation.GetCurrRate();
|
||||
var dataChanging = false;
|
||||
var dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
|
||||
int key = i * 1000;
|
||||
if (!radar.context.dataPositionDict.ContainsKey(key))
|
||||
{
|
||||
radar.context.dataPositionDict.Add(i * 1000, new List<Vector3>(serie.dataCount));
|
||||
}
|
||||
else
|
||||
{
|
||||
radar.context.dataPositionDict[key].Clear();
|
||||
}
|
||||
var pointList = radar.context.dataPositionDict[key];
|
||||
var startIndex = GetStartShowIndex(serie);
|
||||
var endIndex = GetEndShowIndex(serie);
|
||||
SerieHelper.UpdateMinMaxData(serie, 1, radar.ceilRate);
|
||||
@@ -314,31 +345,16 @@ namespace XCharts
|
||||
var serieData = serie.data[j];
|
||||
serieData.index = j;
|
||||
string dataName = serieData.name;
|
||||
int serieIndex = 0;
|
||||
if (string.IsNullOrEmpty(dataName))
|
||||
{
|
||||
serieNameCount++;
|
||||
serieIndex = serieNameCount;
|
||||
}
|
||||
else if (!serieNameSet.ContainsKey(dataName))
|
||||
{
|
||||
serieNameSet.Add(dataName, serieNameCount);
|
||||
serieNameCount++;
|
||||
serieIndex = serieNameCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
serieIndex = serieNameSet[dataName];
|
||||
}
|
||||
|
||||
if (!serieData.show)
|
||||
{
|
||||
serieData.context.labelPosition = Vector3.zero;
|
||||
continue;
|
||||
}
|
||||
var isHighlight = IsHighlight(radar, serie, serieData, tooltip, j, 0);
|
||||
var areaColor = SerieHelper.GetAreaColor(serie, chart.theme, serieIndex, isHighlight);
|
||||
var areaToColor = SerieHelper.GetAreaToColor(serie, chart.theme, serieIndex, isHighlight);
|
||||
var lineColor = SerieHelper.GetLineColor(serie, chart.theme, serieIndex, isHighlight);
|
||||
var isHighlight = serie.context.pointerEnter;
|
||||
var areaColor = SerieHelper.GetAreaColor(serie, chart.theme, j, isHighlight);
|
||||
var areaToColor = SerieHelper.GetAreaToColor(serie, chart.theme, j, isHighlight);
|
||||
var lineColor = SerieHelper.GetLineColor(serie, chart.theme, j, isHighlight);
|
||||
int dataCount = radar.indicatorList.Count;
|
||||
var index = serieData.index;
|
||||
var p = radar.context.center;
|
||||
@@ -384,8 +400,8 @@ namespace XCharts
|
||||
startPoint = toPoint;
|
||||
lastColor = lineColor;
|
||||
}
|
||||
serieData.context.position = startPoint;
|
||||
serieData.context.labelPosition = startPoint;
|
||||
pointList.Add(startPoint);
|
||||
|
||||
if (serie.areaStyle.show && j == endIndex)
|
||||
{
|
||||
@@ -406,8 +422,7 @@ namespace XCharts
|
||||
{
|
||||
var serieData = serie.data[j];
|
||||
if (!serieData.show) continue;
|
||||
var isHighlight = serie.highlight || serieData.context.highlight ||
|
||||
(tooltip.show && tooltip.runtimeDataIndex[0] == i && tooltip.runtimeDataIndex[1] == j);
|
||||
var isHighlight = serie.highlight || serieData.context.highlight || serie.context.pointerEnter;
|
||||
var serieIndex = serieData.index;
|
||||
var symbolSize = isHighlight
|
||||
? serie.symbol.GetSelectedSize(serieData.data, chart.theme.serie.lineSymbolSelectedSize)
|
||||
@@ -474,22 +489,5 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsInRadar(Vector2 local)
|
||||
{
|
||||
foreach (var component in chart.components)
|
||||
{
|
||||
if (component is RadarCoord)
|
||||
{
|
||||
var radar = component as RadarCoord;
|
||||
var dist = Vector2.Distance(radar.context.center, local);
|
||||
if (dist < radar.context.radius + chart.theme.serie.lineSymbolSize)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -44,25 +44,53 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var ringIndex = GetRingIndex(chart.pointerPos);
|
||||
if (ringIndex >= 0)
|
||||
{
|
||||
serie.context.pointerEnter = true;
|
||||
serie.context.pointerItemDataIndex = ringIndex;
|
||||
}
|
||||
else
|
||||
{
|
||||
serie.context.pointerEnter = false;
|
||||
serie.context.pointerItemDataIndex = -1;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool SetDefaultTooltipContent(Tooltip tooltip, StringBuilder sb)
|
||||
public override void UpdateTooltipSerieParams(int dataIndex, bool showCategory, string category,
|
||||
string marker, string itemFormatter, string numericFormatter,
|
||||
ref List<SerieParams> paramList, ref string title)
|
||||
{
|
||||
if (!serie.context.pointerEnter || serie.context.pointerItemDataIndex < 0) return false;
|
||||
var serieData = serie.GetSerieData(serie.context.pointerItemDataIndex);
|
||||
if (serieData == null) return false;
|
||||
var key = serieData.name;
|
||||
var numericFormatter = TooltipHelper.GetItemNumericFormatter(tooltip, serie, serieData);
|
||||
var value = serieData.GetData(1);
|
||||
if (!string.IsNullOrEmpty(serie.serieName))
|
||||
{
|
||||
sb.Append(serie.serieName).Append(FormatterHelper.PH_NN);
|
||||
}
|
||||
sb.Append("<color=#").Append(chart.theme.GetColorStr(serie.context.pointerItemDataIndex)).Append(">● </color>");
|
||||
if (!string.IsNullOrEmpty(key))
|
||||
sb.Append(key).Append(": ");
|
||||
sb.Append(ChartCached.FloatToStr(value, numericFormatter));
|
||||
return true;
|
||||
if (dataIndex < 0)
|
||||
dataIndex = serie.context.pointerItemDataIndex;
|
||||
|
||||
if (dataIndex < 0)
|
||||
return;
|
||||
|
||||
var serieData = serie.GetSerieData(dataIndex);
|
||||
if (serieData == null)
|
||||
return;
|
||||
|
||||
var param = serie.context.param;
|
||||
param.serieName = serie.serieName;
|
||||
param.serieIndex = serie.index;
|
||||
param.category = category;
|
||||
param.dimension = 0;
|
||||
param.serieData = serieData;
|
||||
param.value = serieData.GetData(0);
|
||||
param.total = serieData.GetData(1);
|
||||
param.color = chart.theme.GetColor(dataIndex);
|
||||
param.marker = SerieHelper.GetItemMarker(serie, serieData, marker);
|
||||
param.itemFormatter = SerieHelper.GetItemFormatter(serie, serieData, itemFormatter);
|
||||
param.numericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter); ;
|
||||
param.columns.Clear();
|
||||
|
||||
param.columns.Add(param.marker);
|
||||
param.columns.Add(serieData.name);
|
||||
param.columns.Add(ChartCached.NumberToStr(param.value, param.numericFormatter));
|
||||
|
||||
paramList.Add(param);
|
||||
}
|
||||
|
||||
public override void DrawSerie(VertexHelper vh)
|
||||
@@ -268,9 +296,8 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
private int GetRingIndex(Serie serie, Vector2 local)
|
||||
private int GetRingIndex(Vector2 local)
|
||||
{
|
||||
if (!(serie is Ring)) return -1;
|
||||
var dist = Vector2.Distance(local, serie.context.center);
|
||||
if (dist > serie.context.outsideRadius) return -1;
|
||||
Vector2 dir = local - new Vector2(serie.context.center.x, serie.context.center.y);
|
||||
@@ -289,16 +316,6 @@ namespace XCharts
|
||||
return -1;
|
||||
}
|
||||
|
||||
private bool PointerIsInRingSerie(List<Serie> series, Vector2 local)
|
||||
{
|
||||
foreach (var serie in series)
|
||||
{
|
||||
if (!(serie is Ring)) continue;
|
||||
if (GetRingIndex(serie, local) >= 0) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private float VectorAngle(Vector2 from, Vector2 to)
|
||||
{
|
||||
float angle;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
@@ -19,35 +20,38 @@ namespace XCharts
|
||||
UpdateSerieContext();
|
||||
}
|
||||
|
||||
public override bool SetDefaultTooltipContent(Tooltip tooltip, StringBuilder sb)
|
||||
public override void UpdateTooltipSerieParams(int dataIndex, bool showCategory, string category,
|
||||
string marker, string itemFormatter, string numericFormatter,
|
||||
ref List<SerieParams> paramList, ref string title)
|
||||
{
|
||||
var dataIndex = serie.context.pointerItemDataIndex;
|
||||
dataIndex = serie.context.pointerItemDataIndex;
|
||||
if (dataIndex < 0)
|
||||
return false;
|
||||
return;
|
||||
|
||||
var serieData = serie.GetSerieData(dataIndex);
|
||||
if (serieData == null)
|
||||
return false;
|
||||
return;
|
||||
|
||||
double xValue, yValue;
|
||||
serie.GetXYData(dataIndex, null, out xValue, out yValue);
|
||||
title = serie.serieName;
|
||||
|
||||
var key = serie.serieName;
|
||||
var colorIndex = chart.GetLegendRealShowNameIndex(serie.legendName);
|
||||
var numericFormatter = TooltipHelper.GetItemNumericFormatter(tooltip, serie, serieData);
|
||||
var param = serie.context.param;
|
||||
param.serieName = serie.serieName;
|
||||
param.serieIndex = serie.index;
|
||||
param.category = category;
|
||||
param.dimension = 1;
|
||||
param.serieData = serieData;
|
||||
param.color = chart.theme.GetColor(serie.index);
|
||||
param.marker = SerieHelper.GetItemMarker(serie, serieData, marker);
|
||||
param.itemFormatter = SerieHelper.GetItemFormatter(serie, serieData, itemFormatter);
|
||||
param.numericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter);
|
||||
param.columns.Clear();
|
||||
|
||||
if (!string.IsNullOrEmpty(key))
|
||||
sb.Append(key).Append("\n");
|
||||
param.columns.Add(param.marker);
|
||||
if (!string.IsNullOrEmpty(serieData.name))
|
||||
param.columns.Add(serieData.name);
|
||||
param.columns.Add(ChartCached.NumberToStr(serieData.GetData(1), param.numericFormatter));
|
||||
|
||||
sb.Append("<color=#")
|
||||
.Append(chart.theme.GetColorStr(colorIndex))
|
||||
.Append(">● </color>");
|
||||
|
||||
sb.Append(ChartCached.FloatToStr(xValue, numericFormatter))
|
||||
.Append(", ")
|
||||
.Append(ChartCached.FloatToStr(yValue, numericFormatter));
|
||||
|
||||
return true;
|
||||
paramList.Add(param);
|
||||
}
|
||||
|
||||
public override void DrawSerie(VertexHelper vh)
|
||||
|
||||
@@ -1090,10 +1090,11 @@ namespace XCharts
|
||||
get
|
||||
{
|
||||
double total = 0;
|
||||
var duration = animation.GetUpdateAnimationDuration();
|
||||
foreach (var sdata in data)
|
||||
{
|
||||
if (sdata.show && !IsIgnoreValue(sdata.data[1]))
|
||||
total += sdata.GetCurrData(1, animation.GetUpdateAnimationDuration());
|
||||
total += sdata.GetCurrData(1, duration);
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
@@ -101,5 +101,6 @@ namespace XCharts
|
||||
/// 绘制点
|
||||
/// </summary>
|
||||
internal List<PointInfo> drawPoints = new List<PointInfo>();
|
||||
public SerieParams param = new SerieParams();
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
@@ -39,6 +40,7 @@ namespace XCharts
|
||||
public float offsetRadius { get; internal set; }
|
||||
public float outsideRadius { get; set; }
|
||||
public Vector3 position { get; set; }
|
||||
public List<Vector3> dataPoints = new List<Vector3>();
|
||||
/// <summary>
|
||||
/// 绘制区域。
|
||||
/// </summary>
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
@@ -35,11 +36,11 @@ namespace XCharts
|
||||
public virtual void OnScroll(PointerEventData eventData) { }
|
||||
public virtual void RefreshLabelNextFrame() { }
|
||||
public virtual void RefreshLabelInternal() { }
|
||||
public virtual bool SetDefaultTooltipContent(Tooltip tooltip, StringBuilder sb) { return false; }
|
||||
public virtual void UpdateTooltipSerieParams(int dataIndex, bool showCategory, string category, string marker, string itemFormatter, string numericFormatter, ref List<SerieParams> paramList, ref string title) { }
|
||||
public virtual bool OnLegendButtonClick(int index, string legendName, bool show) { return false; }
|
||||
public virtual bool OnLegendButtonEnter(int index, string legendName) { return false; }
|
||||
public virtual bool OnLegendButtonExit(int index, string legendName) { return false; }
|
||||
internal abstract void SerSerie(Serie serie);
|
||||
internal abstract void SetSerie(Serie serie);
|
||||
}
|
||||
|
||||
public abstract class SerieHandler<T> : SerieHandler where T : Serie
|
||||
@@ -52,9 +53,10 @@ namespace XCharts
|
||||
|
||||
public T serie { get; internal set; }
|
||||
|
||||
internal override void SerSerie(Serie serie)
|
||||
internal override void SetSerie(Serie serie)
|
||||
{
|
||||
this.serie = (T)serie;
|
||||
this.serie.context.param.serieType = typeof(T);
|
||||
}
|
||||
public override void Update()
|
||||
{
|
||||
@@ -113,7 +115,7 @@ namespace XCharts
|
||||
private void InitRoot()
|
||||
{
|
||||
m_InitedLabel = false;
|
||||
var objName = s_SerieTitleObjectName + "_" + serie.index;
|
||||
var objName = s_SerieTitleObjectName + "_" + serie.index;
|
||||
m_SerieRoot = ChartHelper.AddObject(objName, chart.transform, chart.chartMinAnchor,
|
||||
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta);
|
||||
m_SerieRoot.hideFlags = chart.chartHideFlags;
|
||||
@@ -244,5 +246,75 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void UpdateCoordSerieParams(ref List<SerieParams> paramList, ref string title,
|
||||
int dataIndex, bool showCategory, string category, string marker,
|
||||
string itemFormatter, string numericFormatter)
|
||||
{
|
||||
if (dataIndex < 0)
|
||||
dataIndex = serie.context.pointerItemDataIndex;
|
||||
|
||||
if (dataIndex < 0)
|
||||
return;
|
||||
|
||||
var serieData = serie.GetSerieData(dataIndex);
|
||||
if (serieData == null)
|
||||
return;
|
||||
|
||||
var param = serie.context.param;
|
||||
param.serieName = serie.serieName;
|
||||
param.serieIndex = serie.index;
|
||||
param.category = category;
|
||||
param.dimension = 1;
|
||||
param.serieData = serieData;
|
||||
param.value = serieData.GetData(1);
|
||||
param.total = serie.yTotal;
|
||||
param.color = chart.GetLegendRealShowNameColor(serie.serieName);
|
||||
param.marker = SerieHelper.GetItemMarker(serie, serieData, marker);
|
||||
param.itemFormatter = SerieHelper.GetItemFormatter(serie, serieData, itemFormatter);
|
||||
param.numericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter); ;
|
||||
param.columns.Clear();
|
||||
|
||||
param.columns.Add(param.marker);
|
||||
param.columns.Add(showCategory ? category : serie.serieName);
|
||||
param.columns.Add(ChartCached.NumberToStr(param.value, param.numericFormatter));
|
||||
|
||||
paramList.Add(param);
|
||||
}
|
||||
|
||||
protected void UpdateItemSerieParams(ref List<SerieParams> paramList, ref string title,
|
||||
int dataIndex, string category, string marker,
|
||||
string itemFormatter, string numericFormatter, int dimension = 1)
|
||||
{
|
||||
if (dataIndex < 0)
|
||||
dataIndex = serie.context.pointerItemDataIndex;
|
||||
|
||||
if (dataIndex < 0)
|
||||
return;
|
||||
|
||||
var serieData = serie.GetSerieData(dataIndex);
|
||||
if (serieData == null)
|
||||
return;
|
||||
|
||||
var param = serie.context.param;
|
||||
param.serieName = serie.serieName;
|
||||
param.serieIndex = serie.index;
|
||||
param.category = category;
|
||||
param.dimension = dimension;
|
||||
param.serieData = serieData;
|
||||
param.value = serieData.GetData(param.dimension);
|
||||
param.total = SerieHelper.GetMaxData(serie, dimension);
|
||||
param.color = chart.theme.GetColor(dataIndex);
|
||||
param.marker = SerieHelper.GetItemMarker(serie, serieData, marker);
|
||||
param.itemFormatter = SerieHelper.GetItemFormatter(serie, serieData, itemFormatter);
|
||||
param.numericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter); ;
|
||||
param.columns.Clear();
|
||||
|
||||
param.columns.Add(param.marker);
|
||||
param.columns.Add(serieData.name);
|
||||
param.columns.Add(ChartCached.NumberToStr(param.value, param.numericFormatter));
|
||||
|
||||
paramList.Add(param);
|
||||
}
|
||||
}
|
||||
}
|
||||
30
Assets/XCharts/Runtime/Serie/SerieParams.cs
Normal file
30
Assets/XCharts/Runtime/Serie/SerieParams.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
public class SerieParams
|
||||
{
|
||||
public Type serieType;
|
||||
public int serieIndex;
|
||||
public string serieName;
|
||||
public string marker = "●";
|
||||
public string category;
|
||||
public int dimension;
|
||||
public SerieData serieData;
|
||||
public double value;
|
||||
public double total;
|
||||
public Color32 color;
|
||||
public string itemFormatter;
|
||||
public string numericFormatter;
|
||||
public List<string> columns = new List<string>();
|
||||
}
|
||||
}
|
||||
11
Assets/XCharts/Runtime/Serie/SerieParams.cs.meta
Normal file
11
Assets/XCharts/Runtime/Serie/SerieParams.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c46808eb5842743c5b02d03c4c503228
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -13,6 +13,7 @@ namespace XCharts
|
||||
[Serializable]
|
||||
public class TooltipTheme : ComponentTheme
|
||||
{
|
||||
|
||||
[SerializeField] protected LineStyle.Type m_LineType = LineStyle.Type.Solid;
|
||||
[SerializeField] protected float m_LineWidth = 1f;
|
||||
[SerializeField] protected Color32 m_LineColor;
|
||||
@@ -47,6 +48,7 @@ namespace XCharts
|
||||
get { return m_LineColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_LineColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the color of line.
|
||||
/// 区域指示的颜色。
|
||||
@@ -83,28 +85,28 @@ namespace XCharts
|
||||
switch (theme)
|
||||
{
|
||||
case ThemeType.Default:
|
||||
m_TextBackgroundColor = ColorUtil.GetColor("#515151C8");
|
||||
m_TextColor = ColorUtil.GetColor("#FFFFFFFF");
|
||||
m_TextBackgroundColor = ColorUtil.GetColor("#FFFFFFFF");
|
||||
m_TextColor = ColorUtil.GetColor("#000000FF");
|
||||
m_AreaColor = ColorUtil.GetColor("#51515120");
|
||||
m_LabelTextColor = ColorUtil.GetColor("#FFFFFFFF");
|
||||
m_LabelBackgroundColor = ColorUtil.GetColor("#292929FF");
|
||||
m_LineColor = ColorUtil.GetColor("#29292964");
|
||||
break;
|
||||
case ThemeType.Light:
|
||||
m_TextBackgroundColor = ColorUtil.GetColor("#515151C8");
|
||||
m_TextColor = ColorUtil.GetColor("#FFFFFFFF");
|
||||
m_TextBackgroundColor = ColorUtil.GetColor("#FFFFFFFF");
|
||||
m_TextColor = ColorUtil.GetColor("#000000FF");
|
||||
m_AreaColor = ColorUtil.GetColor("#51515120");
|
||||
m_LabelTextColor = ColorUtil.GetColor("#FFFFFFFF");
|
||||
m_LabelBackgroundColor = ColorUtil.GetColor("#292929FF");
|
||||
m_LineColor = ColorUtil.GetColor("#29292964");
|
||||
break;
|
||||
case ThemeType.Dark:
|
||||
m_TextBackgroundColor = ColorUtil.GetColor("#515151C8");
|
||||
m_TextColor = ColorUtil.GetColor("#FFFFFFFF");
|
||||
m_TextBackgroundColor = ColorUtil.GetColor("#FFFFFFFF");
|
||||
m_TextColor = ColorUtil.GetColor("#000000FF");
|
||||
m_AreaColor = ColorUtil.GetColor("#51515120");
|
||||
m_LabelTextColor = ColorUtil.GetColor("#FFFFFFFF");
|
||||
m_LabelBackgroundColor = ColorUtil.GetColor("#A7A7A7FF");
|
||||
m_LineColor = ColorUtil.GetColor("#eee");
|
||||
m_LabelBackgroundColor = ColorUtil.GetColor("#292929FF");
|
||||
m_LineColor = ColorUtil.GetColor("#29292964");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user