Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

superset 0.28.1 integrated echarts method #6883

Closed
mildrabbit opened this issue Feb 15, 2019 · 24 comments
Closed

superset 0.28.1 integrated echarts method #6883

mildrabbit opened this issue Feb 15, 2019 · 24 comments
Labels
inactive Inactive for >= 30 days

Comments

@mildrabbit
Copy link

I want to integrate echarts into superset 0.28.1. How to use it

@Llyfighting
Copy link

You should install superset first,there are many related tutorials on the internet,you can learn from them. I'm doing the same thing now, and I have an unsolvable problem, Maybe we can talk to each other.

@mildrabbit
Copy link
Author

@Llyfighting Thanks! I have set up the development environment, also according to some of the information on the Internet to configure, but also encountered problems, has not been solved.

@Llyfighting
Copy link

An error occurred while rendering the visualization: TypeError: (0 , o.getColorFromScheme) is not a function

Have you ever had this problem?

@mildrabbit
Copy link
Author

@Llyfighting no

@mildrabbit
Copy link
Author

@Llyfighting 看了你的贴子,受益非浅,怎么联系你,有事请教

@EmiyaSaber
Copy link

你这个问题解决了吗?我在Windows下使用pip安装superset之后有好多博客当中的文件都找不到。很困扰

@mildrabbit
Copy link
Author

mildrabbit commented Apr 18, 2019 via email

@EmiyaSaber
Copy link

EmiyaSaber commented Apr 18, 2019 via email

@mildrabbit
Copy link
Author

mildrabbit commented Apr 18, 2019 via email

@gbrian
Copy link
Contributor

gbrian commented Jun 3, 2019

Hi, Do you still working on this @mildrabbit @Llyfighting ?

@mistercrunch
Copy link
Member

echarts looks pretty neat, I'd love to see integrations with Superset.

@gbrian
Copy link
Contributor

gbrian commented Jun 4, 2019

@mistercrunch hold my beer! 🤣

@hamza-iqbal-hi
Copy link

Any news?

@gbrian
Copy link
Contributor

gbrian commented Jun 11, 2019

WIP but slooow dut to fixing bugs. @mistercrunch is this the new way to go: @superset-ui/plugin-*? https://github.com/apache-superset/superset-ui-plugins

Found open question for echarts: apache-superset/superset-ui-plugins#76

@mistercrunch
Copy link
Member

Yes @gbrian, that's the way to go. The whole npm link thing works but isn't ideal. There must be an easy way to work on the plugin locally in the main repo and port it once it's baked. @kristw said he's wrapping up some things around controls before documenting the process of adding a new viz.

@hamza-iqbal-hi
Copy link

@mistercrunch when will we be able to see echarts in superset, or a documentation for adding a new viz?

@EmiyaSaber
Copy link

I have already add some simple Echarts viz to superset, and it get worked. I worked on windows with python and JS. And we need npm to manage the JS file from superset.Everytime we change the JS file from superset , we need to run' npm run dev '.

@thunter009
Copy link
Contributor

@EmiyaSaber mind providing a link to a fork with the working echarts integration you mention? Would love to try testing it out on a private fork I maintain.

@gbrian
Copy link
Contributor

gbrian commented Jul 15, 2019

Hi,

Have an intermediate step while developing the final Chart plugin. Is about using a modified version of the Markup visualization. It requieres just few changes on Superset (no need to deal with plugins repo currently).
Not a final solution but helps in the meantime 😄

image

Changes are:

  • Add Jinja2 templates
  • Add Query and data functionalities

CODE:


