change single point color in teechart

我的未来我决定 提交于 2019-12-03 01:12:28

问题


i'm using teechart in java.I want to change some points color in a series,not all of the points.If the point's value is over a specific value,then turn the point into red.
i just know how to change all the point's color,and here is my code.

xline.getPointer().setVisible(true); // 数据点突出显示
// xline.getPointer().setStyle(PointerStyle.CIRCLE);
xline.getPointer().setHorizSize(2);
xline.getPointer().setVertSize(2);
xline.getPointer().setColor(Color.black);
xline.getPointer().getPen().setColor(Color.black);

can someone show me some code on how to do this?


回答1:


You can set a color per each point. Ie:

    tChart1.getAspect().setView3D(false);
    Line xline = new Line(tChart1.getChart());
    xline.fillSampleValues();

    xline.getPointer().setVisible(true); // 数据点突出显示
    // xline.getPointer().setStyle(PointerStyle.CIRCLE);
    xline.getPointer().setHorizSize(2);
    xline.getPointer().setVertSize(2);
    //xline.getPointer().setColor(Color.black);
    //xline.getPointer().getPen().setColor(Color.black);

    double thr = xline.getYValues().getMinimum() + (xline.getYValues().getMaximum() - xline.getYValues().getMinimum()) / 3;
    for (int i=0; i<xline.getCount(); i++) {
        if (xline.getYValues().getValue(i) > thr) {
            xline.getColors().setColor(i, Color.black);
        }
    }


来源:https://stackoverflow.com/questions/30219595/change-single-point-color-in-teechart

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!