Menu

Color of plot area

2018-06-15
2018-07-10
  • Norbert Wołowiec

    Hello I have a new feature to lib: Setting a color of plot area in chart;

    Add new enum in chart.h

    /// @brief The enumeration determines plot area fill style
    enum EPlotAreaFillStyle
    {
        PLOT_AREA_FILL_NONE = 0,
        PLOT_AREA_FILL_SOLID
        //Maybe others will be added in the future, for example gradient or image.
    };
    

    New attributes in struct Diagramm

    EPlotAreaFillStyle plotAreaFillStyle;
    std::string plotAreaFillColor;         ///< plotAreaFillColor RGB string like "FF00FF"
    

    Change constructor

    Diagramm()
        {
            nameSize = 18;
            legend_pos = POS_RIGHT;
            tableData = TBL_DATA_NONE;
            typeMain = CHART_LINEAR;
            typeAdditional = CHART_NONE;
            plotAreaFillStyle = PLOT_AREA_FILL_NONE;
            plotAreaFillColor = "FFFFFF";
            barDir = BAR_DIR_VERTICAL;
            barGroup = BAR_GROUP_CLUSTERED;
            scatterStyle = SCATTER_POINT;
            emptyCellsDisplayMethod = EMPTY_CELLS_DISP_GAPS;
            showDataFromHiddenCells = false;
    
            DrawAdditionalAxis = true;
        }
    

    Add new public method in CChart

    inline EPlotAreaFillStyle GetPlotAreaFillStyle() const { return m_diagramm.plotAreaFillStyle; }
    inline void SetPlotAreaFillStyle(EPlotAreaFillStyle plotAreaFillStyle) { m_diagramm.plotAreaFillStyle = plotAreaFillStyle; }
    inline std::string GetPlotAreaFillColor() const { return m_diagramm.plotAreaFillColor; }
    inline void SetPlotAreaFillColor(std::string plotAreaFillColor) { m_diagramm.plotAreaFillColor = plotAreaFillColor; }
    

    And add code in Chart.cpp in CChart::Save() between lines(194) AddTableData( xmlw ); and xmlw.End( "c:plotArea" );

    if ((m_diagramm.plotAreaFillStyle == EPlotAreaFillStyle::PLOT_AREA_FILL_SOLID) && (m_diagramm.plotAreaFillColor.size() == 6))
    {
        xmlw.Tag("c:spPr").Tag("a:solidFill").TagL("a:srgbClr").Attr("val", m_diagramm.plotAreaFillColor).EndL().End("a:solidFill").End("c:spPr");
    }
    
     
  • Norbert Wołowiec

    SolidFill is easy, others are not.

     
  • Alexandr Belyak

    Alexandr Belyak - 2018-06-18

    Hi,
    Thanks for one more useful improvement.
    I will add it to the new version of the library.

    Also I'll think about how to make a gradient and pattern fills.

     
  • Norbert Wołowiec

    I also think about it in my free time. If I have something, I will write it.

     
  • Norbert Wołowiec

    Wow, I must test it :)

     
  • Alexandr Belyak

    Alexandr Belyak - 2018-07-10

    I would be grateful to you for test and results :-)

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.