I am using WinForms to create a line chart. I have two related questions:
How can I draw a vertical line on the chart?
I have tried to draw a vertical line between two points at (0,0) and (0,5) using:
chart1.Series["Pakistan"].Points.AddXY(0, 0);
chart1.Series["Pakistan"].Points.AddXY(0, 5);
Run Code Online (Sandbox Code Playgroud)
However, I get an askew line from (0,0) to (1,5).
How can I label this line with a string on the X axis?
我正在使用 Morris.js 绘制折线图。
是否可以在一行中更改每个点的颜色?
我创建了一个LineChart
使用库 MPAndroidChart 并且一切正常。
现在我想要做的是为图表上的每个条目显示一个可绘制的(图像)而不是默认的圆圈。
我从 API 中尝试了很多选项,但没有运气。
谁能告诉我我该怎么做?
我正在尝试动态更改图例的颜色,因此我的 css 类中没有任何线条和符号的样式。我可以动态更改图表中的所有线条和符号,但遗憾的是无法更改图例。他们保持默认状态。有没有办法动态地做到这一点?
所以,我尝试过:
1)
for (int index = 0; index < series.getData().size(); index++) {
XYChart.Data dataPoint = series.getData().get(index);
Node lineSymbol = dataPoint.getNode().lookup(".chart-legend");
lineSymbol.setStyle("-fx-background-color: #00ff00, #000000; -fx-background-insets: 0, 2;\n" +
" -fx-background-radius: 3px;\n" +
" -fx-padding: 3px;");
}
Run Code Online (Sandbox Code Playgroud)
根据 caspian.css 和下面的链接问题,这应该可以工作,但它给了我NullPointerException因为无法找到 .chart-legend 即使它在那里。
2)
for (Node n : lineChart.getChildrenUnmodifiable())
{
if (n instanceof Legend)
{
final Legend legend = (Legend) n;
// remove the legend
legend.getChildrenUnmodifiable().addListener(new ListChangeListener<Object>()
{
@Override
public void onChanged(Change<?> arg0)
{
for (Node node : …
Run Code Online (Sandbox Code Playgroud)