superset icon indicating copy to clipboard operation
superset copied to clipboard

How to add custom visualisation to Superset?

Open ghost opened this issue 7 years ago • 8 comments

Make sure these boxes are checked before submitting your issue - thank you!

  • [ ] I have checked the superset logs for python stacktraces and included it here as text if there are any.
  • [ ] I have reproduced the issue with at least the latest released version of superset.
  • [ ] I have checked the issue tracker for the same issue and I haven't found one similar.

Superset version

Expected results

Actual results

Steps to reproduce

Can anyone guide me to create my own custom visualisation in Superset?

ghost avatar Dec 21 '18 07:12 ghost

You can add the echarts into the superset

XuanmoFeng avatar Dec 21 '18 08:12 XuanmoFeng

You can add the echarts into the superset

Hey XuanmoFeng, Can you explain it? I didn't get you.

ghost avatar Dec 21 '18 09:12 ghost

Hey ,Can tests above version 0.28.0 be used?I'm using 'python3.7' right now.

dzhmjl3 avatar Dec 21 '18 09:12 dzhmjl3

const propTypes = {
    data: PropTypes.arrayOf(PropTypes.shape({
        country_id: PropTypes.string,
        metric: PropTypes.number,
    })),
    width: PropTypes.number,
    height: PropTypes.number,
    country: PropTypes.string,
    linearColorScheme: PropTypes.string,
    mapBaseUrl: PropTypes.string,
    numberFormat: PropTypes.string,
    sliceId: PropTypes.number,
};


function EchartsCountryMap(element, props) {

    const {
        data,
        width,
        height,
        country,
        linearColorScheme,
        mapBaseUrl = '/static/assets/src/visualizations/EchartsCountryMap/countries',
        numberFormat,
        sliceId,
    } = props;


    const div = d3.select(element);
    const sliceID = 'echarts_slice_' + sliceId;
    const html = '<div id=' + sliceID + ' style="width:' + width + 'px;height:' + height + 'px;"></div>';
    div.html(html); // reset
    const myChart = echarts.init(document.getElementById(sliceID));
.......

You can write others codes like the countryMap

XuanmoFeng avatar Dec 21 '18 10:12 XuanmoFeng

const propTypes = {
    data: PropTypes.arrayOf(PropTypes.shape({
        country_id: PropTypes.string,
        metric: PropTypes.number,
    })),
    width: PropTypes.number,
    height: PropTypes.number,
    country: PropTypes.string,
    linearColorScheme: PropTypes.string,
    mapBaseUrl: PropTypes.string,
    numberFormat: PropTypes.string,
    sliceId: PropTypes.number,
};


function EchartsCountryMap(element, props) {

    const {
        data,
        width,
        height,
        country,
        linearColorScheme,
        mapBaseUrl = '/static/assets/src/visualizations/EchartsCountryMap/countries',
        numberFormat,
        sliceId,
    } = props;


    const div = d3.select(element);
    const sliceID = 'echarts_slice_' + sliceId;
    const html = '<div id=' + sliceID + ' style="width:' + width + 'px;height:' + height + 'px;"></div>';
    div.html(html); // reset
    const myChart = echarts.init(document.getElementById(sliceID));
.......

You can write others codes like the countryMap

Thank you @XuanmoFeng

ghost avatar Dec 21 '18 10:12 ghost

const propTypes = {
    data: PropTypes.arrayOf(PropTypes.shape({
        country_id: PropTypes.string,
        metric: PropTypes.number,
    })),
    width: PropTypes.number,
    height: PropTypes.number,
    country: PropTypes.string,
    linearColorScheme: PropTypes.string,
    mapBaseUrl: PropTypes.string,
    numberFormat: PropTypes.string,
    sliceId: PropTypes.number,
};


function EchartsCountryMap(element, props) {

    const {
        data,
        width,
        height,
        country,
        linearColorScheme,
        mapBaseUrl = '/static/assets/src/visualizations/EchartsCountryMap/countries',
        numberFormat,
        sliceId,
    } = props;


    const div = d3.select(element);
    const sliceID = 'echarts_slice_' + sliceId;
    const html = '<div id=' + sliceID + ' style="width:' + width + 'px;height:' + height + 'px;"></div>';
    div.html(html); // reset
    const myChart = echarts.init(document.getElementById(sliceID));
.......

You can write others codes like the countryMap

Is there any reference how to write echarts code?

ghost avatar Dec 24 '18 06:12 ghost

#6812

kristw avatar Feb 13 '19 12:02 kristw

Hi, Is there any way to add choropleth map/custom map/ or new visualization chart for current version. thanks

vidishanaresh avatar Apr 24 '20 07:04 vidishanaresh