class MarkupViz(BaseViz):

    """Use html or markdown to create a free form widget"""

    viz_type = "markup"
    verbose_name = _("Markup")
    is_timeseries = False

    def should_be_timeseries(self):
        fd = self.form_data
        # TODO handle datasource-type-specific code in datasource
        conditions_met = (fd.get("granularity") and fd.get("granularity") != "all") or (
            fd.get("granularity_sqla") and fd.get("time_grain_sqla")
        )
        if fd.get("include_time") and not conditions_met:
            raise Exception(
                _("Pick a granularity in the Time section or " "uncheck 'Include Time'")
            )
        return fd.get("include_time")

    def query_obj(self):
        d = super().query_obj()
        fd = self.form_data

        if fd.get("all_columns") and (fd.get("groupby") or fd.get("metrics")):
            raise Exception(
                _(
                    "Choose either fields to [Group By] and [Metrics] or "
                    "[Columns], not both"
                )
            )

        sort_by = fd.get("timeseries_limit_metric")
        if fd.get("all_columns"):
            d["columns"] = fd.get("all_columns")
            d["groupby"] = []
            order_by_cols = fd.get("order_by_cols") or []
            d["orderby"] = [json.loads(t) for t in order_by_cols]
        elif sort_by:
            sort_by_label = utils.get_metric_name(sort_by)
            if sort_by_label not in utils.get_metric_names(d["metrics"]):
                d["metrics"] += [sort_by]
            d["orderby"] = [(sort_by, not fd.get("order_desc", True))]

        # Add all percent metrics that are not already in the list
        if "percent_metrics" in fd:
            d["metrics"] = d["metrics"] + list(
                filter(lambda m: m not in d["metrics"], fd["percent_metrics"] or [])
            )

        d["is_timeseries"] = self.should_be_timeseries()
        return d

    def get_code(self, df):
        code = self.form_data.get("code", "")
        processor = get_template_processor(self.datasource.database)
        return processor.process_template(code, data=df.to_dict('r'))

    def get_data(self, df):
        print("markup df:%s" % df)
        markup_type = self.form_data.get("markup_type")
        code = self.get_code(df)
        if markup_type == "markdown":
            code = markdown(code, extensions=['tables'])
        return dict(html=code, theme_css=get_css_manifest_files("theme"))


markup.js

import { t } from '@superset-ui/translation';

export default {
  controlPanelSections: [
    {
      label: t('GROUP BY'),
      description: t('Use this section if you want a query that aggregates'),
      expanded: true,
      controlSetRows: [
        ['groupby'],
        ['metrics'],
        ['percent_metrics'],
        ['timeseries_limit_metric', 'row_limit'],
        ['include_time', 'order_desc'],
      ],
    },
    {
      label: t('NOT GROUPED BY'),
      description: t('Use this section if you want to query atomic rows'),
      expanded: true,
      controlSetRows: [
        ['all_columns'],
        ['order_by_cols'],
        ['row_limit', null],
      ],
    },
    {
      label: t('Query'),
      expanded: true,
      controlSetRows: [
        ['adhoc_filters'],
      ],
    },
    {
      label: t('Options'),
      expanded: true,
      controlSetRows: [
        ['table_timestamp_format'],
        ['page_length', null],
        ['include_search', 'table_filter'],
        ['align_pn', 'color_pn'],
      ],
    },
    {
      label: t('Code'),
      expanded: true,
      controlSetRows: [
        ['markup_type'],
        ['code'],
      ],
    },
  ],
  controlOverrides: {
    metrics: {
      validators: [],
    },
  },
};

@stale
Copy link

stale bot commented Sep 13, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. For admin, please label this issue .pinned to prevent stale bot from closing the issue.

@stale stale bot added the inactive Inactive for >= 30 days label Sep 13, 2019
@stale stale bot closed this as completed Sep 20, 2019
@mistercrunch
Copy link
Member

FYI I have a proof of concept up too. It's looking pretty neat.

@gbrian
Copy link
Contributor

gbrian commented Sep 23, 2019

@mistercrunch ,
Cool, I'm following same approach as NVD3. Which branch is your work?

charts_480

Currently it implements basic charts with the option "Emit filter" so had to do some changes around. Still WIP so hope I can share soon.

@gbrian
Copy link
Contributor

gbrian commented Sep 23, 2019

@maltoze
Copy link
Contributor

maltoze commented Sep 25, 2019

https://github.com/apache/incubator-superset/tree/echarts_poc

import EchartsScatterChartPlugin from '@superset-ui/superset-ui-plugin-echarts-scatter/src';

Where is '@superset-ui/superset-ui-plugin-echarts-scatter/src'? I can't find it. @gbrian @mistercrunch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
inactive Inactive for >= 30 days
Projects
None yet
Development

No branches or pull requests

9 participants