增加ScatterChart同时对Scatter和Line的支持,实现折线图和散点图的组合图

This commit is contained in:
monitor1394
2019-10-02 08:15:02 +08:00
parent 2560170921
commit 437f985b45
9 changed files with 4821 additions and 4769 deletions

View File

@@ -668,20 +668,20 @@ namespace XCharts
if (axis.IsCategory() || !axis.show) return;
int tempMinValue = 0;
int tempMaxValue = 0;
if (m_XAxises[axisIndex].IsValue() && m_YAxises[axisIndex].IsValue())
if (IsValue())
{
if (axis is XAxis)
{
m_Series.GetXMinMaxValue(m_DataZoom, axisIndex, out tempMinValue, out tempMaxValue);
m_Series.GetXMinMaxValue(m_DataZoom, axisIndex, true, out tempMinValue, out tempMaxValue);
}
else
{
m_Series.GetYMinMaxValue(m_DataZoom, axisIndex, out tempMinValue, out tempMaxValue);
m_Series.GetYMinMaxValue(m_DataZoom, axisIndex, true, out tempMinValue, out tempMaxValue);
}
}
else
{
m_Series.GetYMinMaxValue(m_DataZoom, axisIndex, out tempMinValue, out tempMaxValue);
m_Series.GetYMinMaxValue(m_DataZoom, axisIndex, false, out tempMinValue, out tempMaxValue);
}
axis.AdjustMinMaxValue(ref tempMinValue, ref tempMaxValue);
if (tempMinValue != axis.minValue || tempMaxValue != axis.maxValue)
@@ -921,7 +921,7 @@ namespace XCharts
Vector3 np = Vector3.zero;
int minValue = 0;
int maxValue = 100;
m_Series.GetYMinMaxValue(null, 0, out minValue, out maxValue);
m_Series.GetYMinMaxValue(null, 0, IsValue(), out minValue, out maxValue);
axis.AdjustMinMaxValue(ref minValue, ref maxValue);
if (minValue > 0 && maxValue > 0) minValue = 0;
for (int i = 0; i < serie.data.Count; i++)

View File

@@ -8,9 +8,9 @@ namespace XCharts
public partial class CoordinateChart
{
protected float m_BarLastOffset = 0;
protected void DrawYBarSerie(VertexHelper vh, int serieIndex, int stackCount,
Serie serie, int colorIndex, ref List<float> seriesHig)
protected void DrawYBarSerie(VertexHelper vh, int serieIndex, Serie serie, int colorIndex,
ref List<float> seriesHig)
{
if (!IsActive(serie.name)) return;
var xAxis = m_XAxises[serie.axisIndex];
@@ -95,8 +95,8 @@ namespace XCharts
return currHig;
}
protected void DrawXBarSerie(VertexHelper vh, int serieIndex, int stackCount,
Serie serie, int colorIndex, ref List<float> seriesHig)
protected void DrawXBarSerie(VertexHelper vh, int serieIndex, Serie serie, int colorIndex,
ref List<float> seriesHig)
{
if (!IsActive(serie.name)) return;
var showData = serie.GetDataList(m_DataZoom);

View File

@@ -0,0 +1,58 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace XCharts
{
public partial class CoordinateChart
{
protected void DrawScatterSerie(VertexHelper vh,int colorIndex, Serie serie)
{
var yAxis = m_YAxises[serie.axisIndex];
var xAxis = m_XAxises[serie.axisIndex];
var color = serie.symbol.color != Color.clear ? serie.symbol.color : (Color)m_ThemeInfo.GetColor(colorIndex);
color.a *= serie.symbol.opacity;
int maxCount = serie.maxShow > 0 ?
(serie.maxShow > serie.dataCount ? serie.dataCount : serie.maxShow)
: serie.dataCount;
for (int n = serie.minShow; n < maxCount; n++)
{
var serieData = serie.GetDataList(m_DataZoom)[n];
float xValue = serieData.data[0];
float yValue = serieData.data[1];
float pX = coordinateX + xAxis.axisLine.width;
float pY = coordinateY + yAxis.axisLine.width;
float xDataHig = (xValue - xAxis.minValue) / (xAxis.maxValue - xAxis.minValue) * coordinateWid;
float yDataHig = (yValue - yAxis.minValue) / (yAxis.maxValue - yAxis.minValue) * coordinateHig;
var pos = new Vector3(pX + xDataHig, pY + yDataHig);
var datas = serie.data[n].data;
float symbolSize = 0;
if (serie.highlighted || serieData.highlighted)
{
symbolSize = serie.symbol.GetSelectedSize(datas);
}
else
{
symbolSize = serie.symbol.GetSize(datas);
}
if (symbolSize > 100) symbolSize = 100;
if (serie.type == SerieType.EffectScatter)
{
for (int count = 0; count < serie.symbol.animationSize.Count; count++)
{
var nowSize = serie.symbol.animationSize[count];
color.a = (symbolSize - nowSize) / symbolSize;
DrawSymbol(vh, serie.symbol.type, nowSize, 3, pos, color);
}
RefreshChart();
}
else
{
DrawSymbol(vh, serie.symbol.type, symbolSize, 3, pos, color);
}
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2f06734940c9e4f92897bb83573394a7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: