关于次要蜱,我有一个非常具体的要求.根据不同的几十年,我的客户想要一个具有不同数量的次要刻度的图表.例如,如果十年小于1,他想要10个标签(1,2,3,4,5,6,7,8,9,10)和下面的小标记(1.5,2.5
如果十年是1到2,他想要以下标签(1,2,3,4,5,6,8,10)和以下小标记(1.5,2.5,3.5,4.5,5.5,7,9)
任何帮助非常感谢.我找不到如何覆盖刻度线,所以我可以将它们放在自定义点.我已经想出了自定义标签.
谢谢
这里回答你 here.我在这里发布了最后一个更复杂的例子中的代码,其中自定义标签用于绘制不规则标签,并创建DrawMinorTick函数以手动绘制不规则的自定义次要刻度.uses Series, TeCanvas; procedure TForm1.FormCreate(Sender: TObject); var i: Integer; begin Chart1.View3D:=false; Chart1.Legend.Visible:=false; Chart1.AddSeries(TFastLineSeries).FillSampleValues(10); for i:=0 to Chart1[0].Count-1 do Chart1[0].XValue[i]:=i+1; Chart1.Axes.Bottom.Items.Clear; for i:=1 to 4 do Chart1.Axes.Bottom.Items.Add(i, IntToStr(i)); Chart1.Axes.Bottom.Items.Add(7, '7'); Chart1.Axes.Bottom.Items.Add(10, '10'); Chart1.Axes.Bottom.MinorTickCount:=0; end; procedure TForm1.Chart1AfterDraw(Sender: TObject); begin DrawMinorTick(Chart1.Axes.Bottom, 1.5); DrawMinorTick(Chart1.Axes.Bottom, 2.5); DrawMinorTick(Chart1.Axes.Bottom, 5); DrawMinorTick(Chart1.Axes.Bottom, 6); DrawMinorTick(Chart1.Axes.Bottom, 8); DrawMinorTick(Chart1.Axes.Bottom, 9); end; procedure TForm1.DrawMinorTick(axis: TChartAxis; value: double); var XPos, YPos: Integer; begin Chart1.Canvas.Pen.Color:=axis.MinorTicks.Color; Chart1.Canvas.Pen.Width:=axis.MinorTicks.Width; Chart1.Canvas.Pen.Style:=axis.MinorTicks.Style; if axis.Horizontal then begin XPos:=axis.CalcPosValue(value); YPos:=axis.PosAxis+1; Chart1.Canvas.Line(XPos, YPos, XPos, YPos+axis.MinorTickLength); end else begin XPos:=axis.PosAxis; YPos:=axis.CalcPosValue(value); Chart1.Canvas.Line(XPos, YPos, XPos-axis.MinorTickLength, YPos); end; end;