图形表示 - 数据分配 [英] Graphical representation - Data Distribution

查看:103
本文介绍了图形表示 - 数据分配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据分布,我想在c ++程序中展示它(例如Eclipse)。有没有可以在这里使用的图书馆?我查找了graphics.h,但似乎花费了很多时间来构建这样的事情。
这样的东西会很棒,但更简单的版本也适用于我。

解决方案

是的,您可以尝试使用 ImageMagick 进行游戏。它包含了许多除C / C ++之外的其他语言的封装!



这里的小示例足以让您开始您想要的!

  int main(int argc,char * argv [])
{
int value [5] = {10,20 ,30,20,10};

双倍宽度(200),高度(200);

Magick ::图表图表;
chart.size(Magick :: Geometry(width,height));
chart.draw(Magick :: DrawableRectangle(0.0,0.0,width,height));

chart.strokeColor(Magick :: Color(255,255,255));
chart.draw(Magick :: DrawableLine(width * 0.1,0.0,width * 0.1,height));
chart.draw(Magick :: DrawableLine(0.0,height * 0.9,width,height * 0.9));

double W(width * 0.8 / 5.0);

for(int i(0); i <= 4; i ++)
{
double X0(width * 0.1 + i * W);
double Y0(height * 0.9);

chart.draw(Magick :: DrawableRectangle(X0,Y0,X0 + W,Y0 - 4.0 * value [i]));
}

chart.write(chart.png);

返回0;
}

它会创建如下图形:



祝你好运!


I have a data distribution that I want to show it in a c++ program (by Eclipse for example). Is there a library that I can use here? I looked for the graphics.h, but it seems to take a lot of time to build such a thing. Something like this would be great, but a simpler version would also work for me.

解决方案

Yes, you could try to play with ImageMagick. It has wrapper for a lot of other languages other than C/C++!

This little demonstration down here is enough for you to start what you want!

int main( int argc, char * argv[] )
{
    int value[ 5 ] = { 10, 20, 30, 20, 10 };

    double width( 200 ), height( 200 );

    Magick::Image chart;
    chart.size( Magick::Geometry( width, height ) );
    chart.draw( Magick::DrawableRectangle( 0.0, 0.0, width, height ) );

    chart.strokeColor( Magick::Color( 255, 255, 255 ) );
    chart.draw( Magick::DrawableLine( width * 0.1, 0.0, width * 0.1, height ) );
    chart.draw( Magick::DrawableLine( 0.0, height * 0.9, width, height * 0.9 ) );

    double W( width * 0.8 / 5.0 );

    for ( int i( 0 ); i <= 4; i++ )
    {
        double X0( width * 0.1 + i * W );
        double Y0( height * 0.9 );

        chart.draw( Magick::DrawableRectangle( X0, Y0, X0 + W, Y0 - 4.0 * value[ i ] ) );
    }

    chart.write( "chart.png" );

    return 0;
}

It creates a graphic like this:

Good luck!

这篇关于图形表示 - 数据分配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