Charts - comma as a decimal separator

maciekmaciek Member Posts: 13 Contributor II
edited September 2020 in Help
Dear RapidMiner community,

could you please instruct me on how to set comma as a decimal separator for values shown on the chart?

As far as I understand from the tooltip under Axis style -> Labels style [Label value format] there is a way to format numbers appearing on charts, but I am not able to use this hint.

Additionally: what are available options for formatting chart numbers? Where can I find the overview? Any documentation on that available?

Any help would be appreciated.

Best regards
Maciej Pankiewicz

Answers

  • BalazsBaranyBalazsBarany Administrator, Moderator, Employee, RapidMiner Certified Analyst, RapidMiner Certified Expert Posts: 955 Unicorn
    Hi,

    you can't do it in RapidMiner but you can export a chart as a SVG (scalable vector graphics) image which is an XML document. Then you can search and replace the text objects (e. g.   <g class="highcharts-axis-labels highcharts-yaxis-labels" data-z-index="7"> => <text ...>value</text>).

    Regards,
    Balázs
  • maciekmaciek Member Posts: 13 Contributor II

    thank you for your answer. Indeed, exporting as a svg file and editing an xml may be a work around - seems to be faster than putting commas directly on the graphics ;-)

    I tried to create a process that replaces dots with commas using the ReadXML operator, but had some difficulties with the XPath section for identifying appropriate XML elements. Would you also be able to help me with that?

    Best regards
    Maciek
  • BalazsBaranyBalazsBarany Administrator, Moderator, Employee, RapidMiner Certified Analyst, RapidMiner Certified Expert Posts: 955 Unicorn
    Dear Maciek,

    I don't know how I would solve this with Read XML, as there's no corresponding Write XML. However, it is possible with Read Document, Replace Tokens and Write Document, all from the Text Processing extension.

    Example:
    <?xml version="1.0" encoding="UTF-8"?><process version="9.7.002">
      <context>
        <input/>
        <output/>
        <macros>
          <macro>
            <key>inputFile</key>
            <value>/tmp/iris.svg</value>
          </macro>
          <macro>
            <key>outputFile</key>
            <value>/tmp/iris-commas.svg</value>
          </macro>
        </macros>
      </context>
      <operator activated="true" class="process" compatibility="9.7.002" expanded="true" name="Process">
        <parameter key="logverbosity" value="init"/>
        <parameter key="random_seed" value="-1"/>
        <parameter key="send_mail" value="never"/>
        <parameter key="notification_email" value=""/>
        <parameter key="process_duration_for_mail" value="30"/>
        <parameter key="encoding" value="SYSTEM"/>
        <process expanded="true">
          <operator activated="true" class="text:read_document" compatibility="9.3.001" expanded="true" height="68" name="Read Document" width="90" x="112" y="34">
            <parameter key="file" value="%{inputFile}"/>
            <parameter key="extract_text_only" value="false"/>
            <parameter key="use_file_extension_as_type" value="false"/>
            <parameter key="content_type" value="xml"/>
            <parameter key="encoding" value="SYSTEM"/>
          </operator>
          <operator activated="true" class="text:replace_tokens" compatibility="9.3.001" expanded="true" height="68" name="Replace Tokens" width="90" x="246" y="34">
            <list key="replace_dictionary">
              <parameter key="(&lt;text [^&gt;]+ opacity=&quot;1&quot;&gt;[0-9]+)\.([0-9]*&lt;/text&gt;)" value="$1,$2"/>
            </list>
          </operator>
          <operator activated="true" class="text:write_document" compatibility="9.3.001" expanded="true" height="82" name="Write Document" width="90" x="380" y="34">
            <parameter key="file" value="%{outputFile}"/>
            <parameter key="overwrite" value="true"/>
            <parameter key="encoding" value="SYSTEM"/>
          </operator>
          <connect from_op="Read Document" from_port="output" to_op="Replace Tokens" to_port="document"/>
          <connect from_op="Replace Tokens" from_port="document" to_op="Write Document" to_port="document"/>
          <connect from_op="Write Document" from_port="document" to_port="result 1"/>
          <portSpacing port="source_input 1" spacing="0"/>
          <portSpacing port="sink_result 1" spacing="0"/>
          <portSpacing port="sink_result 2" spacing="0"/>
          <description align="left" color="green" colored="true" height="99" resized="true" width="516" x="88" y="129">Reads a chart file produced by the RapidMiner SVG export and changes (hopefully only) axis labels to use a decimal comma instead of the decimal point.&lt;br/&gt;&lt;br/&gt;Enter the input and output filenames in the process context.</description>
        </process>
      </operator>
    </process>
    
    


    Of course, processing XML with regular expressions is a sure path to hilarious errors but in this case it produced meaningful output for me.

    Regards,
    Balázs
  • MarcoBarradasMarcoBarradas Administrator, Employee, RapidMiner Certified Analyst, Member Posts: 272 Unicorn
    @maciek have you tried the Plot Data Operator? you can find it under Extensions/Animated Plots extensions. If you don´t have it try searching on the Marketplace.
Sign In or Register to comment.