ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  artifact on chart text string
Posted by David Drell on Sep-30-2012 20:41
Attachments:
at the end of a data-set label 'blebbistatin ' there is an artifact. if I remove the trailing
space at the end of 'blebbistatin' then the artifact just moves to the left one space.

how can I get rid of this artifact?

I am using the c++/win32 lib with Qt. Downloaded the lib on 29 September 2012.

thanks
David
chart.png

  Re: artifact on chart text string
Posted by Peter Kwan on Oct-02-2012 01:03
Attachments:
Hi David,

I have just performed some testing, but I cannot reproduce the problem. I have attached my test code and the resulting chart for your reference.

For your case, would you mind to double check if the B-Blebbistatin is really a standard C text string (char* with null termination)? In some systems, the text string may not be null terminated. For example, if some "string class" is used (such as std::string, QString, CString, etc), and the incorrect method is used to obtain the underlying "const char*" to pass to ChartDirector (such as using the str() method in std::string), the string may not be null terminated. If the text is not null terminated, ChartDirector may think there are additional characters at the end, and these characters can become the "artifact".

To double check, you may use hard code standard C text string "B-Blebbistatin" (like in my test code) to see if the artifact is still there.

If the above still does not solve the problem, would you mind to try my attached test code to see if you can reproduce the problem? If the problem occurs in your machine, please inform me the exact operating system and QT version you are using (the type of Windows, service pack level - because the font files in different Windows versions are slightly different). I will try again with your exact configuration to see if I can reproduce the problem.

If my sample code does not have any problem, but the artifact appears in your own code, is it possible to try to modify my sample code to a similar style to your actual code (such as using similar chart size, margins, etc), to see if it can reproduce the problem. You may also try to simplify your own code (using hard coded data for everything, remove the logo, title, x-axis labels, etc) to see if there is any effect. The objective is to find the simplest code that can reproduce the problem. Please kindly email the code to me so I can try to reproduce the problem.

Regards
Peter Kwan
test.png
helloworld.cpp
#include <QApplication>
#include "qchartviewer.h"


int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
 	QChartViewer viewer;

	//
	// Draw Chart and set to QChartViewer
	//

    // The data for the line chart
    double data0[] = {42, 49, 33, 38, 51, 46, 29, 41, 44, 57, 59, 52, 37, 34, 51, 56,
        56, 60, 70, 76, 63, 67, 75, 64, 51};
    double data1[] = {50, 55, 47, 34, 42, 49, 63, 62, 73, 59, 56, 50, 64, 60, 67, 67,
        58, 59, 73, 77, 84, 82, 80, 84, 98};
    double data2[] = {36, 28, 25, 33, 38, 20, 22, 30, 25, 33, 30, 24, 28, 15, 21, 26,
        46, 42, 48, 45, 43, 52, 64, 60, 70};

    // The labels for the line chart
    const char *labels[] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10",
        "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23",
        "24"};

    XYChart *c = new XYChart(800, 500);
    c->setPlotArea(55, 58, 720, 395);

    // Add a legend box at (50, 30) (top of the chart) with horizontal layout. Use 9
    // pts Arial Bold font. Set the background and border color to Transparent.
    c->addLegend(50, 30, false, "arialbd.ttf", 10)->setBackground(Chart::Transparent);

    c->addTitle("Experiment MVL-0001 : PMA/Blebbistatin/Control");

    // Add a title to the y axis
    c->yAxis()->setTitle("Locomoting Cells (%)");

    // Set the labels on the x axis.
    c->xAxis()->setLabels(StringArray(labels, (int)(sizeof(labels) / sizeof(labels[0]
        ))));

    // Display 1 out of 3 labels on the x-axis.
    c->xAxis()->setLabelStep(3);

    // Add a title to the x axis
    c->xAxis()->setTitle("Time (minutes)");

    // Add a line layer to the chart
    LineLayer *layer = c->addLineLayer();

    // Add the three data sets to the line layer. For demo purpose, we use a dash
    // line color for the last line
    layer->addDataSet(DoubleArray(data0, (int)(sizeof(data0) / sizeof(data0[0]))),
        -1, "G-PMA")->setDataSymbol(Chart::SquareShape);
    layer->addDataSet(DoubleArray(data1, (int)(sizeof(data1) / sizeof(data1[0]))),
        -1, "A-Control")->setDataSymbol(Chart::DiamondShape);
    layer->addDataSet(DoubleArray(data2, (int)(sizeof(data2) / sizeof(data2[0]))),
        -1, "B-Blebbistatin")->setDataSymbol(Chart::TriangleShape);

    // Output the chart
    viewer.setChart(c);
	
	// In this sample project, we do not need to chart object any more, so we 
	// delete it now.
    delete c;
    
    //
    // Show the viewer
    //
    
    viewer.show();
    return app.exec();
}