mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-18 14:30:10 +00:00
增加折线图和柱形图的tooltip
This commit is contained in:
@@ -25,10 +25,9 @@ namespace xcharts
|
||||
base.Update();
|
||||
}
|
||||
|
||||
protected override void OnPopulateMesh(VertexHelper vh)
|
||||
protected override void DrawChart(VertexHelper vh)
|
||||
{
|
||||
base.OnPopulateMesh(vh);
|
||||
|
||||
base.DrawChart(vh);
|
||||
if(yAxis.type == AxisType.category)
|
||||
{
|
||||
int seriesCount = seriesList.Count;
|
||||
@@ -36,6 +35,16 @@ namespace xcharts
|
||||
float barWid = barInfo.barWid > 1 ? barInfo.barWid : scaleWid * barInfo.barWid;
|
||||
float offset = (scaleWid - barWid * seriesCount - barInfo.space * (seriesCount - 1)) / 2;
|
||||
float max = GetMaxValue();
|
||||
if (tooltip.show && tooltip.DataIndex > 0)
|
||||
{
|
||||
float pX = zeroX + coordinateWid;
|
||||
float pY = zeroY + scaleWid * (tooltip.DataIndex - 1);
|
||||
Vector3 p1 = new Vector3(zeroX, pY);
|
||||
Vector3 p2 = new Vector3(zeroX, pY + scaleWid);
|
||||
Vector3 p3 = new Vector3(pX, pY + scaleWid);
|
||||
Vector3 p4 = new Vector3(pX, pY);
|
||||
ChartUtils.DrawPolygon(vh, p1, p2, p3, p4, themeInfo.tooltipFlagAreaColor);
|
||||
}
|
||||
for (int j = 0; j < seriesCount; j++)
|
||||
{
|
||||
if (!legend.IsShowSeries(j)) continue;
|
||||
@@ -69,6 +78,16 @@ namespace xcharts
|
||||
float barWid = barInfo.barWid > 1 ? barInfo.barWid : scaleWid * barInfo.barWid;
|
||||
float offset = (scaleWid - barWid * seriesCount - barInfo.space * (seriesCount - 1)) / 2;
|
||||
float max = GetMaxValue();
|
||||
if (tooltip.show && tooltip.DataIndex > 0)
|
||||
{
|
||||
float pX = zeroX + scaleWid * (tooltip.DataIndex - 1);
|
||||
float pY = zeroY + coordinateHig;
|
||||
Vector3 p1 = new Vector3(pX, zeroY);
|
||||
Vector3 p2 = new Vector3(pX, pY);
|
||||
Vector3 p3 = new Vector3(pX + scaleWid, pY);
|
||||
Vector3 p4 = new Vector3(pX + scaleWid, zeroY);
|
||||
ChartUtils.DrawPolygon(vh, p1, p2, p3, p4, themeInfo.tooltipFlagAreaColor);
|
||||
}
|
||||
for (int j = 0; j < seriesCount; j++)
|
||||
{
|
||||
if (!legend.IsShowSeries(j)) continue;
|
||||
|
||||
Reference in New Issue
Block a user