|
Xåæ ‡è½´ä¸Šçš„Labelæ²¡æœ‰å±•å¼€ï¼ |
Posted by JerryLia on May-02-2016 22:34 |
|
您好,我在测试您的产å“的时候é‡åˆ°è¿™æ ·çš„问题,如下图所示:
我有两个double数组X[]å’ŒY[],其ä¸Y数组用æ¥ç»˜åˆ¶æ›²çº¿ï¼Œè€ŒX数组用æ¥æ˜¾ç¤ºæ ‡ç¾ã€‚
å…¶ä¸X数组ä¸çš„æ•°æ®å¹¶ä¸æ˜¯ä»Žå°åˆ°å¤§æŽ’列的,而是具有跳跃性,比如:
double labels[] = { 0, 1, 2, 3, 4, 5, 24, 7};
我在绘制的时候,如下代ç 所示:
LineLayer* lineLayer = c->addLineLayer(Y_DoubleArray, color, name);
lineLayer->setXData(X_DoubleArray);
绘制结果如下:
ä¸çŸ¥é“问题出在哪里,烦请指点,ä¸èƒœæ„Ÿæ¿€ï¼
|
Re: Xåæ ‡è½´ä¸Šçš„Labelæ²¡æœ‰å±•å¼€ï¼ |
Posted by Peter Kwan on May-03-2016 01:54 |
|
Hi JerryLia,
If the X[] is used for labels, please use Axis.setLabels, not Layer.setXData. For example:
c->addLineLayer(Y_DoubleArray, color, name);
c->xAxis()->setLabels(X_DoubleArray);
Regards
Peter Kwan |
Re: Xåæ ‡è½´ä¸Šçš„Labelæ²¡æœ‰å±•å¼€ï¼ |
Posted by JerryLia on May-03-2016 06:32 |
|
Peter Kwan,您好ï¼
æ ¹æ®æ‚¨çš„建议将代ç 修改为:
LineLayer* lineLayer = c->addLineLayer(Y_DoubleArray, color, name);
c->xAxis()->setLabels(X_DoubleArray);
c->xAxis()->setLabelStep(X_DoubleArray.len / 20);
但是显示的曲线图形并éžæ˜¯æˆ‘想è¦çš„。请注æ„,X_DoubleArrayä¸çš„æ•°æ®å¹¶éžæ˜¯ä»Žå°åˆ°å¤§ä¾æ¬¡æŽ’列的,它å¯èƒ½æ˜¯æ— åºçš„ã€‚å› æ¤æ‰€ç”»å›¾å½¢ä¸ï¼Œä¸é—´çš„Xåæ ‡å€¼æ¯”è¾ƒå°ï¼Œè€Œä¸¤ç«¯çš„比较大。如下图所示:
我曾ç»ä½¿ç”¨è¿‡TeeChart,åªè¦è°ƒç”¨å®ƒçš„AddXY(double x,double y)方法,它会自动将X轴按照从å°åˆ°å¤§çš„顺åºæŽ’列。
|
Re: Xåæ ‡è½´ä¸Šçš„Labelæ²¡æœ‰å±•å¼€ï¼ |
Posted by Peter Kwan on May-04-2016 00:24 |
|
Hi JerryLia,
如果Xæ•°ç»„æ˜¯ç”¨ä½œã€Œæ˜¾ç¤ºæ ‡ç¾ã€ï¼Œé‚£ChartDirector會把它看æˆã€Œåå—ã€ä¸€æ¨£ï¼ŒåªæœƒæŠŠå®ƒé¡¯ç¤ºï¼Œè€Œä¸ç†æœƒå®ƒçš„æ„æ€ã€‚如果X数组是用作åæ ‡ï¼ŒChartDirectorå°±æœƒæ ¹æ“šå…¶æ•¸å€¼ä¾†åŠƒç·šã€‚æ¤æ™‚x-axisçš„æ ‡ç¾æœƒè‡ªå‹•ç”Ÿæˆã€‚例如 x = {0.97, 9.1, 5.6, 7, 2.32}, x-axis çš„æ ‡ç¾å¯èƒ½æœƒæ˜¯ {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, 通常ä¸æœƒå’ŒX数组完全一樣。
如果X数组是用作åæ ‡, å¯ç”¨ä½ 原來的方法:
LineLayer* lineLayer = c->addLineLayer(Y_DoubleArray, color, name);
lineLayer->(X_DoubleArray);
ä½ åŽŸä¾†çš„å•é¢˜å¯èƒ½æ˜¯ä½ 圖ä¸é‚„有其它柬西,如Bar Chart。æ¤æ™‚å¯ç”¨ Axis.setIndent 解決,例如:
http://www.chartdir.com/forum/download_thread.php?bn=chartdir_general&thread=1226312933#N1226318864
Regards
Peter Kwan |
Re: Xåæ ‡è½´ä¸Šçš„Labelæ²¡æœ‰å±•å¼€ï¼ |
Posted by JerryLia on May-04-2016 21:41 |
|
Peter Kwan,您好ï¼
éžå¸¸æ„Ÿè°¢æ‚¨è€å¿ƒçš„解ç”ï¼
我仔细检查了我的代ç ,按照您所说的能够画出æ£ç¡®çš„图形。
事实上,我想åšä¸€ä¸ªç±»ä¼¼financedemo的图形,于是我从MultiChart继承,å‚ç…§financedemo例å进行修改,但最终ä¸èƒ½æ£ç¡®æ˜¾ç¤ºå›¾åƒï¼Œä¹Ÿå°±æ˜¯Xè½´æ ‡ç¾æ— 法展开。
我附带了一个demo工程用æ¥å±•ç¤ºæˆ‘所说的问题。请帮忙看看问题到底出在哪里ï¼
由于ä¸èƒ½ä¸Šä¼ 大的附件,所以我放到百度网盘,多有ä¸ä¾¿æ•¬è¯·åŽŸè°…ï¼
http://pan.baidu.com/s/1jIgyxs6 |
Re: Xåæ ‡è½´ä¸Šçš„Labelæ²¡æœ‰å±•å¼€ï¼ |
Posted by Peter Kwan on May-05-2016 04:34 |
|
Hi JerryLia,
I have not actually run your code, but I read your code and see that there is a line in IMUChart.cpp:
a->setIndent(true);
Please change the above to the followings to see if this can solve the problem:
a->setIndent(false);
Regards
Peter Kwan |
Re: Xåæ ‡è½´ä¸Šçš„Labelæ²¡æœ‰å±•å¼€ï¼ |
Posted by JerryLia on May-05-2016 08:15 |
|
问题解决了,éžå¸¸æ„Ÿè°¢ï¼ |
|