The community forums are in BETA and closed to the public.

Can we republish messages fron one channel into another in PUBNUB

I have a situation where I can get the data from python so I can only publish via python. I need to visualize this data so I need to subscribe to the channel via JavaScript. My visualization libaray C3.js only takes data into the following format:

message: { columns: [ ['x', new Date().getTime()], ['y', Math.floor(Math.random() * 99)] ] }

To get my data like this in python is difficult for me. An easier solution would be to subscribe via JavaScript and again republish the data into my desired format. My question is, is it possible to do that in PUBNUB if so DO I need to publish the data into another channel or the same channel would be ok?

My python code is:

for each in data: y = each.counter_volume x = each.timestamp pubnub.publish(channel='orbit_channel', message=y)

Hey Hina! I created a library called EON that is made to work specifically with C3! And, it includes a function to transform the data on the front end as you request. Check out the transform example. It should be EXACTLY what you need.

Hi Ian, Thank you for your reply. I ran into a problem with EON charts may be you can help me with this. I am trying to render a spline chart . I do not understand what is going wrong here. I can see the data in console, but the chart is not rendering, there are only x and y axis lines. I am getting the data from python SDK and subscribing via javascript SDK. There is no error message in the console.

My python code is

def counterVolume(data):
  for each in data:
    y = each.counter_volume
    data_clean = json.dumps(y, indent=4, separators=(',', ': '))
    print pubnub.publish(channel='channel', message= data_clean)


My subscribe javascript function is

       var data;
       var pubnub = PUBNUB.init({
                                publish_key: 'pub',
                                subscribe_key: 'subf'

       var channel = "c3-spline";
                             history: true,
                            channel: 'channel',
                             flow: true,
                               generate: {
                                bindto: '#chart',
                                data: {
                                x: 'x',
                                labels: false
                               axis : {
                                  x : {
                                  type : 'timeseries',
                                  tick: {
                                 format: '%m-%d %H:%M:%S'
    } }});
    function dataCallback(){
                                  channel: 'channel',
                                  message: function(m){
                                           data = m
                     channel: 'orbit_channel',
                     message: {
                            columns: [
                                     ['x', new Date().getTime()],
                                     ['y', data]

I can see the values in console but I do not understand why it wont render on chart.

Login or Signup to post a comment